@inzombieland/nuxt-common 1.18.5 → 1.18.8
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 +1 -1
- package/dist/module.mjs +1 -2
- package/dist/runtime/api/index.d.ts +6 -0
- package/dist/runtime/api/user-actions.d.ts +0 -6
- package/dist/runtime/api/user-actions.mjs +2 -26
- package/dist/runtime/packages/core/define-vue-plugins.d.ts +4 -0
- package/dist/runtime/packages/core/define-vue-plugins.mjs +4 -0
- package/dist/runtime/packages/core/index.d.ts +19 -0
- package/dist/runtime/packages/core/index.mjs +1 -0
- package/dist/runtime/packages/core/init-application.mjs +3 -1
- package/dist/runtime/packages/core/package.json +1 -1
- package/dist/runtime/packages/core/plugins/index.d.ts +1 -0
- package/dist/runtime/packages/core/plugins/index.mjs +1 -0
- package/dist/runtime/{ui/varlet.d.ts → packages/core/plugins/varlet-ui.d.ts} +4 -2
- package/dist/runtime/{ui/varlet.mjs → packages/core/plugins/varlet-ui.mjs} +6 -7
- package/dist/runtime/packages/core/user-actions.d.ts +6 -0
- package/dist/runtime/packages/core/user-actions.mjs +15 -1
- package/dist/runtime/plugin.mjs +12 -2
- package/package.json +1 -1
- package/dist/runtime/composables/use-helpers.d.ts +0 -16
- package/dist/runtime/composables/use-helpers.mjs +0 -4
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.18.
|
|
5
|
+
const version = "1.18.8";
|
|
6
6
|
|
|
7
7
|
const module = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
@@ -47,7 +47,6 @@ const module = defineNuxtModule({
|
|
|
47
47
|
});
|
|
48
48
|
addImportsDir(resolve(runtimeDir, "composables"));
|
|
49
49
|
addPlugin(resolve(runtimeDir, "plugin"));
|
|
50
|
-
addPlugin(resolve(runtimeDir, "ui/varlet"));
|
|
51
50
|
addPlugin(resolve(runtimeDir, "plugins/device"));
|
|
52
51
|
addPlugin(resolve(runtimeDir, "plugins/otp-input"));
|
|
53
52
|
addPlugin(resolve(runtimeDir, "plugins/sanitize-html"));
|
|
@@ -28,5 +28,11 @@ declare const fetch: Fetch, getUser: () => Promise<import("src/runtime/packages/
|
|
|
28
28
|
fetchActiveSessions: () => Promise<{
|
|
29
29
|
sessions: import("src/runtime/packages/core/types").ActiveSession[];
|
|
30
30
|
}>;
|
|
31
|
+
changeTheme: (body: {
|
|
32
|
+
theme: "light" | "dark";
|
|
33
|
+
}) => Promise<void>;
|
|
34
|
+
changeLocale: (body: {
|
|
35
|
+
locale: string;
|
|
36
|
+
}) => Promise<void>;
|
|
31
37
|
};
|
|
32
38
|
export { fetch, getUser, useApiFetch, userActions };
|
|
@@ -87,12 +87,6 @@ export declare const changePhone: (body: {
|
|
|
87
87
|
phone: string;
|
|
88
88
|
password: string;
|
|
89
89
|
}) => Promise<void>;
|
|
90
|
-
export declare const changeTheme: (body: {
|
|
91
|
-
theme: "light" | "dark";
|
|
92
|
-
}) => Promise<void>;
|
|
93
|
-
export declare const changeLocale: (body: {
|
|
94
|
-
locale: string;
|
|
95
|
-
}) => Promise<void>;
|
|
96
90
|
export declare const changeAvatar: (body: FormData) => Promise<void>;
|
|
97
91
|
export declare const deleteAvatar: () => Promise<void>;
|
|
98
92
|
export declare const fetchActiveSessions: () => Promise<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useRequestHeaders } from "#imports";
|
|
2
|
+
import { useUser } from "../packages/core/index.mjs";
|
|
3
3
|
import { flush, setToken, updateUser } from "../packages/core/api-client.mjs";
|
|
4
4
|
import { fetch, getUser, userActions } from "./index.mjs";
|
|
5
5
|
export const signIn = userActions.signIn;
|
|
@@ -114,30 +114,6 @@ export const changePhone = async (body) => {
|
|
|
114
114
|
await fetch("/account/1/change/phone", { body, method: "POST" });
|
|
115
115
|
updateUser({ phone: body.phone });
|
|
116
116
|
};
|
|
117
|
-
export const changeTheme = async (body) => {
|
|
118
|
-
const user = useUser();
|
|
119
|
-
if (user.value) {
|
|
120
|
-
await fetch("/account/1/change/theme", { body, method: "POST" });
|
|
121
|
-
updateUser(body);
|
|
122
|
-
}
|
|
123
|
-
if (typeof window !== "undefined") {
|
|
124
|
-
const theme = useThemeMode();
|
|
125
|
-
theme.value = { value: body.theme };
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
export const changeLocale = async (body) => {
|
|
129
|
-
const user = useUser();
|
|
130
|
-
if (user.value) {
|
|
131
|
-
await fetch("/account/1/change/locale", { body, method: "POST" });
|
|
132
|
-
updateUser(body);
|
|
133
|
-
}
|
|
134
|
-
if (typeof window !== "undefined") {
|
|
135
|
-
const localeCookie = useCookie("locale", { maxAge: 60 * 60 * 24 * 365 });
|
|
136
|
-
localeCookie.value = body.locale;
|
|
137
|
-
const locale = useAppLocale();
|
|
138
|
-
locale.value = { value: body.locale };
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
117
|
export const changeAvatar = async (body) => {
|
|
142
118
|
const { avatar } = await fetch("/account/1/upload/avatar", { body, method: "POST" });
|
|
143
119
|
updateUser({ avatar });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Ref } from "vue";
|
|
2
2
|
import type { Fetch, FetchConfig } from "./types";
|
|
3
|
+
export { defineVuePlugins } from "./define-vue-plugins";
|
|
3
4
|
export { default as AppProvider } from "./AppProvider.vue";
|
|
4
5
|
export * from "./composables";
|
|
5
6
|
export * from "./types";
|
|
@@ -19,6 +20,12 @@ export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
|
|
|
19
20
|
fetchActiveSessions: () => Promise<{
|
|
20
21
|
sessions: import("./types").ActiveSession[];
|
|
21
22
|
}>;
|
|
23
|
+
changeTheme: (body: {
|
|
24
|
+
theme: "light" | "dark";
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
changeLocale: (body: {
|
|
27
|
+
locale: string;
|
|
28
|
+
}) => Promise<void>;
|
|
22
29
|
};
|
|
23
30
|
};
|
|
24
31
|
export declare const useUserActions: () => Ref<{
|
|
@@ -33,6 +40,12 @@ export declare const useUserActions: () => Ref<{
|
|
|
33
40
|
fetchActiveSessions: () => Promise<{
|
|
34
41
|
sessions: import("./types").ActiveSession[];
|
|
35
42
|
}>;
|
|
43
|
+
changeTheme: (body: {
|
|
44
|
+
theme: "light" | "dark";
|
|
45
|
+
}) => Promise<void>;
|
|
46
|
+
changeLocale: (body: {
|
|
47
|
+
locale: string;
|
|
48
|
+
}) => Promise<void>;
|
|
36
49
|
}, {
|
|
37
50
|
signIn: (body: {
|
|
38
51
|
username: string;
|
|
@@ -45,4 +58,10 @@ export declare const useUserActions: () => Ref<{
|
|
|
45
58
|
fetchActiveSessions: () => Promise<{
|
|
46
59
|
sessions: import("./types").ActiveSession[];
|
|
47
60
|
}>;
|
|
61
|
+
changeTheme: (body: {
|
|
62
|
+
theme: "light" | "dark";
|
|
63
|
+
}) => Promise<void>;
|
|
64
|
+
changeLocale: (body: {
|
|
65
|
+
locale: string;
|
|
66
|
+
}) => Promise<void>;
|
|
48
67
|
}> | undefined;
|
|
@@ -9,6 +9,7 @@ import { createApiGetVisitorIdentifier } from "./get-visitor.mjs";
|
|
|
9
9
|
import { createInitApplication } from "./init-application.mjs";
|
|
10
10
|
import { createApiRefreshToken } from "./refresh-token.mjs";
|
|
11
11
|
import { createApiUserActions } from "./user-actions.mjs";
|
|
12
|
+
export { defineVuePlugins } from "./define-vue-plugins.mjs";
|
|
12
13
|
export { default as AppProvider } from "./AppProvider.vue";
|
|
13
14
|
export * from "./composables/index.mjs";
|
|
14
15
|
export * from "./types.mjs";
|
|
@@ -14,6 +14,7 @@ function initApplication() {
|
|
|
14
14
|
const theme = useThemeMode();
|
|
15
15
|
const locale = useAppLocale();
|
|
16
16
|
const i18n = useI18n();
|
|
17
|
+
const userActions = useUserActions();
|
|
17
18
|
watch(user, (user2) => {
|
|
18
19
|
if (user2 && user2.theme !== theme.value?.value) {
|
|
19
20
|
theme.value = { value: user2.theme };
|
|
@@ -34,6 +35,7 @@ function initApplication() {
|
|
|
34
35
|
document.documentElement.classList.add("light", "van-theme-light");
|
|
35
36
|
StyleProvider(null);
|
|
36
37
|
}
|
|
38
|
+
userActions?.value.changeTheme({ theme: theme2?.value });
|
|
37
39
|
},
|
|
38
40
|
{ immediate: true }
|
|
39
41
|
);
|
|
@@ -51,6 +53,7 @@ function initApplication() {
|
|
|
51
53
|
VantLocale.use(locale2, ruRU);
|
|
52
54
|
VarletLocale.add("en-US", VarletLocale.enUS);
|
|
53
55
|
}
|
|
56
|
+
userActions?.value.changeLocale({ locale: locale2?.value });
|
|
54
57
|
},
|
|
55
58
|
{ immediate: true }
|
|
56
59
|
);
|
|
@@ -73,7 +76,6 @@ function initApplication() {
|
|
|
73
76
|
}
|
|
74
77
|
const visitor = useVisitor();
|
|
75
78
|
if (session?.status === "SignedOut" && session?.visitorId === visitor.value?.id) {
|
|
76
|
-
const userActions = useUserActions();
|
|
77
79
|
const data = await userActions?.value.fetchActiveSessions();
|
|
78
80
|
const isCurrentSession = data?.sessions.some((s) => s.isCurrentSession && s.id === session?.sessionId);
|
|
79
81
|
if (isCurrentSession) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./varlet-ui";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./varlet-ui.mjs";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { createApp } from "vue";
|
|
1
2
|
import "@varlet/ui/es/button/style/index";
|
|
2
3
|
import "@varlet/ui/es/chip/style/index";
|
|
3
4
|
import "@varlet/ui/es/icon/style/index";
|
|
4
5
|
import "@varlet/ui/es/link/style/index";
|
|
5
6
|
import "@varlet/ui/es/styles/elevation.css";
|
|
6
|
-
|
|
7
|
-
export
|
|
7
|
+
type App = ReturnType<typeof createApp>;
|
|
8
|
+
export declare function defineVarletPlugin(app: App): void;
|
|
9
|
+
export {};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Button, Chip, Icon, Link } from "@varlet/ui";
|
|
2
|
-
import { defineNuxtPlugin } from "#app";
|
|
3
2
|
import "@varlet/ui/es/button/style/index";
|
|
4
3
|
import "@varlet/ui/es/chip/style/index";
|
|
5
4
|
import "@varlet/ui/es/icon/style/index";
|
|
6
5
|
import "@varlet/ui/es/link/style/index";
|
|
7
6
|
import "@varlet/ui/es/styles/elevation.css";
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
7
|
+
export function defineVarletPlugin(app) {
|
|
8
|
+
app.use(Button);
|
|
9
|
+
app.use(Chip);
|
|
10
|
+
app.use(Icon);
|
|
11
|
+
app.use(Link);
|
|
12
|
+
}
|
|
@@ -12,4 +12,10 @@ export declare const createApiUserActions: (fetch: Fetch, config: FetchConfig, g
|
|
|
12
12
|
fetchActiveSessions: () => Promise<{
|
|
13
13
|
sessions: ActiveSession[];
|
|
14
14
|
}>;
|
|
15
|
+
changeTheme: (body: {
|
|
16
|
+
theme: "light" | "dark";
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
changeLocale: (body: {
|
|
19
|
+
locale: string;
|
|
20
|
+
}) => Promise<void>;
|
|
15
21
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flush, setToken } from "./api-client.mjs";
|
|
1
|
+
import { flush, setToken, updateUser } from "./api-client.mjs";
|
|
2
2
|
import { useUser } from "./composables/index.mjs";
|
|
3
3
|
import { once } from "./helpers/index.mjs";
|
|
4
4
|
export const createApiUserActions = once(
|
|
@@ -32,6 +32,20 @@ export const createApiUserActions = once(
|
|
|
32
32
|
},
|
|
33
33
|
fetchActiveSessions: async () => {
|
|
34
34
|
return await fetch("/account/1/sessions");
|
|
35
|
+
},
|
|
36
|
+
changeTheme: async (body) => {
|
|
37
|
+
const user = useUser();
|
|
38
|
+
if (user.value) {
|
|
39
|
+
await fetch("/account/1/change/theme", { body, method: "POST" });
|
|
40
|
+
updateUser(body);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
changeLocale: async (body) => {
|
|
44
|
+
const user = useUser();
|
|
45
|
+
if (user.value) {
|
|
46
|
+
await fetch("/account/1/change/locale", { body, method: "POST" });
|
|
47
|
+
updateUser(body);
|
|
48
|
+
}
|
|
35
49
|
}
|
|
36
50
|
};
|
|
37
51
|
}
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { addRouteMiddleware, defineNuxtPlugin } from "#app";
|
|
2
|
-
import { useNuxtApp, useRequestHeaders, useRuntimeConfig, useState } from "#imports";
|
|
2
|
+
import { useCookie, useNuxtApp, useRequestHeaders, useRuntimeConfig, useState } from "#imports";
|
|
3
3
|
import { watch } from "vue";
|
|
4
4
|
import { fetch, getUser } from "./api/index.mjs";
|
|
5
5
|
import { authMiddleware, guestMiddleware, localeMiddleware } from "./middleware/index.mjs";
|
|
6
|
-
import { useThemeMode } from "./packages/core/index.mjs";
|
|
6
|
+
import { defineVuePlugins, useAppLocale, useThemeMode } from "./packages/core/index.mjs";
|
|
7
7
|
import { flush, setToken, setUser } from "./packages/core/api-client.mjs";
|
|
8
8
|
const useAuth = () => {
|
|
9
9
|
return useState("auth", () => null);
|
|
10
10
|
};
|
|
11
11
|
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
12
|
+
defineVuePlugins(nuxtApp.vueApp);
|
|
12
13
|
const auth = useAuth();
|
|
13
14
|
const runtimeConfig = useRuntimeConfig();
|
|
14
15
|
const { $mobileApp } = useNuxtApp();
|
|
15
16
|
const theme = useThemeMode();
|
|
17
|
+
const locale = useAppLocale();
|
|
16
18
|
if (runtimeConfig.public.ssr && import.meta.server || !runtimeConfig.public.ssr) {
|
|
17
19
|
flush();
|
|
18
20
|
if (import.meta.server) {
|
|
@@ -39,6 +41,14 @@ export default defineNuxtPlugin(async (nuxtApp) => {
|
|
|
39
41
|
},
|
|
40
42
|
{ immediate: true }
|
|
41
43
|
);
|
|
44
|
+
watch(
|
|
45
|
+
locale,
|
|
46
|
+
(locale2) => {
|
|
47
|
+
const localeCookie = useCookie("locale", { maxAge: 60 * 60 * 24 * 365 });
|
|
48
|
+
localeCookie.value = locale2?.value;
|
|
49
|
+
},
|
|
50
|
+
{ immediate: true }
|
|
51
|
+
);
|
|
42
52
|
});
|
|
43
53
|
addRouteMiddleware("auth", authMiddleware, { global: false });
|
|
44
54
|
addRouteMiddleware("guest", guestMiddleware, { global: false });
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { once } from "../packages/core/helpers";
|
|
2
|
-
export declare const useHelpers: () => {
|
|
3
|
-
dateHelper: {
|
|
4
|
-
stringToDate: typeof import("src/runtime/packages/core/helpers/date-helper").stringToDate;
|
|
5
|
-
dateFormat: typeof import("src/runtime/packages/core/helpers/date-helper").dateFormat;
|
|
6
|
-
};
|
|
7
|
-
once: typeof once;
|
|
8
|
-
phoneHelper: {
|
|
9
|
-
getPlainPhoneNumber: typeof import("src/runtime/packages/core/helpers/phone-helper").getPlainPhoneNumber;
|
|
10
|
-
convertToPhone: typeof import("src/runtime/packages/core/helpers/phone-helper").convertToPhone;
|
|
11
|
-
maskPhone: typeof import("src/runtime/packages/core/helpers/phone-helper").maskPhone;
|
|
12
|
-
};
|
|
13
|
-
stringHelper: {
|
|
14
|
-
maskEmail: typeof import("src/runtime/packages/core/helpers/string-helper").maskEmail;
|
|
15
|
-
};
|
|
16
|
-
};
|