@anweb/nuxt-ancore 1.16.14 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "AnCore",
3
3
  "configKey": "ancore",
4
- "version": "1.16.14",
4
+ "version": "1.16.15",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,8 +1,7 @@
1
1
  import i18next from "i18next";
2
2
  import { ref, computed } from "vue";
3
3
  import { useRuntimeConfig, useCookie } from "#app";
4
- const nsMap = /* @__PURE__ */ new WeakMap();
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) => {
@@ -25,11 +24,9 @@ export const useAnI18n = (resources) => {
25
24
  };
26
25
  const langReadonly = computed(() => lang.value);
27
26
  if (resources) {
28
- let ns = nsMap.get(resources);
29
- if (!ns) {
30
- ns = `c${nsId++}`;
31
- nsMap.set(resources, ns);
32
- 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)) {
33
30
  try {
34
31
  i18next.addResourceBundle(l, ns, resources[l]);
35
32
  } catch (e) {
@@ -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;
@@ -0,0 +1,8 @@
1
+ export const fnv1a = (str) => {
2
+ let h = 2166136261;
3
+ for (let i = 0; i < str.length; i++) {
4
+ h ^= str.charCodeAt(i);
5
+ h = Math.imul(h, 16777619);
6
+ }
7
+ return h >>> 0;
8
+ };
@@ -1,4 +1,5 @@
1
1
  export * from './asyncInit.js';
2
2
  export * from './coreApi.js';
3
+ export * from './fnv1a.js';
3
4
  export * from './toQuery.js';
4
5
  export * from './userApi.js';
@@ -1,4 +1,5 @@
1
1
  export * from "./asyncInit.js";
2
2
  export * from "./coreApi.js";
3
+ export * from "./fnv1a.js";
3
4
  export * from "./toQuery.js";
4
5
  export * from "./userApi.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anweb/nuxt-ancore",
3
- "version": "1.16.14",
3
+ "version": "1.16.15",
4
4
  "description": "AnCore Nuxt module",
5
5
  "repository": "https://github.com/ANLTD/ancore",
6
6
  "license": "MIT",