@inzombieland/nuxt-common 1.16.20 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.16.20",
3
+ "version": "1.16.21",
4
4
  "configKey": "nuxt-common",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.6.0",
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.20";
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 = useLocalStorage("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
- theme,
52
- theme => {
53
- if (!theme) {
54
- theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"
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 === "dark") {
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 :theme="theme as ConfigProviderTheme" />
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", "light");
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) => {
@@ -30,7 +30,7 @@ export function initApiFetch($fetch, config) {
30
30
  };
31
31
  if (typeof window !== "undefined") {
32
32
  const loggedIn = useLocalStorage("lin", "no");
33
- const theme = useLocalStorage("theme", "");
33
+ const theme = useLocalStorage("app-preferences-theme", JSON.stringify({ value: "" }));
34
34
  const locale = useLocalStorage("locale", "en");
35
35
  const cometServerURL = config.cometServerURL;
36
36
  let cometClient;
@@ -46,8 +46,13 @@ export function initApiFetch($fetch, config) {
46
46
  cometClient.isStarted = false;
47
47
  }
48
48
  loggedIn.value = user ? "yes" : "no";
49
- if (user && user.theme !== theme.value) {
50
- theme.value = user.theme;
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);
51
56
  }
52
57
  if (user && user.locale !== locale.value) {
53
58
  locale.value = user.locale;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/api",
3
- "version": "1.16.20",
3
+ "version": "1.16.21",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.16.20",
3
+ "version": "1.16.21",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {