@inzombieland/core 1.20.3 → 1.20.5
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/composables/use-app-locale.js +2 -1
- package/composables/use-theme-mode.js +2 -1
- package/index.d.ts +6 -15
- package/local-storage-utils.js +5 -4
- package/package.json +1 -1
- package/user-actions.d.ts +2 -5
- package/user-actions.js +6 -17
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useLocalStorage } from "@vueuse/core";
|
|
2
2
|
export const useAppLocale = () => {
|
|
3
|
+
const namespace = import.meta.env.VITE_APP_NAMESPACE ?? "app";
|
|
3
4
|
let value = "en";
|
|
4
5
|
if (typeof window !== "undefined" && window.navigator.language) {
|
|
5
6
|
value = window.navigator.language.split("-")[0] ?? "en";
|
|
6
7
|
}
|
|
7
8
|
return useLocalStorage(
|
|
8
|
-
|
|
9
|
+
`${namespace}-preferences-locale`,
|
|
9
10
|
{ value },
|
|
10
11
|
{
|
|
11
12
|
serializer: {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { useLocalStorage, usePreferredDark } from "@vueuse/core";
|
|
2
2
|
export const useThemeMode = () => {
|
|
3
|
+
const namespace = import.meta.env.VITE_APP_NAMESPACE ?? "app";
|
|
3
4
|
const isDark = usePreferredDark();
|
|
4
5
|
return useLocalStorage(
|
|
5
|
-
|
|
6
|
+
`${namespace}-preferences-theme`,
|
|
6
7
|
{ value: isDark.value ? "dark" : "light" },
|
|
7
8
|
{
|
|
8
9
|
serializer: {
|
package/index.d.ts
CHANGED
|
@@ -9,13 +9,10 @@ export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
|
|
|
9
9
|
getUser: () => Promise<import("./types.js").GetUserResponse>;
|
|
10
10
|
useApiFetch: () => Fetch;
|
|
11
11
|
userActions: {
|
|
12
|
-
signIn: (body: Record<string, any>) => Promise<
|
|
12
|
+
signIn: (body: Record<string, any>) => Promise<{
|
|
13
13
|
key: string;
|
|
14
14
|
}>;
|
|
15
|
-
|
|
16
|
-
key: string;
|
|
17
|
-
}>;
|
|
18
|
-
signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
15
|
+
signInVerifyCode: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
19
16
|
getToken: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
20
17
|
signUp: (body: Record<string, any>) => Promise<{
|
|
21
18
|
key: string;
|
|
@@ -108,13 +105,10 @@ export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
|
|
|
108
105
|
};
|
|
109
106
|
};
|
|
110
107
|
export declare const useUserActions: () => Ref<{
|
|
111
|
-
signIn: (body: Record<string, any>) => Promise<
|
|
112
|
-
key: string;
|
|
113
|
-
}>;
|
|
114
|
-
signInByCodeSendCode: (body: Record<string, any>) => Promise<{
|
|
108
|
+
signIn: (body: Record<string, any>) => Promise<{
|
|
115
109
|
key: string;
|
|
116
110
|
}>;
|
|
117
|
-
|
|
111
|
+
signInVerifyCode: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
118
112
|
getToken: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
119
113
|
signUp: (body: Record<string, any>) => Promise<{
|
|
120
114
|
key: string;
|
|
@@ -205,13 +199,10 @@ export declare const useUserActions: () => Ref<{
|
|
|
205
199
|
code: string;
|
|
206
200
|
}) => Promise<void>;
|
|
207
201
|
}, {
|
|
208
|
-
signIn: (body: Record<string, any>) => Promise<
|
|
209
|
-
key: string;
|
|
210
|
-
}>;
|
|
211
|
-
signInByCodeSendCode: (body: Record<string, any>) => Promise<{
|
|
202
|
+
signIn: (body: Record<string, any>) => Promise<{
|
|
212
203
|
key: string;
|
|
213
204
|
}>;
|
|
214
|
-
|
|
205
|
+
signInVerifyCode: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
215
206
|
getToken: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
216
207
|
signUp: (body: Record<string, any>) => Promise<{
|
|
217
208
|
key: string;
|
package/local-storage-utils.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
+
const namespace = import.meta.env.VITE_APP_NAMESPACE ?? "app";
|
|
1
2
|
export const getSessionId = () => {
|
|
2
3
|
if (typeof window !== "undefined") {
|
|
3
|
-
return window.localStorage.getItem(
|
|
4
|
+
return window.localStorage.getItem(`${namespace}-sid`);
|
|
4
5
|
}
|
|
5
6
|
return null;
|
|
6
7
|
};
|
|
7
8
|
export const setSessionId = (sessionId = "") => {
|
|
8
9
|
if (typeof window !== "undefined") {
|
|
9
|
-
window.localStorage.setItem(
|
|
10
|
+
window.localStorage.setItem(`${namespace}-sid`, sessionId);
|
|
10
11
|
}
|
|
11
12
|
};
|
|
12
13
|
export const getVisitorId = () => {
|
|
13
14
|
if (typeof window !== "undefined") {
|
|
14
|
-
return window.localStorage.getItem(
|
|
15
|
+
return window.localStorage.getItem(`${namespace}-vid`);
|
|
15
16
|
}
|
|
16
17
|
return null;
|
|
17
18
|
};
|
|
18
19
|
export const setVisitorId = (visitorId = "") => {
|
|
19
20
|
if (typeof window !== "undefined") {
|
|
20
|
-
window.localStorage.setItem(
|
|
21
|
+
window.localStorage.setItem(`${namespace}-vid`, visitorId);
|
|
21
22
|
}
|
|
22
23
|
};
|
package/package.json
CHANGED
package/user-actions.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import type { ActiveSession, Fetch, FetchConfig, GetUserResponse } from "./types.js";
|
|
2
2
|
export type UserActions = ReturnType<typeof createApiUserActions>;
|
|
3
3
|
export declare const createApiUserActions: (fetch: Fetch, config: FetchConfig, getUser: () => Promise<GetUserResponse>) => {
|
|
4
|
-
signIn: (body: Record<string, any>) => Promise<
|
|
4
|
+
signIn: (body: Record<string, any>) => Promise<{
|
|
5
5
|
key: string;
|
|
6
6
|
}>;
|
|
7
|
-
|
|
8
|
-
key: string;
|
|
9
|
-
}>;
|
|
10
|
-
signInByCodeVerifyCode: (body: Record<string, any>) => Promise<GetUserResponse>;
|
|
7
|
+
signInVerifyCode: (body: Record<string, any>) => Promise<GetUserResponse>;
|
|
11
8
|
getToken: (body: Record<string, any>) => Promise<GetUserResponse>;
|
|
12
9
|
signUp: (body: Record<string, any>) => Promise<{
|
|
13
10
|
key: string;
|
package/user-actions.js
CHANGED
|
@@ -11,31 +11,20 @@ export const createApiUserActions = once(
|
|
|
11
11
|
method: "POST",
|
|
12
12
|
...config.useRequestHeaders?.(["cookie"]) ?? {}
|
|
13
13
|
});
|
|
14
|
-
const {
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
return { key };
|
|
18
|
-
}
|
|
19
|
-
throw rest;
|
|
14
|
+
const { key, ...rest } = response;
|
|
15
|
+
if (key) {
|
|
16
|
+
return { key };
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
return await getUser();
|
|
23
|
-
},
|
|
24
|
-
signInByCodeSendCode: async (body) => {
|
|
25
|
-
return await fetch("/account/0/signinbycode/sendcode", {
|
|
26
|
-
body,
|
|
27
|
-
method: "POST",
|
|
28
|
-
...config.useRequestHeaders?.(["cookie"]) ?? {}
|
|
29
|
-
});
|
|
18
|
+
throw rest;
|
|
30
19
|
},
|
|
31
|
-
|
|
20
|
+
signInVerifyCode: async (body) => {
|
|
32
21
|
const response = await fetch("/account/0/signinbycode/verifycode", {
|
|
33
22
|
body,
|
|
34
23
|
method: "POST",
|
|
35
24
|
...config.useRequestHeaders?.(["cookie"]) ?? {}
|
|
36
25
|
});
|
|
37
26
|
const { accessToken, sessionId, visitorId, secretKey, ...rest } = response;
|
|
38
|
-
if (!accessToken || !sessionId) {
|
|
27
|
+
if (!accessToken || !sessionId || !visitorId || !secretKey) {
|
|
39
28
|
throw rest;
|
|
40
29
|
}
|
|
41
30
|
setToken(accessToken);
|