@inzombieland/nuxt-common 1.16.19 → 1.16.21
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.21";
|
|
6
6
|
|
|
7
7
|
const module = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
@@ -13,7 +13,8 @@ import bus from "./packages/api/bus"
|
|
|
13
13
|
import type { ConfigProviderTheme } from "vant"
|
|
14
14
|
import "@vant/touch-emulator"
|
|
15
15
|
|
|
16
|
-
const theme =
|
|
16
|
+
const theme = ref("")
|
|
17
|
+
const appPreferencesTheme = useLocalStorage("app-preferences-theme", JSON.stringify({ value: "" }))
|
|
17
18
|
const locale = useLocalStorage("locale", "en")
|
|
18
19
|
const user = useUser()
|
|
19
20
|
const activeSessions = useActiveSessions()
|
|
@@ -48,13 +49,21 @@ useSubscribe("WS.SessionsUpdated", async (session: { status?: string; visitorId?
|
|
|
48
49
|
|
|
49
50
|
onMounted(() => {
|
|
50
51
|
watch(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
appPreferencesTheme,
|
|
53
|
+
newThemeValue => {
|
|
54
|
+
try {
|
|
55
|
+
const { value } = JSON.parse(newThemeValue)
|
|
56
|
+
theme.value = value
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error(`Error parsing theme storage object:`, error)
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
if (theme
|
|
61
|
+
if (!theme.value) {
|
|
62
|
+
theme.value = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
|
|
63
|
+
appPreferencesTheme.value = JSON.stringify({ value: theme.value })
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (theme.value === "dark") {
|
|
58
67
|
document.documentElement.classList.remove("light", "van-theme-light")
|
|
59
68
|
document.documentElement.classList.add("dark", "van-theme-dark")
|
|
60
69
|
StyleProvider(Themes.dark)
|
|
@@ -65,7 +74,7 @@ onMounted(() => {
|
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
if ($mobileApp?.changeTheme && typeof $mobileApp.changeTheme === "function") {
|
|
68
|
-
$mobileApp.changeTheme({ theme })
|
|
77
|
+
$mobileApp.changeTheme({ theme: theme.value })
|
|
69
78
|
}
|
|
70
79
|
},
|
|
71
80
|
{ immediate: true }
|
|
@@ -93,7 +102,10 @@ if (typeof window !== "undefined") {
|
|
|
93
102
|
:class="{ app: appLoading }"
|
|
94
103
|
>
|
|
95
104
|
<slot />
|
|
96
|
-
<van-config-provider
|
|
105
|
+
<van-config-provider
|
|
106
|
+
v-if="theme"
|
|
107
|
+
:theme="theme as ConfigProviderTheme"
|
|
108
|
+
/>
|
|
97
109
|
</div>
|
|
98
110
|
</template>
|
|
99
111
|
|
|
@@ -121,8 +121,8 @@ export const changeTheme = async (body) => {
|
|
|
121
121
|
updateUser(body);
|
|
122
122
|
}
|
|
123
123
|
if (typeof window !== "undefined") {
|
|
124
|
-
const theme = useLocalStorage("theme", "
|
|
125
|
-
theme.value = body.theme;
|
|
124
|
+
const theme = useLocalStorage("app-preferences-theme", JSON.stringify({ value: "" }));
|
|
125
|
+
theme.value = JSON.stringify({ value: body.theme });
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
128
|
export const changeLocale = async (body) => {
|
|
@@ -29,7 +29,8 @@ export function initApiFetch($fetch, config) {
|
|
|
29
29
|
refreshToken
|
|
30
30
|
};
|
|
31
31
|
if (typeof window !== "undefined") {
|
|
32
|
-
const
|
|
32
|
+
const loggedIn = useLocalStorage("lin", "no");
|
|
33
|
+
const theme = useLocalStorage("app-preferences-theme", JSON.stringify({ value: "" }));
|
|
33
34
|
const locale = useLocalStorage("locale", "en");
|
|
34
35
|
const cometServerURL = config.cometServerURL;
|
|
35
36
|
let cometClient;
|
|
@@ -44,8 +45,14 @@ export function initApiFetch($fetch, config) {
|
|
|
44
45
|
cometClient.stop();
|
|
45
46
|
cometClient.isStarted = false;
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
loggedIn.value = user ? "yes" : "no";
|
|
49
|
+
try {
|
|
50
|
+
const { value } = JSON.parse(theme.value);
|
|
51
|
+
if (user && user.theme !== value) {
|
|
52
|
+
theme.value = JSON.stringify({ value: user.theme });
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error(`Error parsing theme storage object:`, error);
|
|
49
56
|
}
|
|
50
57
|
if (user && user.locale !== locale.value) {
|
|
51
58
|
locale.value = user.locale;
|