Repository navigation
Expand file tree
/
Copy pathapp.vue
More file actions
72 lines (57 loc) · 1.87 KB
/
Copy pathapp.vue
File metadata and controls
72 lines (57 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<script setup lang="ts">
import { computed, defineAsyncComponent } from "vue";
import { polyfillCountryFlagEmojis } from "country-flag-emoji-polyfill";
import { useBranding } from "~/composables/useBranding";
import { useApplicationSettingsStore } from "~/stores/ApplicationSettings";
import { useAuthStore } from "~/stores/AuthStore";
const MatchmakingConfirm = defineAsyncComponent(
() => import("~/components/matchmaking/MatchmakingConfirm.vue"),
);
const PlayerNameRegistration = defineAsyncComponent(
() => import("~/components/PlayerNameRegistration.vue"),
);
const StreamGlobal = defineAsyncComponent(
() => import("~/components/StreamGlobal.vue"),
);
polyfillCountryFlagEmojis();
useBranding();
const authStore = useAuthStore();
const applicationSettingsStore = useApplicationSettingsStore();
const me = computed(() => authStore.me);
const hasGlobalStream = computed(() => !!applicationSettingsStore.globalStream);
const TAB_QUERY_KEYS = new Set(["tab", "mode"]);
function pageKeyWithoutTabQuery(route: {
path: string;
query: Record<string, unknown>;
hash?: string;
}) {
const query = new URLSearchParams();
Object.keys(route.query)
.filter((key) => !TAB_QUERY_KEYS.has(key))
.sort()
.forEach((key) => {
const value = route.query[key];
const values = Array.isArray(value) ? value : [value];
values.forEach((item) => {
if (item == null) {
return;
}
query.append(key, String(item));
});
});
const queryString = query.toString();
return `${route.path}${queryString ? `?${queryString}` : ""}${route.hash || ""}`;
}
</script>
<template>
<NuxtPwaManifest />
<StreamGlobal v-if="hasGlobalStream" />
<template v-if="me">
<PlayerNameRegistration />
<MatchmakingConfirm />
</template>
<NuxtLayout>
<NuxtPage :page-key="pageKeyWithoutTabQuery" />
</NuxtLayout>
<Toaster />
</template>