@inzombieland/nuxt-common 1.16.21 → 1.16.23

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.21",
3
+ "version": "1.16.23",
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.21";
5
+ const version = "1.16.23";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -15,7 +15,7 @@ import "@vant/touch-emulator"
15
15
 
16
16
  const theme = ref("")
17
17
  const appPreferencesTheme = useLocalStorage("app-preferences-theme", JSON.stringify({ value: "" }))
18
- const locale = useLocalStorage("locale", "en")
18
+ const locale = useLocalStorage("app-preferences-locale", JSON.stringify({ value: "en" }))
19
19
  const user = useUser()
20
20
  const activeSessions = useActiveSessions()
21
21
  const { fetchActiveSessions, logout } = useUserActions()
@@ -52,10 +52,12 @@ onMounted(() => {
52
52
  appPreferencesTheme,
53
53
  newThemeValue => {
54
54
  try {
55
- const { value } = JSON.parse(newThemeValue)
56
- theme.value = value
55
+ if (newThemeValue) {
56
+ const { value } = JSON.parse(newThemeValue)
57
+ theme.value = value
58
+ }
57
59
  } catch (error) {
58
- console.error(`Error parsing theme storage object:`, error)
60
+ console.error(`Error parsing app preferences theme:`, error)
59
61
  }
60
62
 
61
63
  if (!theme.value) {
@@ -83,7 +85,13 @@ onMounted(() => {
83
85
  watch(
84
86
  locale,
85
87
  locale => {
86
- setLocale(locale as "en" | "ru")
88
+ try {
89
+ const { value } = JSON.parse(locale)
90
+ setLocale(value)
91
+ } catch (error) {
92
+ console.error(`Error parsing app preferences locale:`, error)
93
+ setLocale("en")
94
+ }
87
95
  },
88
96
  { immediate: true }
89
97
  )
@@ -134,8 +134,8 @@ export const changeLocale = async (body) => {
134
134
  if (typeof window !== "undefined") {
135
135
  const localeCookie = useCookie("locale", { maxAge: 60 * 60 * 24 * 365 });
136
136
  localeCookie.value = body.locale;
137
- const locale = useLocalStorage("locale", "en");
138
- locale.value = body.locale;
137
+ const locale = useLocalStorage("app-preferences-locale", JSON.stringify({ value: "" }));
138
+ locale.value = JSON.stringify({ value: body.locale });
139
139
  }
140
140
  };
141
141
  export const changeAvatar = async (body) => {
@@ -31,7 +31,7 @@ export function initApiFetch($fetch, config) {
31
31
  if (typeof window !== "undefined") {
32
32
  const loggedIn = useLocalStorage("lin", "no");
33
33
  const theme = useLocalStorage("app-preferences-theme", JSON.stringify({ value: "" }));
34
- const locale = useLocalStorage("locale", "en");
34
+ const locale = useLocalStorage("app-preferences-locale", JSON.stringify({ value: "en" }));
35
35
  const cometServerURL = config.cometServerURL;
36
36
  let cometClient;
37
37
  bus.subscribe("user:onUpdated", (user) => {
@@ -52,19 +52,32 @@ export function initApiFetch($fetch, config) {
52
52
  theme.value = JSON.stringify({ value: user.theme });
53
53
  }
54
54
  } catch (error) {
55
- console.error(`Error parsing theme storage object:`, error);
55
+ console.error(`Error parsing app preferences theme:`, error);
56
56
  }
57
- if (user && user.locale !== locale.value) {
58
- locale.value = user.locale;
57
+ try {
58
+ const { value } = JSON.parse(locale.value);
59
+ if (user && user.locale !== value) {
60
+ locale.value = JSON.stringify({ value: user.locale });
61
+ }
62
+ } catch (error) {
63
+ console.error(`Error parsing app preferences locale:`, error);
59
64
  }
60
65
  });
61
66
  watch(
62
67
  locale,
63
68
  (locale2) => {
64
- if (locale2 === "ru") {
65
- VantLocale.use(locale2, ruRU);
66
- VarletLocale.add("en-US", VarletLocale.enUS);
67
- } else {
69
+ try {
70
+ const { value } = JSON.parse(locale2);
71
+ if (value === "en") {
72
+ VantLocale.use(locale2, enUS);
73
+ VarletLocale.add("en-US", VarletLocale.enUS);
74
+ }
75
+ if (value === "ru") {
76
+ VantLocale.use(locale2, ruRU);
77
+ VarletLocale.add("en-US", VarletLocale.enUS);
78
+ }
79
+ } catch (error) {
80
+ console.error(`Error parsing app preferences locale:`, error);
68
81
  VantLocale.use(locale2, enUS);
69
82
  VarletLocale.add("en-US", VarletLocale.enUS);
70
83
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/api",
3
- "version": "1.16.21",
3
+ "version": "1.16.23",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
@@ -1,10 +1,8 @@
1
- import { useLocalStorage } from "@vueuse/core";
2
1
  import { addRouteMiddleware, defineNuxtPlugin } from "#app";
3
2
  import { useRequestHeaders, useRuntimeConfig, useState } from "#imports";
4
3
  import { fetch, getUser } from "./api/index.mjs";
5
4
  import { authMiddleware, guestMiddleware, localeMiddleware } from "./middleware/index.mjs";
6
5
  import { flush, setToken, setUser } from "./packages/api/api-client.mjs";
7
- import bus from "./packages/api/bus.mjs";
8
6
  const useAuth = () => {
9
7
  return useState("auth", () => null);
10
8
  };
@@ -28,10 +26,6 @@ export default defineNuxtPlugin(async (nuxtApp) => {
28
26
  }
29
27
  nuxtApp.hook("app:beforeMount", () => {
30
28
  auth.value = null;
31
- bus.subscribe("user:onUpdated", (value) => {
32
- const loggedIn = useLocalStorage("lin", "no");
33
- loggedIn.value = value ? "yes" : "no";
34
- });
35
29
  });
36
30
  addRouteMiddleware("auth", authMiddleware, { global: false });
37
31
  addRouteMiddleware("guest", guestMiddleware, { global: false });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.16.21",
3
+ "version": "1.16.23",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {