@anweb/nuxt-ancore 1.12.1 → 1.13.0
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
|
@@ -7,12 +7,13 @@ export const useAnData = (initConfig) => {
|
|
|
7
7
|
const error = ref(void 0);
|
|
8
8
|
const status = ref("idle");
|
|
9
9
|
const isMounted = ref(false);
|
|
10
|
+
const time = ref(Date.now());
|
|
10
11
|
const init = async () => {
|
|
11
12
|
if (isMounted.value) {
|
|
12
13
|
const execute = () => {
|
|
13
14
|
status.value = "pending";
|
|
14
15
|
userApi(
|
|
15
|
-
|
|
16
|
+
path.value.url,
|
|
16
17
|
{ method: "GET", ...config.value.apiConfig || {} }
|
|
17
18
|
).then((response) => {
|
|
18
19
|
status.value = "success";
|
|
@@ -27,7 +28,7 @@ export const useAnData = (initConfig) => {
|
|
|
27
28
|
const Data = useAsyncData(
|
|
28
29
|
key,
|
|
29
30
|
() => userApi(
|
|
30
|
-
|
|
31
|
+
path.value.url,
|
|
31
32
|
{ method: "GET", ...config.value.apiConfig || {} }
|
|
32
33
|
),
|
|
33
34
|
{ immediate: false }
|
|
@@ -41,7 +42,7 @@ export const useAnData = (initConfig) => {
|
|
|
41
42
|
const set = (value) => {
|
|
42
43
|
data.value = value;
|
|
43
44
|
};
|
|
44
|
-
const
|
|
45
|
+
const path = computed(() => {
|
|
45
46
|
let url = config.value.request.toString();
|
|
46
47
|
for (const key2 in config.value.params) {
|
|
47
48
|
url = url.replace(`:${key2}`, encodeURIComponent(String(config.value.params[key2])));
|
|
@@ -50,8 +51,12 @@ export const useAnData = (initConfig) => {
|
|
|
50
51
|
if (config.value.apiConfig?.query) {
|
|
51
52
|
query = "?" + toQuery(config.value.apiConfig.query);
|
|
52
53
|
}
|
|
53
|
-
return
|
|
54
|
+
return {
|
|
55
|
+
url: url + query,
|
|
56
|
+
key: url + query + (query ? "&" : "?") + "time=" + time.value
|
|
57
|
+
};
|
|
54
58
|
});
|
|
59
|
+
const key = computed(() => path.value.key);
|
|
55
60
|
const loading = computed(() => status.value === "pending");
|
|
56
61
|
onMounted(() => {
|
|
57
62
|
isMounted.value = true;
|
|
@@ -59,6 +64,7 @@ export const useAnData = (initConfig) => {
|
|
|
59
64
|
return {
|
|
60
65
|
init,
|
|
61
66
|
set,
|
|
67
|
+
refresh: () => time.value = Date.now(),
|
|
62
68
|
data,
|
|
63
69
|
config,
|
|
64
70
|
status,
|
|
@@ -10,7 +10,7 @@ interface TConfig<TFilter> {
|
|
|
10
10
|
}
|
|
11
11
|
export declare const useAnList: <TData, TFilter extends object = {}>(initConfig: TConfig<TFilter>) => {
|
|
12
12
|
init: () => Promise<void>;
|
|
13
|
-
infiniteScroll: (scrollConfig?: TInfiniteScroll) => void;
|
|
13
|
+
infiniteScroll: (scrollConfig?: TInfiniteScroll) => () => void;
|
|
14
14
|
filter: TFilter;
|
|
15
15
|
params: Record<string, unknown> | undefined;
|
|
16
16
|
items: TData[];
|