@peng_kai/kit 0.1.14 → 0.1.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/admin/components/filter/src/FilterDrawer.vue +153 -153
- package/admin/components/filter/src/FilterParam.vue +78 -78
- package/admin/components/scroll-nav/index.ts +1 -1
- package/admin/components/scroll-nav/src/ScrollNav.vue +59 -59
- package/admin/components/text/index.ts +13 -13
- package/admin/components/text/src/Amount.vue +121 -121
- package/admin/components/text/src/Datetime.vue +48 -48
- package/admin/components/text/src/Duration.vue +26 -26
- package/admin/components/text/src/Hash.vue +51 -51
- package/admin/components/text/src/createTagGetter.ts +13 -13
- package/admin/hooks/useMenu.ts +128 -128
- package/admin/hooks/usePage.ts +141 -141
- package/admin/hooks/usePageTab.ts +35 -35
- package/admin/layout/large/Breadcrumb.vue +69 -69
- package/admin/layout/large/Content.vue +24 -24
- package/admin/layout/large/Menu.vue +69 -69
- package/admin/layout/large/PageTab.vue +71 -71
- package/admin/permission/index.ts +4 -4
- package/admin/permission/routerGuard.ts +43 -43
- package/admin/permission/usePermission.ts +52 -52
- package/admin/permission/vuePlugin.ts +30 -30
- package/admin/route-guards/index.ts +3 -3
- package/admin/route-guards/pageProgress.ts +27 -27
- package/admin/route-guards/pageTitle.ts +19 -19
- package/admin/styles/globalCover.scss +54 -54
- package/antd/components/InputNumberRange.vue +59 -59
- package/antd/directives/formLabelAlign.ts +36 -36
- package/antd/hooks/useAntdDrawer.ts +73 -73
- package/antd/hooks/useAntdTable.ts +115 -115
- package/package.json +1 -1
- package/request/helpers.ts +49 -49
- package/request/interceptors/toLogin.ts +26 -26
- package/request/type.d.ts +92 -92
- package/stylelint.config.cjs +7 -7
- package/tsconfig.json +50 -50
- package/utils/index.ts +2 -0
- package/vue/components/infinite-query/index.ts +1 -1
- package/vue/components/infinite-query/src/InfiniteQuery.vue +205 -205
- package/vue/components/infinite-query/src/useCreateTrigger.ts +39 -39
package/tsconfig.json
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"jsx": "preserve",
|
|
5
|
-
"jsxFactory": "h",
|
|
6
|
-
"jsxFragmentFactory": "Fragment",
|
|
7
|
-
"lib": [
|
|
8
|
-
"ESNext",
|
|
9
|
-
"DOM",
|
|
10
|
-
"DOM.Iterable"
|
|
11
|
-
],
|
|
12
|
-
"useDefineForClassFields": true,
|
|
13
|
-
"module": "ESNext",
|
|
14
|
-
|
|
15
|
-
/* Bundler mode */
|
|
16
|
-
"moduleResolution": "bundler",
|
|
17
|
-
"resolveJsonModule": true,
|
|
18
|
-
"allowImportingTsExtensions": true,
|
|
19
|
-
|
|
20
|
-
/* Linting */
|
|
21
|
-
"strict": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true,
|
|
23
|
-
"noImplicitAny": false,
|
|
24
|
-
"noUnusedLocals": true,
|
|
25
|
-
"noUnusedParameters": true,
|
|
26
|
-
"noEmit": true,
|
|
27
|
-
"allowSyntheticDefaultImports": true,
|
|
28
|
-
"esModuleInterop": true,
|
|
29
|
-
"isolatedModules": true,
|
|
30
|
-
"skipLibCheck": true
|
|
31
|
-
},
|
|
32
|
-
"include": [
|
|
33
|
-
"admin/**/*.ts",
|
|
34
|
-
"admin/**/*.d.ts",
|
|
35
|
-
"admin/**/*.tsx",
|
|
36
|
-
"admin/**/*.vue",
|
|
37
|
-
"antd/**/*.ts",
|
|
38
|
-
"antd/**/*.d.ts",
|
|
39
|
-
"antd/**/*.tsx",
|
|
40
|
-
"antd/**/*.vue",
|
|
41
|
-
"request/**/*.ts",
|
|
42
|
-
"request/**/*.d.ts",
|
|
43
|
-
"utils/**/*.ts",
|
|
44
|
-
"utils/**/*.d.ts",
|
|
45
|
-
"vue/**/*.ts",
|
|
46
|
-
"vue/**/*.d.ts",
|
|
47
|
-
"vue/**/*.tsx",
|
|
48
|
-
"vue/**/*.vue"
|
|
49
|
-
]
|
|
50
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"jsx": "preserve",
|
|
5
|
+
"jsxFactory": "h",
|
|
6
|
+
"jsxFragmentFactory": "Fragment",
|
|
7
|
+
"lib": [
|
|
8
|
+
"ESNext",
|
|
9
|
+
"DOM",
|
|
10
|
+
"DOM.Iterable"
|
|
11
|
+
],
|
|
12
|
+
"useDefineForClassFields": true,
|
|
13
|
+
"module": "ESNext",
|
|
14
|
+
|
|
15
|
+
/* Bundler mode */
|
|
16
|
+
"moduleResolution": "bundler",
|
|
17
|
+
"resolveJsonModule": true,
|
|
18
|
+
"allowImportingTsExtensions": true,
|
|
19
|
+
|
|
20
|
+
/* Linting */
|
|
21
|
+
"strict": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noImplicitAny": false,
|
|
24
|
+
"noUnusedLocals": true,
|
|
25
|
+
"noUnusedParameters": true,
|
|
26
|
+
"noEmit": true,
|
|
27
|
+
"allowSyntheticDefaultImports": true,
|
|
28
|
+
"esModuleInterop": true,
|
|
29
|
+
"isolatedModules": true,
|
|
30
|
+
"skipLibCheck": true
|
|
31
|
+
},
|
|
32
|
+
"include": [
|
|
33
|
+
"admin/**/*.ts",
|
|
34
|
+
"admin/**/*.d.ts",
|
|
35
|
+
"admin/**/*.tsx",
|
|
36
|
+
"admin/**/*.vue",
|
|
37
|
+
"antd/**/*.ts",
|
|
38
|
+
"antd/**/*.d.ts",
|
|
39
|
+
"antd/**/*.tsx",
|
|
40
|
+
"antd/**/*.vue",
|
|
41
|
+
"request/**/*.ts",
|
|
42
|
+
"request/**/*.d.ts",
|
|
43
|
+
"utils/**/*.ts",
|
|
44
|
+
"utils/**/*.d.ts",
|
|
45
|
+
"vue/**/*.ts",
|
|
46
|
+
"vue/**/*.d.ts",
|
|
47
|
+
"vue/**/*.tsx",
|
|
48
|
+
"vue/**/*.vue"
|
|
49
|
+
]
|
|
50
|
+
}
|
package/utils/index.ts
CHANGED
|
@@ -101,6 +101,8 @@ export function getScanBrowser(chain: string, hash: string, type: 'transaction'
|
|
|
101
101
|
const _type = (<TypeMap>{ address: 'account', transaction: 'tx' })[type] ?? type;
|
|
102
102
|
return `https://solscan.io/${_type}/${hash}`;
|
|
103
103
|
},
|
|
104
|
+
'DOGE': () => `https://dogechain.info/${evmType()}/${hash}`,
|
|
105
|
+
'BTC': () => `https://mempool.space/${evmType()}/${hash}`,
|
|
104
106
|
}[_chain] ?? (() => '');
|
|
105
107
|
|
|
106
108
|
return urlFn();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as InfiniteQuery } from './src/InfiniteQuery.vue';
|
|
1
|
+
export { default as InfiniteQuery } from './src/InfiniteQuery.vue';
|
|
@@ -1,205 +1,205 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { computed, ref, unref } from 'vue';
|
|
3
|
-
import type { UseInfiniteQueryReturnType } from '@tanstack/vue-query';
|
|
4
|
-
import { useCreateTrigger } from './useCreateTrigger';
|
|
5
|
-
|
|
6
|
-
export type { ISlotProvide };
|
|
7
|
-
|
|
8
|
-
interface ISlotProvide {
|
|
9
|
-
isInitialLoading: boolean
|
|
10
|
-
isInitialLoadingError: boolean
|
|
11
|
-
isEmpty: boolean
|
|
12
|
-
isMoreLoading: boolean
|
|
13
|
-
isMoreLoadingError: boolean
|
|
14
|
-
isNoMore: boolean
|
|
15
|
-
refetch: () => void
|
|
16
|
-
}
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<script setup lang="ts" generic="T extends UseInfiniteQueryReturnType<any, any>">
|
|
20
|
-
type TPage = T extends UseInfiniteQueryReturnType<infer P, any> ? NonNullable<P> : any;
|
|
21
|
-
type TRecord = TPage extends { list: Array<infer I> } ? I : any;
|
|
22
|
-
|
|
23
|
-
const props = withDefaults(defineProps<{
|
|
24
|
-
queryier: T
|
|
25
|
-
distance?: string
|
|
26
|
-
}>(), {
|
|
27
|
-
distance: '50px',
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const { queryier } = props;
|
|
31
|
-
const pages = computed(() => queryier.data.value?.pages);
|
|
32
|
-
// TODO: 状态之间的互斥仍有问题
|
|
33
|
-
const isInitialLoading = computed(() => queryier.isInitialLoading.value);
|
|
34
|
-
const isInitialLoadingError = computed(() => queryier.isLoadingError.value && !isInitialLoading.value);
|
|
35
|
-
const isMoreLoading = computed(
|
|
36
|
-
() => (queryier.isFetchingNextPage.value || queryier.isFetching.value) && !isInitialLoading.value,
|
|
37
|
-
);
|
|
38
|
-
const isEmpty = computed(() => queryier.isSuccess.value && !pages.value?.[0].list?.length);
|
|
39
|
-
const isMoreLoadingError = computed(() => queryier.isRefetchError.value && !isMoreLoading.value);
|
|
40
|
-
const isNoMore = computed(
|
|
41
|
-
() =>
|
|
42
|
-
!queryier.hasNextPage?.value
|
|
43
|
-
&& !isInitialLoading.value
|
|
44
|
-
&& !isInitialLoadingError.value
|
|
45
|
-
&& !isMoreLoading.value
|
|
46
|
-
&& !isMoreLoadingError.value,
|
|
47
|
-
);
|
|
48
|
-
const $container = ref<HTMLElement>();
|
|
49
|
-
const containerCssVars = computed(() => {
|
|
50
|
-
const ctnEle = unref($container);
|
|
51
|
-
|
|
52
|
-
if (!ctnEle)
|
|
53
|
-
return {};
|
|
54
|
-
|
|
55
|
-
const rect = ctnEle.getBoundingClientRect();
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
'--ctn-height': `${rect.height}px`,
|
|
59
|
-
};
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
function refetchLastPage() {
|
|
63
|
-
queryier.refetch({
|
|
64
|
-
refetchPage(lastPage: any, _index, allPages: any[]) {
|
|
65
|
-
const lastIndex = allPages?.length - 1;
|
|
66
|
-
return lastPage?.pagination?.page === allPages?.[lastIndex]?.pagination?.page;
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function fetchNextPage() {
|
|
72
|
-
const { isFetching, isLoading, hasNextPage } = queryier;
|
|
73
|
-
|
|
74
|
-
if (isFetching.value || isLoading.value || !hasNextPage?.value)
|
|
75
|
-
return;
|
|
76
|
-
|
|
77
|
-
queryier.fetchNextPage();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function refetch() {
|
|
81
|
-
if (isNoMore.value)
|
|
82
|
-
refetchLastPage();
|
|
83
|
-
else if (isMoreLoadingError.value)
|
|
84
|
-
fetchNextPage();
|
|
85
|
-
else
|
|
86
|
-
queryier.refetch();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function triggerFetchNextPage() {
|
|
90
|
-
if (queryier.isError.value)
|
|
91
|
-
return;
|
|
92
|
-
|
|
93
|
-
fetchNextPage();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
useCreateTrigger($container, triggerFetchNextPage, props.distance);
|
|
97
|
-
|
|
98
|
-
const slotProvide = computed<ISlotProvide>(() => ({
|
|
99
|
-
isInitialLoading: isInitialLoading.value,
|
|
100
|
-
isInitialLoadingError: isInitialLoadingError.value,
|
|
101
|
-
isMoreLoading: isMoreLoading.value,
|
|
102
|
-
isMoreLoadingError: isMoreLoadingError.value,
|
|
103
|
-
isNoMore: isNoMore.value,
|
|
104
|
-
isEmpty: isEmpty.value,
|
|
105
|
-
refetch,
|
|
106
|
-
}));
|
|
107
|
-
</script>
|
|
108
|
-
|
|
109
|
-
<template>
|
|
110
|
-
<div ref="$container" class="infinite-query-wrapper" :style="containerCssVars">
|
|
111
|
-
<div class="list">
|
|
112
|
-
<template v-for="(page) of pages">
|
|
113
|
-
<template v-for="record of page.list">
|
|
114
|
-
<!-- eslint-disable-next-line vue/no-extra-parens -->
|
|
115
|
-
<slot name="default" :record="(record as TRecord)" />
|
|
116
|
-
</template>
|
|
117
|
-
</template>
|
|
118
|
-
</div>
|
|
119
|
-
|
|
120
|
-
<slot
|
|
121
|
-
name="status" v-bind="slotProvide"
|
|
122
|
-
>
|
|
123
|
-
<slot name="initialLoading">
|
|
124
|
-
<div v-if="isInitialLoading" class="initial-loading">
|
|
125
|
-
<i class="i-svg-spinners:180-ring-with-bg loading-icon" />
|
|
126
|
-
</div>
|
|
127
|
-
</slot>
|
|
128
|
-
|
|
129
|
-
<slot name="initialLoadingError">
|
|
130
|
-
<div v-if="isInitialLoadingError" class="initial-loading-error" @click="refetch()">
|
|
131
|
-
<span>加载失败,点击重试</span>
|
|
132
|
-
</div>
|
|
133
|
-
</slot>
|
|
134
|
-
|
|
135
|
-
<slot name="empty">
|
|
136
|
-
<div v-if="isEmpty" class="empty">
|
|
137
|
-
<span>暂无数据</span>
|
|
138
|
-
</div>
|
|
139
|
-
</slot>
|
|
140
|
-
|
|
141
|
-
<slot name="oreLoading">
|
|
142
|
-
<div v-if="isMoreLoading" class="more-loading">
|
|
143
|
-
<i class="i-svg-spinners:180-ring-with-bg loading-icon" />
|
|
144
|
-
<span class="ml-1 text">加载中...</span>
|
|
145
|
-
</div>
|
|
146
|
-
</slot>
|
|
147
|
-
|
|
148
|
-
<slot name="moreLoadingError">
|
|
149
|
-
<div v-if="isMoreLoadingError" class="more-loading-error" @click="refetch()">
|
|
150
|
-
<span class="text">加载失败,点击重试</span>
|
|
151
|
-
</div>
|
|
152
|
-
</slot>
|
|
153
|
-
|
|
154
|
-
<slot name="noMore">
|
|
155
|
-
<div v-if="isNoMore" class="no-more" @click="refetch()">
|
|
156
|
-
<span class="text">暂无更多</span>
|
|
157
|
-
</div>
|
|
158
|
-
</slot>
|
|
159
|
-
</slot>
|
|
160
|
-
</div>
|
|
161
|
-
</template>
|
|
162
|
-
|
|
163
|
-
<style scoped lang="scss">
|
|
164
|
-
.infinite-query-wrapper {
|
|
165
|
-
overflow: auto;
|
|
166
|
-
font-size: 14px;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.loading-icon {
|
|
170
|
-
display: block;
|
|
171
|
-
color: var(--antd-colorPrimary);
|
|
172
|
-
font-size: 1.2em;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.initial-loading,
|
|
176
|
-
.initial-loading-error,
|
|
177
|
-
.empty,
|
|
178
|
-
.more-loading,
|
|
179
|
-
.more-loading-error,
|
|
180
|
-
.no-more {
|
|
181
|
-
display: flex;
|
|
182
|
-
align-items: center;
|
|
183
|
-
justify-content: center;
|
|
184
|
-
color: var(--antd-colorTextSecondary);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.initial-loading,
|
|
188
|
-
.initial-loading-error {
|
|
189
|
-
height: var(--ctn-height, 100px);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.initial-loading-error {
|
|
193
|
-
cursor: pointer;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
.more-loading,
|
|
197
|
-
.more-loading-error,
|
|
198
|
-
.no-more {
|
|
199
|
-
height: 50px;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
.more-loading-error {
|
|
203
|
-
cursor: pointer;
|
|
204
|
-
}
|
|
205
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { computed, ref, unref } from 'vue';
|
|
3
|
+
import type { UseInfiniteQueryReturnType } from '@tanstack/vue-query';
|
|
4
|
+
import { useCreateTrigger } from './useCreateTrigger';
|
|
5
|
+
|
|
6
|
+
export type { ISlotProvide };
|
|
7
|
+
|
|
8
|
+
interface ISlotProvide {
|
|
9
|
+
isInitialLoading: boolean
|
|
10
|
+
isInitialLoadingError: boolean
|
|
11
|
+
isEmpty: boolean
|
|
12
|
+
isMoreLoading: boolean
|
|
13
|
+
isMoreLoadingError: boolean
|
|
14
|
+
isNoMore: boolean
|
|
15
|
+
refetch: () => void
|
|
16
|
+
}
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts" generic="T extends UseInfiniteQueryReturnType<any, any>">
|
|
20
|
+
type TPage = T extends UseInfiniteQueryReturnType<infer P, any> ? NonNullable<P> : any;
|
|
21
|
+
type TRecord = TPage extends { list: Array<infer I> } ? I : any;
|
|
22
|
+
|
|
23
|
+
const props = withDefaults(defineProps<{
|
|
24
|
+
queryier: T
|
|
25
|
+
distance?: string
|
|
26
|
+
}>(), {
|
|
27
|
+
distance: '50px',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const { queryier } = props;
|
|
31
|
+
const pages = computed(() => queryier.data.value?.pages);
|
|
32
|
+
// TODO: 状态之间的互斥仍有问题
|
|
33
|
+
const isInitialLoading = computed(() => queryier.isInitialLoading.value);
|
|
34
|
+
const isInitialLoadingError = computed(() => queryier.isLoadingError.value && !isInitialLoading.value);
|
|
35
|
+
const isMoreLoading = computed(
|
|
36
|
+
() => (queryier.isFetchingNextPage.value || queryier.isFetching.value) && !isInitialLoading.value,
|
|
37
|
+
);
|
|
38
|
+
const isEmpty = computed(() => queryier.isSuccess.value && !pages.value?.[0].list?.length);
|
|
39
|
+
const isMoreLoadingError = computed(() => queryier.isRefetchError.value && !isMoreLoading.value);
|
|
40
|
+
const isNoMore = computed(
|
|
41
|
+
() =>
|
|
42
|
+
!queryier.hasNextPage?.value
|
|
43
|
+
&& !isInitialLoading.value
|
|
44
|
+
&& !isInitialLoadingError.value
|
|
45
|
+
&& !isMoreLoading.value
|
|
46
|
+
&& !isMoreLoadingError.value,
|
|
47
|
+
);
|
|
48
|
+
const $container = ref<HTMLElement>();
|
|
49
|
+
const containerCssVars = computed(() => {
|
|
50
|
+
const ctnEle = unref($container);
|
|
51
|
+
|
|
52
|
+
if (!ctnEle)
|
|
53
|
+
return {};
|
|
54
|
+
|
|
55
|
+
const rect = ctnEle.getBoundingClientRect();
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
'--ctn-height': `${rect.height}px`,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
function refetchLastPage() {
|
|
63
|
+
queryier.refetch({
|
|
64
|
+
refetchPage(lastPage: any, _index, allPages: any[]) {
|
|
65
|
+
const lastIndex = allPages?.length - 1;
|
|
66
|
+
return lastPage?.pagination?.page === allPages?.[lastIndex]?.pagination?.page;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function fetchNextPage() {
|
|
72
|
+
const { isFetching, isLoading, hasNextPage } = queryier;
|
|
73
|
+
|
|
74
|
+
if (isFetching.value || isLoading.value || !hasNextPage?.value)
|
|
75
|
+
return;
|
|
76
|
+
|
|
77
|
+
queryier.fetchNextPage();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function refetch() {
|
|
81
|
+
if (isNoMore.value)
|
|
82
|
+
refetchLastPage();
|
|
83
|
+
else if (isMoreLoadingError.value)
|
|
84
|
+
fetchNextPage();
|
|
85
|
+
else
|
|
86
|
+
queryier.refetch();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function triggerFetchNextPage() {
|
|
90
|
+
if (queryier.isError.value)
|
|
91
|
+
return;
|
|
92
|
+
|
|
93
|
+
fetchNextPage();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
useCreateTrigger($container, triggerFetchNextPage, props.distance);
|
|
97
|
+
|
|
98
|
+
const slotProvide = computed<ISlotProvide>(() => ({
|
|
99
|
+
isInitialLoading: isInitialLoading.value,
|
|
100
|
+
isInitialLoadingError: isInitialLoadingError.value,
|
|
101
|
+
isMoreLoading: isMoreLoading.value,
|
|
102
|
+
isMoreLoadingError: isMoreLoadingError.value,
|
|
103
|
+
isNoMore: isNoMore.value,
|
|
104
|
+
isEmpty: isEmpty.value,
|
|
105
|
+
refetch,
|
|
106
|
+
}));
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<template>
|
|
110
|
+
<div ref="$container" class="infinite-query-wrapper" :style="containerCssVars">
|
|
111
|
+
<div class="list">
|
|
112
|
+
<template v-for="(page) of pages">
|
|
113
|
+
<template v-for="record of page.list">
|
|
114
|
+
<!-- eslint-disable-next-line vue/no-extra-parens -->
|
|
115
|
+
<slot name="default" :record="(record as TRecord)" />
|
|
116
|
+
</template>
|
|
117
|
+
</template>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<slot
|
|
121
|
+
name="status" v-bind="slotProvide"
|
|
122
|
+
>
|
|
123
|
+
<slot name="initialLoading">
|
|
124
|
+
<div v-if="isInitialLoading" class="initial-loading">
|
|
125
|
+
<i class="i-svg-spinners:180-ring-with-bg loading-icon" />
|
|
126
|
+
</div>
|
|
127
|
+
</slot>
|
|
128
|
+
|
|
129
|
+
<slot name="initialLoadingError">
|
|
130
|
+
<div v-if="isInitialLoadingError" class="initial-loading-error" @click="refetch()">
|
|
131
|
+
<span>加载失败,点击重试</span>
|
|
132
|
+
</div>
|
|
133
|
+
</slot>
|
|
134
|
+
|
|
135
|
+
<slot name="empty">
|
|
136
|
+
<div v-if="isEmpty" class="empty">
|
|
137
|
+
<span>暂无数据</span>
|
|
138
|
+
</div>
|
|
139
|
+
</slot>
|
|
140
|
+
|
|
141
|
+
<slot name="oreLoading">
|
|
142
|
+
<div v-if="isMoreLoading" class="more-loading">
|
|
143
|
+
<i class="i-svg-spinners:180-ring-with-bg loading-icon" />
|
|
144
|
+
<span class="ml-1 text">加载中...</span>
|
|
145
|
+
</div>
|
|
146
|
+
</slot>
|
|
147
|
+
|
|
148
|
+
<slot name="moreLoadingError">
|
|
149
|
+
<div v-if="isMoreLoadingError" class="more-loading-error" @click="refetch()">
|
|
150
|
+
<span class="text">加载失败,点击重试</span>
|
|
151
|
+
</div>
|
|
152
|
+
</slot>
|
|
153
|
+
|
|
154
|
+
<slot name="noMore">
|
|
155
|
+
<div v-if="isNoMore" class="no-more" @click="refetch()">
|
|
156
|
+
<span class="text">暂无更多</span>
|
|
157
|
+
</div>
|
|
158
|
+
</slot>
|
|
159
|
+
</slot>
|
|
160
|
+
</div>
|
|
161
|
+
</template>
|
|
162
|
+
|
|
163
|
+
<style scoped lang="scss">
|
|
164
|
+
.infinite-query-wrapper {
|
|
165
|
+
overflow: auto;
|
|
166
|
+
font-size: 14px;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.loading-icon {
|
|
170
|
+
display: block;
|
|
171
|
+
color: var(--antd-colorPrimary);
|
|
172
|
+
font-size: 1.2em;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.initial-loading,
|
|
176
|
+
.initial-loading-error,
|
|
177
|
+
.empty,
|
|
178
|
+
.more-loading,
|
|
179
|
+
.more-loading-error,
|
|
180
|
+
.no-more {
|
|
181
|
+
display: flex;
|
|
182
|
+
align-items: center;
|
|
183
|
+
justify-content: center;
|
|
184
|
+
color: var(--antd-colorTextSecondary);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.initial-loading,
|
|
188
|
+
.initial-loading-error {
|
|
189
|
+
height: var(--ctn-height, 100px);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.initial-loading-error {
|
|
193
|
+
cursor: pointer;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.more-loading,
|
|
197
|
+
.more-loading-error,
|
|
198
|
+
.no-more {
|
|
199
|
+
height: 50px;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.more-loading-error {
|
|
203
|
+
cursor: pointer;
|
|
204
|
+
}
|
|
205
|
+
</style>
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { onUnmounted, watch } from 'vue';
|
|
2
|
-
import type { Ref } from 'vue';
|
|
3
|
-
import { useIntersectionObserver, useIntervalFn } from '@vueuse/core';
|
|
4
|
-
|
|
5
|
-
export function useCreateTrigger(containerEle: Ref<HTMLElement | undefined>, callback: Function, distance: string) {
|
|
6
|
-
const triggerEl = document.createElement('div');
|
|
7
|
-
|
|
8
|
-
Object.assign(triggerEl.style, {
|
|
9
|
-
position: 'relative',
|
|
10
|
-
zIndex: '5',
|
|
11
|
-
marginTop: `-${distance}`,
|
|
12
|
-
marginBottom: distance,
|
|
13
|
-
width: '5px',
|
|
14
|
-
height: '5px',
|
|
15
|
-
// background: 'red',
|
|
16
|
-
} satisfies Partial<CSSStyleDeclaration>);
|
|
17
|
-
|
|
18
|
-
useIntervalFn(() => {
|
|
19
|
-
const { transform } = triggerEl.style;
|
|
20
|
-
|
|
21
|
-
if (transform)
|
|
22
|
-
triggerEl.style.removeProperty('transform');
|
|
23
|
-
else triggerEl.style.setProperty('transform', 'translateX(-200%)');
|
|
24
|
-
}, 500);
|
|
25
|
-
|
|
26
|
-
useIntersectionObserver(triggerEl, ([entry]) => {
|
|
27
|
-
if (entry.isIntersecting)
|
|
28
|
-
callback();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
watch(containerEle, (ele) => {
|
|
32
|
-
if (ele)
|
|
33
|
-
ele.append(triggerEl);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
onUnmounted(() => {
|
|
37
|
-
triggerEl.remove();
|
|
38
|
-
});
|
|
39
|
-
}
|
|
1
|
+
import { onUnmounted, watch } from 'vue';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
import { useIntersectionObserver, useIntervalFn } from '@vueuse/core';
|
|
4
|
+
|
|
5
|
+
export function useCreateTrigger(containerEle: Ref<HTMLElement | undefined>, callback: Function, distance: string) {
|
|
6
|
+
const triggerEl = document.createElement('div');
|
|
7
|
+
|
|
8
|
+
Object.assign(triggerEl.style, {
|
|
9
|
+
position: 'relative',
|
|
10
|
+
zIndex: '5',
|
|
11
|
+
marginTop: `-${distance}`,
|
|
12
|
+
marginBottom: distance,
|
|
13
|
+
width: '5px',
|
|
14
|
+
height: '5px',
|
|
15
|
+
// background: 'red',
|
|
16
|
+
} satisfies Partial<CSSStyleDeclaration>);
|
|
17
|
+
|
|
18
|
+
useIntervalFn(() => {
|
|
19
|
+
const { transform } = triggerEl.style;
|
|
20
|
+
|
|
21
|
+
if (transform)
|
|
22
|
+
triggerEl.style.removeProperty('transform');
|
|
23
|
+
else triggerEl.style.setProperty('transform', 'translateX(-200%)');
|
|
24
|
+
}, 500);
|
|
25
|
+
|
|
26
|
+
useIntersectionObserver(triggerEl, ([entry]) => {
|
|
27
|
+
if (entry.isIntersecting)
|
|
28
|
+
callback();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
watch(containerEle, (ele) => {
|
|
32
|
+
if (ele)
|
|
33
|
+
ele.append(triggerEl);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
onUnmounted(() => {
|
|
37
|
+
triggerEl.remove();
|
|
38
|
+
});
|
|
39
|
+
}
|