@inzombieland/nuxt-common 1.16.15 → 1.16.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
2
2
|
import { defineNuxtModule, createResolver, addServerHandler, addImportsDir, addPlugin, addComponent } from '@nuxt/kit';
|
|
3
3
|
|
|
4
4
|
const name = "@inzombieland/nuxt-common";
|
|
5
|
-
const version = "1.16.
|
|
5
|
+
const version = "1.16.17";
|
|
6
6
|
|
|
7
7
|
const module = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { StyleProvider, Themes
|
|
2
|
+
import { StyleProvider, Themes } from "@varlet/ui"
|
|
3
3
|
import { useLocalStorage } from "@vueuse/core"
|
|
4
4
|
import { useI18n, useLocalePath } from "#i18n"
|
|
5
5
|
import { useNuxtApp } from "#imports"
|
|
6
|
-
import { setNotifyDefaultOptions, Locale as VantLocale, type ConfigProviderTheme } from "vant"
|
|
7
|
-
import enUS from "vant/es/locale/lang/en-US"
|
|
8
|
-
import ruRU from "vant/es/locale/lang/ru-RU"
|
|
9
6
|
import { onMounted, ref, watch } from "vue"
|
|
10
7
|
import { useRouter } from "vue-router"
|
|
11
8
|
import { getVisitorId, getVisitorIdentifier } from "./api"
|
|
12
9
|
import { useActiveSessions } from "./composables/use-active-sessions"
|
|
13
10
|
import { useUserActions } from "./composables/use-user-actions"
|
|
14
11
|
import { useSubscribe, useUser } from "./packages/api"
|
|
12
|
+
import type { ConfigProviderTheme } from "vant"
|
|
15
13
|
import "@vant/touch-emulator"
|
|
16
14
|
|
|
17
15
|
const theme = useLocalStorage("theme", "")
|
|
@@ -48,19 +46,6 @@ useSubscribe("WS.SessionsUpdated", async (session: { status?: string; visitorId?
|
|
|
48
46
|
})
|
|
49
47
|
|
|
50
48
|
onMounted(() => {
|
|
51
|
-
watch(
|
|
52
|
-
user,
|
|
53
|
-
user => {
|
|
54
|
-
if (user && user.theme !== theme.value) {
|
|
55
|
-
theme.value = user.theme
|
|
56
|
-
}
|
|
57
|
-
if (user && user.locale !== locale.value) {
|
|
58
|
-
locale.value = user.locale
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
{ immediate: true }
|
|
62
|
-
)
|
|
63
|
-
|
|
64
49
|
watch(
|
|
65
50
|
theme,
|
|
66
51
|
theme => {
|
|
@@ -87,21 +72,12 @@ onMounted(() => {
|
|
|
87
72
|
|
|
88
73
|
watch(
|
|
89
74
|
locale,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
VantLocale.use(locale.value, ruRU)
|
|
93
|
-
VarletLocale.add("en-US", VarletLocale.enUS)
|
|
94
|
-
} else {
|
|
95
|
-
VantLocale.use(locale.value, enUS)
|
|
96
|
-
VarletLocale.add("en-US", VarletLocale.enUS)
|
|
97
|
-
}
|
|
98
|
-
setLocale(locale.value as "en" | "ru")
|
|
75
|
+
locale => {
|
|
76
|
+
setLocale(locale as "en" | "ru")
|
|
99
77
|
},
|
|
100
78
|
{ immediate: true }
|
|
101
79
|
)
|
|
102
80
|
|
|
103
|
-
setNotifyDefaultOptions({ position: "bottom" })
|
|
104
|
-
|
|
105
81
|
appLoading.value = false
|
|
106
82
|
})
|
|
107
83
|
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { Locale as VarletLocale } from "@varlet/ui";
|
|
2
|
+
import { useLocalStorage } from "@vueuse/core";
|
|
3
|
+
import { setNotifyDefaultOptions, Locale as VantLocale } from "vant";
|
|
4
|
+
import enUS from "vant/es/locale/lang/en-US";
|
|
5
|
+
import ruRU from "vant/es/locale/lang/ru-RU";
|
|
6
|
+
import { watch } from "vue";
|
|
1
7
|
import { createApiFetch } from "./api-client.mjs";
|
|
2
8
|
import bus from "./bus.mjs";
|
|
3
9
|
import { newCometClient } from "./comet-client.mjs";
|
|
@@ -23,6 +29,8 @@ export function initApiFetch($fetch, config) {
|
|
|
23
29
|
refreshToken
|
|
24
30
|
};
|
|
25
31
|
if (typeof window !== "undefined") {
|
|
32
|
+
const theme = useLocalStorage("theme", "");
|
|
33
|
+
const locale = useLocalStorage("locale", "en");
|
|
26
34
|
const cometServerURL = config.cometServerURL;
|
|
27
35
|
let cometClient;
|
|
28
36
|
bus.subscribe("user:onUpdated", (user) => {
|
|
@@ -36,7 +44,27 @@ export function initApiFetch($fetch, config) {
|
|
|
36
44
|
cometClient.stop();
|
|
37
45
|
cometClient.isStarted = false;
|
|
38
46
|
}
|
|
47
|
+
if (user && user.theme !== theme.value) {
|
|
48
|
+
theme.value = user.theme;
|
|
49
|
+
}
|
|
50
|
+
if (user && user.locale !== locale.value) {
|
|
51
|
+
locale.value = user.locale;
|
|
52
|
+
}
|
|
39
53
|
});
|
|
54
|
+
watch(
|
|
55
|
+
locale,
|
|
56
|
+
(locale2) => {
|
|
57
|
+
if (locale2 === "ru") {
|
|
58
|
+
VantLocale.use(locale2, ruRU);
|
|
59
|
+
VarletLocale.add("en-US", VarletLocale.enUS);
|
|
60
|
+
} else {
|
|
61
|
+
VantLocale.use(locale2, enUS);
|
|
62
|
+
VarletLocale.add("en-US", VarletLocale.enUS);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{ immediate: true }
|
|
66
|
+
);
|
|
67
|
+
setNotifyDefaultOptions({ position: "bottom" });
|
|
40
68
|
}
|
|
41
69
|
return { fetch, getUser, getVisitorIdentifier, useApiFetch, userActions };
|
|
42
70
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inzombieland/api",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "./index.mjs",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fingerprintjs/fingerprintjs": "^4.6.2",
|
|
13
|
+
"@varlet/ui": "^3.10.5",
|
|
13
14
|
"@vueuse/core": "^12.8.2",
|
|
14
15
|
"centrifuge": "^5.3.4",
|
|
15
16
|
"ofetch": "^1.4.1",
|