@anweb/nuxt-ancore 1.4.3 → 1.4.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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "AnCore",
3
3
  "configKey": "ancore",
4
- "version": "1.4.3",
4
+ "version": "1.4.5",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.1",
7
7
  "unbuild": "3.5.0"
@@ -4,27 +4,22 @@ import { userApi } from "../utils/index.js";
4
4
  export const useAnData = (config) => {
5
5
  const request = ref(config.request);
6
6
  const loading = computed(() => {
7
- return status.value === "pending";
7
+ return AData.status.value === "pending";
8
8
  });
9
9
  const key = computed(() => {
10
10
  return request.value.toString();
11
11
  });
12
- const {
13
- data,
14
- error,
15
- execute,
16
- status
17
- } = useAsyncData(
12
+ const AData = useAsyncData(
18
13
  key,
19
14
  () => userApi(request.value, { method: "GET" }),
20
15
  { immediate: false }
21
16
  );
22
17
  return {
23
- init: execute,
18
+ init: AData.execute,
24
19
  loading,
25
20
  request,
26
- data,
27
- error,
28
- status
21
+ data: AData.data,
22
+ error: AData.error,
23
+ status: AData.status
29
24
  };
30
25
  };
@@ -14,12 +14,12 @@ export default (config) => {
14
14
  } else if (config.filter) {
15
15
  filter.value = { ...config.filter };
16
16
  }
17
- await execute();
17
+ await AData.execute();
18
18
  refresh();
19
19
  if (config.events) {
20
20
  for (const event of config.events) {
21
- event.bus.on((data2) => {
22
- const newCount = event.callback(items, count.value || 0, data2);
21
+ event.bus.on((data) => {
22
+ const newCount = event.callback(items, count.value || 0, data);
23
23
  if (newCount || newCount === 0) {
24
24
  count.value = newCount;
25
25
  }
@@ -27,10 +27,10 @@ export default (config) => {
27
27
  }
28
28
  }
29
29
  if (config.ws) {
30
- busWS.on((data2) => {
31
- const event = config.ws?.find((item) => item.type === data2.type);
30
+ busWS.on((data) => {
31
+ const event = config.ws?.find((item) => item.type === data.type);
32
32
  if (event) {
33
- const newCount = event.callback(items, count.value || 0, data2.data);
33
+ const newCount = event.callback(items, count.value || 0, data.data);
34
34
  if (newCount || newCount === 0) {
35
35
  count.value = newCount;
36
36
  }
@@ -40,35 +40,30 @@ export default (config) => {
40
40
  inited.value = true;
41
41
  };
42
42
  const refresh = () => {
43
- if (!data.value) return;
43
+ if (!AData.data.value) return;
44
44
  if (!filter.value.skip) {
45
45
  count.value = null;
46
46
  items.length = 0;
47
47
  }
48
48
  if (config.reverse) {
49
- items.unshift(...data.value.items);
49
+ items.unshift(...AData.data.value.items);
50
50
  } else {
51
- items.push(...data.value.items);
51
+ items.push(...AData.data.value.items);
52
52
  }
53
- count.value = data.value.count;
53
+ count.value = AData.data.value.count;
54
54
  };
55
55
  const key = computed(() => {
56
56
  return config.request + "?" + toQuery(filter.value);
57
57
  });
58
58
  const loading = computed(() => {
59
- return status.value === "pending";
59
+ return AData.status.value === "pending";
60
60
  });
61
- const {
62
- data,
63
- error,
64
- execute,
65
- status
66
- } = useAsyncData(
61
+ const AData = useAsyncData(
67
62
  key,
68
63
  () => userApi(config.request, { method: "GET", query: filter.value }),
69
64
  { immediate: false }
70
65
  );
71
- watch(data, refresh);
66
+ watch(AData, refresh);
72
67
  return {
73
68
  init,
74
69
  inited,
@@ -76,7 +71,7 @@ export default (config) => {
76
71
  loading,
77
72
  items,
78
73
  count,
79
- error,
80
- status
74
+ error: AData.error,
75
+ status: AData.status
81
76
  };
82
77
  };
@@ -1,4 +1 @@
1
- type TValue = string | number | boolean | undefined | null;
2
- export type TQueryObject = Record<string, TValue | TValue[]>;
3
- export declare const toQuery: (params: TQueryObject) => string;
4
- export {};
1
+ export declare const toQuery: <T extends object>(params: T) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anweb/nuxt-ancore",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "description": "AnCore Nuxt module",
5
5
  "repository": "https://github.com/ANLTD/ancore",
6
6
  "license": "MIT",