@anweb/nuxt-ancore 1.16.13 → 1.16.15
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/runtime/composables/useAnI18n.d.ts +2 -2
- package/dist/runtime/composables/useAnI18n.js +8 -14
- package/dist/runtime/composables/useAnList.js +1 -0
- package/dist/runtime/utils/fnv1a.d.ts +1 -0
- package/dist/runtime/utils/fnv1a.js +8 -0
- package/dist/runtime/utils/index.d.ts +1 -0
- package/dist/runtime/utils/index.js +1 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const useAnI18n: (resources?: Record<string, Record<string, string>>) => {
|
|
2
2
|
t: (key: string, options?: {}) => string;
|
|
3
|
-
|
|
3
|
+
lang: import("vue").ComputedRef<string>;
|
|
4
4
|
set: (value: string) => void;
|
|
5
5
|
} | {
|
|
6
6
|
t: import("i18next").TFunction<["translation", ...string[]], undefined>;
|
|
7
|
-
|
|
7
|
+
lang: import("vue").ComputedRef<string>;
|
|
8
8
|
set: (value: string) => void;
|
|
9
9
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import i18next from "i18next";
|
|
2
|
-
import { ref } from "vue";
|
|
2
|
+
import { ref, computed } from "vue";
|
|
3
3
|
import { useRuntimeConfig, useCookie } from "#app";
|
|
4
|
-
|
|
5
|
-
let nsId = 0;
|
|
4
|
+
import { fnv1a } from "#imports";
|
|
6
5
|
const lang = ref(i18next.language);
|
|
7
6
|
export const useAnI18n = (resources) => {
|
|
8
7
|
const set = (value) => {
|
|
@@ -23,12 +22,11 @@ export const useAnI18n = (resources) => {
|
|
|
23
22
|
console.error("[AnI18n] Failed to set language:", e);
|
|
24
23
|
}
|
|
25
24
|
};
|
|
25
|
+
const langReadonly = computed(() => lang.value);
|
|
26
26
|
if (resources) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
ns
|
|
30
|
-
nsMap.set(resources, ns);
|
|
31
|
-
for (const l in resources) {
|
|
27
|
+
const ns = `c${fnv1a(JSON.stringify(resources))}`;
|
|
28
|
+
for (const l in resources) {
|
|
29
|
+
if (!i18next.hasResourceBundle(l, ns)) {
|
|
32
30
|
try {
|
|
33
31
|
i18next.addResourceBundle(l, ns, resources[l]);
|
|
34
32
|
} catch (e) {
|
|
@@ -39,17 +37,13 @@ export const useAnI18n = (resources) => {
|
|
|
39
37
|
const nsRef = ns;
|
|
40
38
|
return {
|
|
41
39
|
t: (key, options = {}) => i18next.t(key, { ns: [nsRef, "translation"], ...options }),
|
|
42
|
-
|
|
43
|
-
return lang.value;
|
|
44
|
-
},
|
|
40
|
+
lang: langReadonly,
|
|
45
41
|
set
|
|
46
42
|
};
|
|
47
43
|
}
|
|
48
44
|
return {
|
|
49
45
|
t: i18next.t,
|
|
50
|
-
|
|
51
|
-
return lang.value;
|
|
52
|
-
},
|
|
46
|
+
lang: langReadonly,
|
|
53
47
|
set
|
|
54
48
|
};
|
|
55
49
|
};
|
|
@@ -24,6 +24,7 @@ export const useAnList = (initConfig) => {
|
|
|
24
24
|
};
|
|
25
25
|
const infiniteScroll = (scrollConfig) => {
|
|
26
26
|
const onLoadMore = scrollConfig?.onLoadMore || (() => {
|
|
27
|
+
if (!scrollConfig?.element && document.body.style.position === "fixed") return;
|
|
27
28
|
if (!config.value.filter) config.value.filter = {};
|
|
28
29
|
config.value.filter[config.value.skipField || "skip"] = items.length;
|
|
29
30
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const fnv1a: (str: string) => number;
|