@peng_kai/kit 0.0.15 → 0.0.16
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/.vscode/settings.json +41 -0
- package/admin/components/filter/index.ts +5 -0
- package/admin/{filter → components/filter/src}/FilterDrawer.vue +12 -9
- package/admin/{filter → components/filter/src}/FilterParam.vue +15 -15
- package/admin/{filter → components/filter/src}/FilterReset.vue +7 -4
- package/admin/{filter → components/filter/src}/useFilterParams.ts +9 -9
- package/admin/{filter → components/filter/src}/useFilterQuery.ts +11 -11
- package/admin/components/scroll-nav/index.ts +1 -1
- package/admin/components/scroll-nav/src/ScrollNav.vue +9 -9
- package/admin/components/text/index.ts +6 -6
- package/admin/components/text/src/Amount.vue +22 -19
- package/admin/components/text/src/Datetime.vue +12 -12
- package/admin/components/text/src/Duration.vue +13 -13
- package/admin/components/text/src/Hash.vue +13 -11
- package/admin/components/text/src/createTagGetter.ts +7 -7
- package/admin/defines/index.ts +4 -5
- package/admin/defines/page/definePage.ts +12 -0
- package/admin/defines/page/index.ts +1 -0
- package/admin/defines/route/defineRoute.ts +14 -0
- package/admin/defines/route/getRoutes.ts +84 -0
- package/admin/defines/route/helpers.ts +49 -0
- package/admin/defines/route/index.ts +73 -0
- package/admin/defines/route-guard/defineRouteGuard.ts +18 -0
- package/admin/defines/route-guard/getRouteGuards.ts +40 -0
- package/admin/defines/route-guard/index.ts +2 -0
- package/admin/defines/startup/defineStartup.ts +11 -0
- package/admin/defines/startup/getStartups.ts +30 -0
- package/admin/defines/startup/index.ts +2 -0
- package/admin/hooks/index.ts +5 -6
- package/admin/hooks/useMenu.ts +48 -48
- package/admin/hooks/usePage.ts +67 -65
- package/admin/hooks/usePageTab.ts +17 -17
- package/admin/layout/large/Breadcrumb.vue +15 -16
- package/admin/layout/large/Content.vue +4 -4
- package/admin/layout/large/Menu.vue +20 -19
- package/admin/layout/large/PageTab.vue +4 -4
- package/admin/layout/large/index.ts +4 -4
- package/admin/permission/index.ts +4 -0
- package/admin/permission/routerGuard.ts +43 -0
- package/admin/permission/usePermission.ts +52 -0
- package/admin/permission/vuePlugin.ts +30 -0
- package/admin/route-guards/index.ts +2 -0
- package/admin/route-guards/pageProgress.ts +16 -0
- package/admin/route-guards/pageTitle.ts +24 -0
- package/admin/types/assist.ts +10 -0
- package/admin/unocss/index.ts +1 -1
- package/antd/components/InputNumberRange.vue +21 -15
- package/antd/directives/formLabelAlign.ts +28 -23
- package/antd/hooks/createAntdModal.ts +29 -29
- package/antd/hooks/useAntdDrawer.ts +31 -31
- package/antd/hooks/useAntdForm.helpers.ts +18 -18
- package/antd/hooks/useAntdForm.ts +38 -37
- package/antd/hooks/useAntdModal.ts +25 -25
- package/antd/hooks/useAntdTable.ts +22 -22
- package/antd/hooks/useAntdTheme.ts +86 -0
- package/antd/index.ts +8 -7
- package/eslint.config.js +50 -0
- package/kitDependencies.ts +21 -7
- package/package.json +22 -16
- package/pnpm-lock.yaml +2147 -56
- package/request/helpers.ts +30 -13
- package/request/index.ts +2 -2
- package/request/interceptors/checkCode.ts +8 -8
- package/request/interceptors/filterEmptyValue.ts +9 -9
- package/request/interceptors/formatPaging.ts +12 -12
- package/request/interceptors/index.ts +7 -6
- package/request/interceptors/popupMessage.ts +35 -35
- package/request/interceptors/returnResultType.ts +19 -19
- package/request/interceptors/toLogin.ts +13 -0
- package/request/interceptors/unitizeAxiosError.ts +7 -7
- package/request/queryClient.ts +42 -0
- package/request/request.ts +21 -21
- package/request/type.d.ts +18 -18
- package/tsconfig.json +41 -12
- package/utils/index.ts +59 -31
- package/vue/components/index.ts +1 -0
- package/{components → vue/components}/infinite-query/index.ts +1 -1
- package/{components → vue/components}/infinite-query/src/InfiniteQuery.vue +29 -29
- package/{components → vue/components}/infinite-query/src/useCreateTrigger.ts +13 -13
- package/vue/hooks/useComponentRef.ts +12 -12
- package/vue/hooks/useIsMounted.ts +4 -4
- package/vue/hooks/useTeleportTarget.ts +7 -7
- package/vue/index.ts +4 -3
- package/admin/defines/definePage.ts +0 -14
- package/admin/defines/defineRoute.helpers.ts +0 -37
- package/admin/defines/defineRoute.ts +0 -161
- package/admin/defines/defineRouteGuard.ts +0 -56
- package/admin/defines/defineStartup.ts +0 -41
- package/admin/filter/index.ts +0 -5
- package/admin/hooks/usePermission.ts +0 -5
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Enable the ESlint flat config support
|
|
3
|
+
"eslint.experimental.useFlatConfig": true,
|
|
4
|
+
|
|
5
|
+
// Disable the default formatter, use eslint instead
|
|
6
|
+
"prettier.enable": false,
|
|
7
|
+
"editor.formatOnSave": false,
|
|
8
|
+
|
|
9
|
+
// Auto fix
|
|
10
|
+
"editor.codeActionsOnSave": {
|
|
11
|
+
"source.fixAll.eslint": "explicit",
|
|
12
|
+
"source.organizeImports": "never"
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
16
|
+
"eslint.rules.customizations": [
|
|
17
|
+
{ "rule": "style/*", "severity": "off" },
|
|
18
|
+
{ "rule": "*-indent", "severity": "off" },
|
|
19
|
+
{ "rule": "*-spacing", "severity": "off" },
|
|
20
|
+
{ "rule": "*-spaces", "severity": "off" },
|
|
21
|
+
{ "rule": "*-order", "severity": "off" },
|
|
22
|
+
{ "rule": "*-dangle", "severity": "off" },
|
|
23
|
+
{ "rule": "*-newline", "severity": "off" },
|
|
24
|
+
{ "rule": "*quotes", "severity": "off" },
|
|
25
|
+
{ "rule": "*semi", "severity": "off" }
|
|
26
|
+
],
|
|
27
|
+
|
|
28
|
+
// Enable eslint for all supported languages
|
|
29
|
+
"eslint.validate": [
|
|
30
|
+
"javascript",
|
|
31
|
+
"javascriptreact",
|
|
32
|
+
"typescript",
|
|
33
|
+
"typescriptreact",
|
|
34
|
+
"vue",
|
|
35
|
+
"html",
|
|
36
|
+
"markdown",
|
|
37
|
+
"json",
|
|
38
|
+
"jsonc",
|
|
39
|
+
"yaml"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as FilterDrawer } from './src/FilterDrawer.vue';
|
|
2
|
+
export { default as FilterReset } from './src/FilterReset.vue';
|
|
3
|
+
export { default as FilterParam, paramTypes } from './src/FilterParam.vue';
|
|
4
|
+
export { useFilterParams } from './src/useFilterParams';
|
|
5
|
+
export { useFilterInfiniteQuery, useFilterPaginationQuery } from './src/useFilterQuery';
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { ref } from
|
|
3
|
-
import {
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { Button as AButton, Drawer as ADrawer } from 'ant-design-vue';
|
|
4
4
|
|
|
5
5
|
const emits = defineEmits<{
|
|
6
6
|
(e: 'filter'): void
|
|
7
7
|
(e: 'reset', value: number): void
|
|
8
|
-
}>()
|
|
9
|
-
const filterVisible = ref(false)
|
|
8
|
+
}>();
|
|
9
|
+
const filterVisible = ref(false);
|
|
10
10
|
|
|
11
11
|
function filter() {
|
|
12
|
-
emits('filter')
|
|
13
|
-
filterVisible.value = false
|
|
12
|
+
emits('filter');
|
|
13
|
+
filterVisible.value = false;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function reset() {
|
|
17
|
-
emits('reset', 1)
|
|
18
|
-
filterVisible.value = false
|
|
17
|
+
emits('reset', 1);
|
|
18
|
+
filterVisible.value = false;
|
|
19
19
|
}
|
|
20
20
|
</script>
|
|
21
21
|
|
|
@@ -30,7 +30,10 @@ function reset() {
|
|
|
30
30
|
</div>
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
|
-
<ADrawer
|
|
33
|
+
<ADrawer
|
|
34
|
+
v-model:open="filterVisible" class="filter-drawer" placement="bottom"
|
|
35
|
+
height="50vh"
|
|
36
|
+
>
|
|
34
37
|
<template #extra>
|
|
35
38
|
<AButton class="mr-3 my--3" @click="reset()">
|
|
36
39
|
重置
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import isNil from 'lodash-es/isNil'
|
|
3
|
-
import isFinite from 'lodash-es/isFinite'
|
|
4
|
-
import dayjs from 'dayjs'
|
|
5
|
-
import bignumber from 'bignumber.js'
|
|
2
|
+
import isNil from 'lodash-es/isNil';
|
|
3
|
+
import isFinite from 'lodash-es/isFinite';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import bignumber from 'bignumber.js';
|
|
6
6
|
|
|
7
|
-
export const paramTypes = { numberRange, datetimeRange, options }
|
|
7
|
+
export const paramTypes = { numberRange, datetimeRange, options };
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* 时间范围格式化
|
|
@@ -13,9 +13,9 @@ export const paramTypes = { numberRange, datetimeRange, options }
|
|
|
13
13
|
*/
|
|
14
14
|
function numberRange(range?: [number, number], unit?: string) {
|
|
15
15
|
if (!range?.every(isFinite))
|
|
16
|
-
return ''
|
|
16
|
+
return '';
|
|
17
17
|
|
|
18
|
-
return `${bignumber(range[0]).toFormat()}~${bignumber(range[1]).toFormat()}${unit}
|
|
18
|
+
return `${bignumber(range[0]).toFormat()}~${bignumber(range[1]).toFormat()}${unit}`;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -25,26 +25,26 @@ function numberRange(range?: [number, number], unit?: string) {
|
|
|
25
25
|
*/
|
|
26
26
|
function datetimeRange(range?: [string | dayjs.Dayjs, string | dayjs.Dayjs], template = 'YYYY-MM-DD') {
|
|
27
27
|
if (!range?.every(v => dayjs(v).isValid()))
|
|
28
|
-
return ''
|
|
28
|
+
return '';
|
|
29
29
|
|
|
30
|
-
return `${dayjs(range[0]).format(template)} ~ ${dayjs(range[1]).format(template)}
|
|
30
|
+
return `${dayjs(range[0]).format(template)} ~ ${dayjs(range[1]).format(template)}`;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function options(
|
|
34
34
|
value?: string | number | Array<string | number>,
|
|
35
|
-
options?: Array<{ value: string | number
|
|
35
|
+
options?: Array<{ value: string | number, label: any }>,
|
|
36
36
|
) {
|
|
37
37
|
if (isNil(value) || isNil(options))
|
|
38
|
-
return
|
|
38
|
+
return;
|
|
39
39
|
if (value === '')
|
|
40
|
-
return
|
|
40
|
+
return;
|
|
41
41
|
|
|
42
|
-
const _value = Array.isArray(value) ? value : [value]
|
|
42
|
+
const _value = Array.isArray(value) ? value : [value];
|
|
43
43
|
|
|
44
44
|
return options
|
|
45
45
|
.filter(o => _value.includes(o.value))
|
|
46
46
|
.map(o => o.label)
|
|
47
|
-
.join(', ')
|
|
47
|
+
.join(', ');
|
|
48
48
|
}
|
|
49
49
|
</script>
|
|
50
50
|
|
|
@@ -52,7 +52,7 @@ function options(
|
|
|
52
52
|
const props = defineProps<{
|
|
53
53
|
label: string
|
|
54
54
|
content?: any
|
|
55
|
-
}>()
|
|
55
|
+
}>();
|
|
56
56
|
</script>
|
|
57
57
|
|
|
58
58
|
<template>
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { Button as AButton } from
|
|
2
|
+
import { Button as AButton } from 'ant-design-vue';
|
|
3
3
|
|
|
4
4
|
const props = defineProps<{
|
|
5
5
|
loading?: boolean
|
|
6
|
-
}>()
|
|
6
|
+
}>();
|
|
7
7
|
const emits = defineEmits<{
|
|
8
8
|
(e: 'filter'): void
|
|
9
9
|
(e: 'reset'): void
|
|
10
|
-
}>()
|
|
10
|
+
}>();
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<template>
|
|
14
14
|
<div class="flex-none flex w-min ml-auto">
|
|
15
|
-
<AButton
|
|
15
|
+
<AButton
|
|
16
|
+
class="mr-2 filter-btn" type="primary" htmlType="submit"
|
|
17
|
+
:loading="props.loading" @click="emits('filter')"
|
|
18
|
+
>
|
|
16
19
|
查询
|
|
17
20
|
</AButton>
|
|
18
21
|
<AButton :disabled="props.loading" @click="emits('reset')">
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { extendRef } from '@vueuse/core'
|
|
2
|
-
import { reactive } from
|
|
1
|
+
import { extendRef } from '@vueuse/core';
|
|
2
|
+
import { reactive } from 'vue';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
const defaultPageParams: PageParams = { page: 1, page_size: 10 }
|
|
4
|
+
interface PageParams { page?: string | number, page_size?: string | number };
|
|
5
|
+
const defaultPageParams: PageParams = { page: 1, page_size: 10 };
|
|
6
6
|
|
|
7
7
|
export function useFilterParams<R extends Api.Request, AP extends Api.GetParam<R>, BP extends AP>(
|
|
8
8
|
_api: R,
|
|
9
9
|
buildParams: () => BP,
|
|
10
10
|
pageParams = defaultPageParams,
|
|
11
11
|
) {
|
|
12
|
-
type FinalParams = AP & BP & PageParams
|
|
13
|
-
const params = reactive({ ...pageParams, ...buildParams() } as FinalParams)
|
|
12
|
+
type FinalParams = AP & BP & PageParams;
|
|
13
|
+
const params = reactive({ ...pageParams, ...buildParams() } as FinalParams);
|
|
14
14
|
const update = (newParams?: Partial<FinalParams>) => {
|
|
15
|
-
Object.assign(params, { ...buildParams(), ...newParams })
|
|
16
|
-
}
|
|
15
|
+
Object.assign(params, { ...buildParams(), ...newParams, __t: Date.now() });
|
|
16
|
+
};
|
|
17
17
|
|
|
18
|
-
return extendRef(params, { update })
|
|
18
|
+
return extendRef(params, { update });
|
|
19
19
|
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useInfiniteQuery, useQuery } from '@tanstack/vue-query';
|
|
2
|
+
import { useFilterParams } from './useFilterParams';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
*/
|
|
7
7
|
export function useFilterPaginationQuery<Api extends Api.Request, P extends Api.GetParam<Api>>(apiFn: Api, paramsFn: () => P) {
|
|
8
|
-
type Data = Api.GetData<Api
|
|
8
|
+
type Data = Api.GetData<Api>;
|
|
9
9
|
|
|
10
|
-
const filterParams = useFilterParams(apiFn, paramsFn)
|
|
10
|
+
const filterParams = useFilterParams(apiFn, paramsFn);
|
|
11
11
|
const filterQuery = useQuery({
|
|
12
12
|
keepPreviousData: true,
|
|
13
13
|
queryKey: [apiFn.id, 'pagination', filterParams],
|
|
14
14
|
queryFn: () => (apiFn(filterParams) as Promise<Data>),
|
|
15
|
-
})
|
|
15
|
+
});
|
|
16
16
|
|
|
17
|
-
return [filterQuery, filterParams] as const
|
|
17
|
+
return [filterQuery, filterParams] as const;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export function useFilterInfiniteQuery<Api extends Api.Request, P extends Api.GetParam<Api>>(apiFn: Api, paramsFn: () => P) {
|
|
21
|
-
type Data = Api.GetData<Api
|
|
21
|
+
type Data = Api.GetData<Api>;
|
|
22
22
|
|
|
23
|
-
const filterParams = useFilterParams(apiFn, paramsFn)
|
|
23
|
+
const filterParams = useFilterParams(apiFn, paramsFn);
|
|
24
24
|
const filterQuery = useInfiniteQuery({
|
|
25
25
|
keepPreviousData: true,
|
|
26
26
|
queryKey: [apiFn.id, 'infinite', filterParams],
|
|
27
27
|
queryFn: ctx => (apiFn({ ...filterParams, ...ctx.pageParam }) as Promise<Data>),
|
|
28
|
-
})
|
|
28
|
+
});
|
|
29
29
|
|
|
30
|
-
return [filterQuery, filterParams] as const
|
|
30
|
+
return [filterQuery, filterParams] as const;
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as ScrollNav } from './src/ScrollNav.vue'
|
|
1
|
+
export { default as ScrollNav } from './src/ScrollNav.vue';
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed } from
|
|
3
|
-
import { useElementSize } from '@vueuse/core'
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { useElementSize } from '@vueuse/core';
|
|
4
4
|
|
|
5
5
|
const props = defineProps<{
|
|
6
6
|
selector: string
|
|
7
|
-
}>()
|
|
7
|
+
}>();
|
|
8
8
|
|
|
9
|
-
const $content = document.querySelector(props.selector) as HTMLElement
|
|
10
|
-
const $contentParent = $content.parentElement
|
|
11
|
-
const { height: contentParentH } = useElementSize($contentParent)
|
|
12
|
-
const { height: contentH } = useElementSize($content)
|
|
13
|
-
const visible = computed(() => contentParentH.value * 2 < contentH.value)
|
|
9
|
+
const $content = document.querySelector(props.selector) as HTMLElement;
|
|
10
|
+
const $contentParent = $content.parentElement;
|
|
11
|
+
const { height: contentParentH } = useElementSize($contentParent);
|
|
12
|
+
const { height: contentH } = useElementSize($content);
|
|
13
|
+
const visible = computed(() => contentParentH.value * 2 < contentH.value);
|
|
14
14
|
|
|
15
15
|
function scrollTo(top: number) {
|
|
16
|
-
$contentParent?.scrollTo({ top })
|
|
16
|
+
$contentParent?.scrollTo({ top });
|
|
17
17
|
}
|
|
18
18
|
</script>
|
|
19
19
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import Hash from './src/Hash.vue'
|
|
2
|
-
import Amount from './src/Amount.vue'
|
|
3
|
-
import Datetime from './src/Datetime.vue'
|
|
4
|
-
import Duration from './src/Duration.vue'
|
|
1
|
+
import Hash from './src/Hash.vue';
|
|
2
|
+
import Amount from './src/Amount.vue';
|
|
3
|
+
import Datetime from './src/Datetime.vue';
|
|
4
|
+
import Duration from './src/Duration.vue';
|
|
5
5
|
|
|
6
|
-
export { createTagGetter } from './src/createTagGetter'
|
|
6
|
+
export { createTagGetter } from './src/createTagGetter';
|
|
7
7
|
|
|
8
8
|
export const Text = {
|
|
9
9
|
Hash,
|
|
10
10
|
Amount,
|
|
11
11
|
Datetime,
|
|
12
12
|
Duration,
|
|
13
|
-
}
|
|
13
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { computed } from
|
|
3
|
-
import bigNumber from 'bignumber.js'
|
|
4
|
-
import isNil from 'lodash-es/isNil'
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import bigNumber from 'bignumber.js';
|
|
4
|
+
import isNil from 'lodash-es/isNil';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* 当 symbol 为以下值时,使用预设的 Logo
|
|
@@ -15,7 +15,7 @@ const presetSymbols: Record<string, string> = {
|
|
|
15
15
|
BUSD: 'https://assets.coingecko.com/coins/images/9576/large/BUSD.png',
|
|
16
16
|
MATIC: 'https://api.iconify.design/cryptocurrency-color:matic.svg',
|
|
17
17
|
SOL: 'https://api.iconify.design/cryptocurrency-color:sol.svg',
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
19
|
</script>
|
|
20
20
|
|
|
21
21
|
<script setup lang="ts">
|
|
@@ -43,30 +43,30 @@ const props = withDefaults(
|
|
|
43
43
|
fractionDigits: 18,
|
|
44
44
|
colorful: false,
|
|
45
45
|
},
|
|
46
|
-
)
|
|
46
|
+
);
|
|
47
47
|
|
|
48
48
|
const amountText = computed(() => {
|
|
49
|
-
const _amount = props.amount
|
|
49
|
+
const _amount = props.amount;
|
|
50
50
|
|
|
51
51
|
if (isNil(_amount))
|
|
52
|
-
return '-'
|
|
52
|
+
return '-';
|
|
53
53
|
|
|
54
|
-
let bn = bigNumber(_amount)
|
|
55
|
-
bn = !isNil(props.precision) ? bn.dividedBy(10 ** props.precision) : bn
|
|
56
|
-
let bnt = bn.toFormat(props.fractionDigits)
|
|
57
|
-
bnt = props.padZero ? bnt : bnt.replace(/\.?0+$/, '')
|
|
54
|
+
let bn = bigNumber(_amount);
|
|
55
|
+
bn = !isNil(props.precision) ? bn.dividedBy(10 ** props.precision) : bn;
|
|
56
|
+
let bnt = bn.toFormat(props.fractionDigits);
|
|
57
|
+
bnt = props.padZero ? bnt : bnt.replace(/\.?0+$/, '');
|
|
58
58
|
|
|
59
|
-
return bnt
|
|
60
|
-
})
|
|
59
|
+
return bnt;
|
|
60
|
+
});
|
|
61
61
|
const amountColor = computed(() => {
|
|
62
|
-
const num = Number.parseFloat(props.amount as string)
|
|
62
|
+
const num = Number.parseFloat(props.amount as string);
|
|
63
63
|
|
|
64
64
|
if (!props.colorful || (Number.isNaN(num) ? true : num === 0))
|
|
65
|
-
return ''
|
|
65
|
+
return '';
|
|
66
66
|
|
|
67
|
-
return num > 0 ? '#52c41a' : (num < 0 ? '#ff4d4f' : '#000')
|
|
68
|
-
})
|
|
69
|
-
const symbol = computed(() => presetSymbols[props.symbol!] ?? props.symbol ?? '')
|
|
67
|
+
return num > 0 ? '#52c41a' : (num < 0 ? '#ff4d4f' : '#000');
|
|
68
|
+
});
|
|
69
|
+
const symbol = computed(() => presetSymbols[props.symbol!] ?? props.symbol ?? '');
|
|
70
70
|
</script>
|
|
71
71
|
|
|
72
72
|
<template>
|
|
@@ -75,7 +75,10 @@ const symbol = computed(() => presetSymbols[props.symbol!] ?? props.symbol ?? ''
|
|
|
75
75
|
<span v-if="props.approx" class="color-$amount-color">≈</span>
|
|
76
76
|
|
|
77
77
|
<!-- 符号 -->
|
|
78
|
-
<img
|
|
78
|
+
<img
|
|
79
|
+
v-if="symbol.startsWith('http')" class="symbol-logo" :src="symbol"
|
|
80
|
+
:alt="props.unit"
|
|
81
|
+
> <!-- 图片Logo -->
|
|
79
82
|
<span v-else class="color-$amount-color">{{ symbol }}</span> <!-- 文本Logo,如法定币种符号(¥、$) -->
|
|
80
83
|
|
|
81
84
|
<!-- 金额 -->
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { Tooltip as ATooltip } from
|
|
3
|
-
import { computed } from
|
|
4
|
-
import { getDependencies } from
|
|
2
|
+
import { Tooltip as ATooltip } from 'ant-design-vue';
|
|
3
|
+
import { computed } from 'vue';
|
|
4
|
+
import { getDependencies } from '../../../../kitDependencies';
|
|
5
5
|
|
|
6
6
|
defineOptions({
|
|
7
7
|
inheritAttrs: false,
|
|
8
|
-
})
|
|
8
|
+
});
|
|
9
9
|
|
|
10
10
|
const props = withDefaults(
|
|
11
11
|
defineProps<{
|
|
@@ -15,20 +15,20 @@ const props = withDefaults(
|
|
|
15
15
|
{
|
|
16
16
|
template: 'MM-DD HH:mm:ss',
|
|
17
17
|
},
|
|
18
|
-
)
|
|
19
|
-
const {dayjs} = getDependencies()
|
|
18
|
+
);
|
|
19
|
+
const { dayjs } = getDependencies()!;
|
|
20
20
|
const timestamp = computed(() => {
|
|
21
|
-
let tsStr = String(props.timestamp)
|
|
21
|
+
let tsStr = String(props.timestamp);
|
|
22
22
|
|
|
23
23
|
if (tsStr.length === 10)
|
|
24
|
-
tsStr += '000'
|
|
24
|
+
tsStr += '000';
|
|
25
25
|
if (tsStr.length !== 13)
|
|
26
|
-
return
|
|
26
|
+
return;
|
|
27
27
|
|
|
28
|
-
const tsNum = Number.parseInt(tsStr)
|
|
28
|
+
const tsNum = Number.parseInt(tsStr);
|
|
29
29
|
|
|
30
|
-
return Number.isNaN(tsNum) ? undefined : tsNum
|
|
31
|
-
})
|
|
30
|
+
return Number.isNaN(tsNum) ? undefined : tsNum;
|
|
31
|
+
});
|
|
32
32
|
</script>
|
|
33
33
|
|
|
34
34
|
<template>
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed } from
|
|
2
|
+
import { computed } from 'vue';
|
|
3
3
|
|
|
4
4
|
const props = defineProps<{
|
|
5
5
|
seconds: number
|
|
6
|
-
}>()
|
|
6
|
+
}>();
|
|
7
7
|
|
|
8
8
|
const formattedDuration = computed(() => {
|
|
9
|
-
const days = Math.floor(props.seconds / (3600 * 24))
|
|
10
|
-
const hours = Math.floor((props.seconds % (3600 * 24)) / 3600)
|
|
11
|
-
const minutes = Math.floor((props.seconds % 3600) / 60)
|
|
12
|
-
const seconds = props.seconds % 60
|
|
13
|
-
let formattedDuration = ''
|
|
9
|
+
const days = Math.floor(props.seconds / (3600 * 24));
|
|
10
|
+
const hours = Math.floor((props.seconds % (3600 * 24)) / 3600);
|
|
11
|
+
const minutes = Math.floor((props.seconds % 3600) / 60);
|
|
12
|
+
const seconds = props.seconds % 60;
|
|
13
|
+
let formattedDuration = '';
|
|
14
14
|
|
|
15
|
-
days >= 1 && (formattedDuration += `${Math.floor(days)}天 `)
|
|
16
|
-
hours >= 1 && (formattedDuration += `${Math.floor(hours)}小时 `)
|
|
17
|
-
minutes >= 1 && (formattedDuration += `${Math.floor(minutes)}分钟 `)
|
|
18
|
-
seconds >= 1 && (formattedDuration += `${Math.floor(seconds)}秒`)
|
|
15
|
+
days >= 1 && (formattedDuration += `${Math.floor(days)}天 `);
|
|
16
|
+
hours >= 1 && (formattedDuration += `${Math.floor(hours)}小时 `);
|
|
17
|
+
minutes >= 1 && (formattedDuration += `${Math.floor(minutes)}分钟 `);
|
|
18
|
+
seconds >= 1 && (formattedDuration += `${Math.floor(seconds)}秒`);
|
|
19
19
|
|
|
20
|
-
return formattedDuration
|
|
21
|
-
})
|
|
20
|
+
return formattedDuration;
|
|
21
|
+
});
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
24
|
<template>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { Tooltip as ATooltip, TypographyLink as ATypographyLink } from
|
|
3
|
-
import { computed } from
|
|
4
|
-
import { desensitize, getScanBrowser } from '../../../../utils'
|
|
2
|
+
import { Tooltip as ATooltip, TypographyLink as ATypographyLink } from 'ant-design-vue';
|
|
3
|
+
import { computed } from 'vue';
|
|
4
|
+
import { desensitize, getScanBrowser } from '../../../../utils';
|
|
5
5
|
|
|
6
|
-
type HashType = Parameters<typeof getScanBrowser>[2]
|
|
6
|
+
type HashType = Parameters<typeof getScanBrowser>[2];
|
|
7
7
|
|
|
8
8
|
defineOptions({
|
|
9
9
|
inheritAttrs: false,
|
|
10
|
-
})
|
|
10
|
+
});
|
|
11
11
|
|
|
12
12
|
const props = withDefaults(
|
|
13
13
|
defineProps<{
|
|
@@ -19,21 +19,23 @@ const props = withDefaults(
|
|
|
19
19
|
{
|
|
20
20
|
hide: true,
|
|
21
21
|
},
|
|
22
|
-
)
|
|
22
|
+
);
|
|
23
23
|
|
|
24
24
|
const href = computed(() => {
|
|
25
|
-
const { hash, chain, type } = props
|
|
25
|
+
const { hash, chain, type } = props;
|
|
26
26
|
|
|
27
27
|
if (!hash || !chain || !type)
|
|
28
|
-
return
|
|
29
|
-
return getScanBrowser(chain, hash, type)
|
|
30
|
-
})
|
|
28
|
+
return;
|
|
29
|
+
return getScanBrowser(chain, hash, type);
|
|
30
|
+
});
|
|
31
31
|
</script>
|
|
32
32
|
|
|
33
33
|
<template>
|
|
34
34
|
<ATypographyLink :href="href" :copyable="{ text: props.hash, tooltip: false }" target="_blank">
|
|
35
35
|
<ATooltip>
|
|
36
|
-
<template v-if="props.hide" #title>
|
|
36
|
+
<template v-if="props.hide" #title>
|
|
37
|
+
{{ props.hash }}
|
|
38
|
+
</template>
|
|
37
39
|
<span v-bind="$attrs">{{ props.hide ? desensitize(props.hash) : props.hash }}</span>
|
|
38
40
|
</ATooltip>
|
|
39
41
|
</ATypographyLink>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { computed, h } from
|
|
2
|
-
import { Tag as ATag } from 'ant-design-vue'
|
|
3
|
-
import type { TagProps } from 'ant-design-vue'
|
|
1
|
+
import { computed, h } from 'vue';
|
|
2
|
+
import { Tag as ATag } from 'ant-design-vue';
|
|
3
|
+
import type { TagProps } from 'ant-design-vue';
|
|
4
4
|
|
|
5
5
|
export function createTagGetter(typeMapFn: () => { [code: number | string]: [ text: string, color: TagProps['color'] ] }) {
|
|
6
|
-
const typeMap = computed(typeMapFn)
|
|
6
|
+
const typeMap = computed(typeMapFn);
|
|
7
7
|
|
|
8
8
|
return (type: number) => {
|
|
9
|
-
const [text, color] = typeMap.value[type] ?? []
|
|
9
|
+
const [text, color] = typeMap.value[type] ?? [];
|
|
10
10
|
|
|
11
|
-
return text ? h(ATag, { color }, () => text) : h('span', null, '-')
|
|
12
|
-
}
|
|
11
|
+
return text ? h(ATag, { color }, () => text) : h('span', null, '-');
|
|
12
|
+
};
|
|
13
13
|
}
|
package/admin/defines/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export { definePage } from './
|
|
2
|
-
export { defineRoute, getRoutes } from './
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export { defineStartup, getStartups } from './defineStartup'
|
|
1
|
+
export { definePage } from './page';
|
|
2
|
+
export { defineRoute, getRoutes } from './route';
|
|
3
|
+
export { defineRouteGuard, getRouteGuards } from './route-guard';
|
|
4
|
+
export { defineStartup, getStartups } from './startup';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineAsyncComponent, defineComponent, h } from 'vue';
|
|
2
|
+
import type { AsyncComponentLoader } from 'vue';
|
|
3
|
+
|
|
4
|
+
export function definePage(loader: AsyncComponentLoader) {
|
|
5
|
+
return defineComponent({
|
|
6
|
+
setup() {
|
|
7
|
+
const Page = defineAsyncComponent(loader);
|
|
8
|
+
|
|
9
|
+
return () => h(Page, null);
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { definePage } from './definePage';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RouteRecordRaw } from 'vue-router';
|
|
2
|
+
import { definePage } from '../page';
|
|
3
|
+
|
|
4
|
+
export { defineRoute, RouteSymbol };
|
|
5
|
+
|
|
6
|
+
const RouteSymbol = Symbol('app-route');
|
|
7
|
+
|
|
8
|
+
/** 定义路由 */
|
|
9
|
+
function defineRoute(route: (params: { definePage: typeof definePage }) => RouteRecordRaw[]) {
|
|
10
|
+
const routeFn: any = () => route({ definePage });
|
|
11
|
+
routeFn[RouteSymbol] = true;
|
|
12
|
+
|
|
13
|
+
return routeFn;
|
|
14
|
+
}
|