@inzombieland/core 1.18.7 → 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/index.d.ts +18 -0
- package/init-application.mjs +3 -1
- package/package.json +1 -1
- package/user-actions.d.ts +6 -0
- package/user-actions.mjs +15 -1
package/index.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
|
|
|
20
20
|
fetchActiveSessions: () => Promise<{
|
|
21
21
|
sessions: import("./types").ActiveSession[];
|
|
22
22
|
}>;
|
|
23
|
+
changeTheme: (body: {
|
|
24
|
+
theme: "light" | "dark";
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
changeLocale: (body: {
|
|
27
|
+
locale: string;
|
|
28
|
+
}) => Promise<void>;
|
|
23
29
|
};
|
|
24
30
|
};
|
|
25
31
|
export declare const useUserActions: () => Ref<{
|
|
@@ -34,6 +40,12 @@ export declare const useUserActions: () => Ref<{
|
|
|
34
40
|
fetchActiveSessions: () => Promise<{
|
|
35
41
|
sessions: import("./types").ActiveSession[];
|
|
36
42
|
}>;
|
|
43
|
+
changeTheme: (body: {
|
|
44
|
+
theme: "light" | "dark";
|
|
45
|
+
}) => Promise<void>;
|
|
46
|
+
changeLocale: (body: {
|
|
47
|
+
locale: string;
|
|
48
|
+
}) => Promise<void>;
|
|
37
49
|
}, {
|
|
38
50
|
signIn: (body: {
|
|
39
51
|
username: string;
|
|
@@ -46,4 +58,10 @@ export declare const useUserActions: () => Ref<{
|
|
|
46
58
|
fetchActiveSessions: () => Promise<{
|
|
47
59
|
sessions: import("./types").ActiveSession[];
|
|
48
60
|
}>;
|
|
61
|
+
changeTheme: (body: {
|
|
62
|
+
theme: "light" | "dark";
|
|
63
|
+
}) => Promise<void>;
|
|
64
|
+
changeLocale: (body: {
|
|
65
|
+
locale: string;
|
|
66
|
+
}) => Promise<void>;
|
|
49
67
|
}> | undefined;
|
package/init-application.mjs
CHANGED
|
@@ -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) {
|
package/package.json
CHANGED
package/user-actions.d.ts
CHANGED
|
@@ -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
|
};
|
package/user-actions.mjs
CHANGED
|
@@ -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
|
}
|