@inzombieland/nuxt-common 1.16.15 → 1.16.16
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.16";
|
|
6
6
|
|
|
7
7
|
const module = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { Locale as VarletLocale } from "@varlet/ui"
|
|
3
3
|
import { useLocalStorage } from "@vueuse/core"
|
|
4
4
|
import { useI18n, useLocalePath } from "#i18n"
|
|
5
5
|
import { useNuxtApp } from "#imports"
|
|
@@ -48,36 +48,12 @@ useSubscribe("WS.SessionsUpdated", async (session: { status?: string; visitorId?
|
|
|
48
48
|
})
|
|
49
49
|
|
|
50
50
|
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
51
|
watch(
|
|
65
52
|
theme,
|
|
66
53
|
theme => {
|
|
67
54
|
if (!theme) {
|
|
68
55
|
theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
|
|
69
56
|
}
|
|
70
|
-
|
|
71
|
-
if (theme === "dark") {
|
|
72
|
-
document.documentElement.classList.remove("light", "van-theme-light")
|
|
73
|
-
document.documentElement.classList.add("dark", "van-theme-dark")
|
|
74
|
-
StyleProvider(Themes.dark)
|
|
75
|
-
} else {
|
|
76
|
-
document.documentElement.classList.remove("dark", "van-theme-dark")
|
|
77
|
-
document.documentElement.classList.add("light", "van-theme-light")
|
|
78
|
-
StyleProvider(null)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
57
|
if ($mobileApp?.changeTheme && typeof $mobileApp.changeTheme === "function") {
|
|
82
58
|
$mobileApp.changeTheme({ theme })
|
|
83
59
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { StyleProvider, Themes } from "@varlet/ui";
|
|
2
|
+
import { useLocalStorage } from "@vueuse/core";
|
|
3
|
+
import { watch } from "vue";
|
|
1
4
|
import { createApiFetch } from "./api-client.mjs";
|
|
2
5
|
import bus from "./bus.mjs";
|
|
3
6
|
import { newCometClient } from "./comet-client.mjs";
|
|
@@ -23,6 +26,8 @@ export function initApiFetch($fetch, config) {
|
|
|
23
26
|
refreshToken
|
|
24
27
|
};
|
|
25
28
|
if (typeof window !== "undefined") {
|
|
29
|
+
const theme = useLocalStorage("theme", "");
|
|
30
|
+
const locale = useLocalStorage("locale", "en");
|
|
26
31
|
const cometServerURL = config.cometServerURL;
|
|
27
32
|
let cometClient;
|
|
28
33
|
bus.subscribe("user:onUpdated", (user) => {
|
|
@@ -36,7 +41,31 @@ export function initApiFetch($fetch, config) {
|
|
|
36
41
|
cometClient.stop();
|
|
37
42
|
cometClient.isStarted = false;
|
|
38
43
|
}
|
|
44
|
+
if (user && user.theme !== theme.value) {
|
|
45
|
+
theme.value = user.theme;
|
|
46
|
+
}
|
|
47
|
+
if (user && user.locale !== locale.value) {
|
|
48
|
+
locale.value = user.locale;
|
|
49
|
+
}
|
|
39
50
|
});
|
|
51
|
+
watch(
|
|
52
|
+
theme,
|
|
53
|
+
(theme2) => {
|
|
54
|
+
if (!theme2) {
|
|
55
|
+
theme2 = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
56
|
+
}
|
|
57
|
+
if (theme2 === "dark") {
|
|
58
|
+
document.documentElement.classList.remove("light", "van-theme-light");
|
|
59
|
+
document.documentElement.classList.add("dark", "van-theme-dark");
|
|
60
|
+
StyleProvider(Themes.dark);
|
|
61
|
+
} else {
|
|
62
|
+
document.documentElement.classList.remove("dark", "van-theme-dark");
|
|
63
|
+
document.documentElement.classList.add("light", "van-theme-light");
|
|
64
|
+
StyleProvider(null);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{ immediate: true }
|
|
68
|
+
);
|
|
40
69
|
}
|
|
41
70
|
return { fetch, getUser, getVisitorIdentifier, useApiFetch, userActions };
|
|
42
71
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inzombieland/api",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.16",
|
|
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",
|