@peng_kai/kit 0.1.4 → 0.1.6

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.
Files changed (51) hide show
  1. package/admin/components/filter/src/FilterDrawer.vue +153 -153
  2. package/admin/components/filter/src/FilterParam.vue +76 -76
  3. package/admin/components/filter/src/FilterReset.vue +2 -2
  4. package/admin/components/filter/src/useFilterParams.ts +9 -0
  5. package/admin/components/scroll-nav/index.ts +1 -1
  6. package/admin/components/scroll-nav/src/ScrollNav.vue +59 -59
  7. package/admin/components/text/index.ts +13 -13
  8. package/admin/components/text/src/Amount.vue +117 -117
  9. package/admin/components/text/src/Datetime.vue +48 -48
  10. package/admin/components/text/src/Duration.vue +26 -26
  11. package/admin/components/text/src/Hash.vue +51 -51
  12. package/admin/components/text/src/createTagGetter.ts +13 -13
  13. package/admin/hooks/useMenu.ts +128 -128
  14. package/admin/hooks/usePage.ts +141 -141
  15. package/admin/hooks/usePageTab.ts +35 -35
  16. package/admin/layout/large/Breadcrumb.vue +69 -69
  17. package/admin/layout/large/Content.vue +24 -24
  18. package/admin/layout/large/Menu.vue +69 -69
  19. package/admin/layout/large/PageTab.vue +71 -71
  20. package/admin/permission/index.ts +4 -4
  21. package/admin/permission/routerGuard.ts +43 -43
  22. package/admin/permission/usePermission.ts +52 -52
  23. package/admin/permission/vuePlugin.ts +30 -30
  24. package/admin/route-guards/index.ts +3 -3
  25. package/admin/route-guards/pageProgress.ts +27 -27
  26. package/admin/route-guards/pageTitle.ts +19 -19
  27. package/admin/styles/classCover.scss +59 -2
  28. package/admin/styles/globalCover.scss +54 -54
  29. package/admin/types/assist.ts +2 -2
  30. package/antd/components/InputNumberRange.vue +53 -53
  31. package/antd/directives/formLabelAlign.ts +36 -36
  32. package/antd/hooks/useAntdDrawer.ts +73 -73
  33. package/antd/hooks/useAntdTable.ts +82 -71
  34. package/package.json +55 -54
  35. package/request/helpers.ts +49 -49
  36. package/request/interceptors/toLogin.ts +15 -15
  37. package/request/type.d.ts +92 -92
  38. package/stylelint.config.cjs +7 -7
  39. package/tsconfig.json +50 -50
  40. package/utils/date.ts +44 -0
  41. package/utils/index.ts +14 -8
  42. package/utils/number.ts +49 -0
  43. package/vue/components/infinite-query/index.ts +1 -1
  44. package/vue/components/infinite-query/src/InfiniteQuery.vue +205 -205
  45. package/vue/components/infinite-query/src/useCreateTrigger.ts +39 -39
  46. package/vue/hooks/useComponentRef.ts +7 -1
  47. package/vue/hooks/useIsDark.ts +5 -0
  48. package/vue/hooks/useIsMounted.ts +3 -0
  49. package/vue/hooks/useTeleportTarget.ts +35 -2
  50. package/vue/index.ts +1 -1
  51. package/pnpm-lock.yaml +0 -5242
@@ -1,117 +1,117 @@
1
- <script lang="ts">
2
- import { computed } from 'vue';
3
- import bigNumber from 'bignumber.js';
4
- import isNil from 'lodash-es/isNil';
5
-
6
- /**
7
- * 当 symbol 为以下值时,使用预设的 Logo
8
- */
9
- const presetSymbols: Record<string, string> = {
10
- USDT: 'https://api.iconify.design/cryptocurrency-color:usdt.svg',
11
- TRX: 'https://api.iconify.design/cryptocurrency-color:trx.svg',
12
- USDC: 'https://api.iconify.design/cryptocurrency-color:usdc.svg',
13
- ETH: 'https://api.iconify.design/cryptocurrency-color:eth.svg',
14
- BNB: 'https://api.iconify.design/cryptocurrency-color:bnb.svg',
15
- BUSD: 'https://assets.coingecko.com/coins/images/9576/large/BUSD.png',
16
- MATIC: 'https://api.iconify.design/cryptocurrency-color:matic.svg',
17
- SOL: 'https://api.iconify.design/cryptocurrency-color:sol.svg',
18
- };
19
- </script>
20
-
21
- <script setup lang="ts">
22
- const props = withDefaults(
23
- defineProps<{
24
- /** 金额 */
25
- amount?: string | number
26
- /** 符号Logo, 可以是币种Logo的URL、法定货币符号($) */
27
- symbol?: string
28
- /** 精度 */
29
- precision?: number
30
- /** 单位,如币种名称 */
31
- unit?: string
32
- /** 保留小数的位数 */
33
- fractionDigits?: number
34
- /** 是否填充 0 */
35
- padZero?: boolean
36
- /** 金额是否红/绿显示 */
37
- colorful?: boolean
38
- /** 是否是大约数 */
39
- approx?: boolean
40
- }>(),
41
- {
42
- padZero: false,
43
- fractionDigits: 18,
44
- colorful: false,
45
- },
46
- );
47
-
48
- const amountText = computed(() => {
49
- const _amount = props.amount;
50
-
51
- if (isNil(_amount))
52
- return '-';
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+$/, '');
58
-
59
- return bnt;
60
- });
61
- const amountColor = computed(() => {
62
- const num = Number.parseFloat(props.amount as string);
63
-
64
- if (!props.colorful || (Number.isNaN(num) ? true : num === 0))
65
- return '';
66
-
67
- return num > 0 ? '#52c41a' : (num < 0 ? '#ff4d4f' : '#000');
68
- });
69
- const symbol = computed(() => presetSymbols[props.symbol!] ?? props.symbol ?? '');
70
- </script>
71
-
72
- <template>
73
- <div class="amount-wrapper" :style="{ '--amount-color': amountColor }">
74
- <!-- 约等于 -->
75
- <span v-if="props.approx" class="color-$amount-color">≈</span>
76
-
77
- <!-- 符号 -->
78
- <img
79
- v-if="symbol.startsWith('http')" class="symbol-logo" :src="symbol"
80
- :alt="props.unit"
81
- > <!-- 图片Logo -->
82
- <span v-else class="color-$amount-color">{{ symbol }}</span> <!-- 文本Logo,如法定币种符号(¥、$) -->
83
-
84
- <!-- 金额 -->
85
- <span class="color-$amount-color amount">{{ amountText }}</span>
86
-
87
- <!-- 单位 -->
88
- <span v-if="props.unit" class="unit">{{ props.unit }}</span>
89
- </div>
90
- </template>
91
-
92
- <style lang="scss">
93
- .amount-wrapper {
94
- display: flex;
95
- align-items: center;
96
-
97
- .symbol-logo {
98
- display: block;
99
- width: 1.1em;
100
- height: 1.1em;
101
- margin-right: 0.2em;
102
- }
103
-
104
- .amount {
105
- font-family: 'dinm';
106
- }
107
-
108
- .currency-name {
109
- margin-left: 0.2em;
110
- }
111
-
112
- .unit {
113
- display: inline-block;
114
- margin-left: 0.2em;
115
- }
116
- }
117
- </style>
1
+ <script lang="ts">
2
+ import { computed } from 'vue';
3
+ import bigNumber from 'bignumber.js';
4
+ import isNil from 'lodash-es/isNil';
5
+
6
+ /**
7
+ * 当 symbol 为以下值时,使用预设的 Logo
8
+ */
9
+ const presetSymbols: Record<string, string> = {
10
+ USDT: 'https://api.iconify.design/cryptocurrency-color:usdt.svg',
11
+ TRX: 'https://api.iconify.design/cryptocurrency-color:trx.svg',
12
+ USDC: 'https://api.iconify.design/cryptocurrency-color:usdc.svg',
13
+ ETH: 'https://api.iconify.design/cryptocurrency-color:eth.svg',
14
+ BNB: 'https://api.iconify.design/cryptocurrency-color:bnb.svg',
15
+ BUSD: 'https://assets.coingecko.com/coins/images/9576/large/BUSD.png',
16
+ MATIC: 'https://api.iconify.design/cryptocurrency-color:matic.svg',
17
+ SOL: 'https://api.iconify.design/cryptocurrency-color:sol.svg',
18
+ };
19
+ </script>
20
+
21
+ <script setup lang="ts">
22
+ const props = withDefaults(
23
+ defineProps<{
24
+ /** 金额 */
25
+ amount?: string | number
26
+ /** 符号Logo, 可以是币种Logo的URL、法定货币符号($) */
27
+ symbol?: string
28
+ /** 精度 */
29
+ precision?: number
30
+ /** 单位,如币种名称 */
31
+ unit?: string
32
+ /** 保留小数的位数 */
33
+ fractionDigits?: number
34
+ /** 是否填充 0 */
35
+ padZero?: boolean
36
+ /** 金额是否红/绿显示 */
37
+ colorful?: boolean
38
+ /** 是否是大约数 */
39
+ approx?: boolean
40
+ }>(),
41
+ {
42
+ padZero: false,
43
+ fractionDigits: 18,
44
+ colorful: false,
45
+ },
46
+ );
47
+
48
+ const amountText = computed(() => {
49
+ const _amount = props.amount;
50
+
51
+ if (isNil(_amount))
52
+ return '-';
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+$/, '');
58
+
59
+ return bnt;
60
+ });
61
+ const amountColor = computed(() => {
62
+ const num = Number.parseFloat(props.amount as string);
63
+
64
+ if (!props.colorful || (Number.isNaN(num) ? true : num === 0))
65
+ return '';
66
+
67
+ return num > 0 ? '#52c41a' : (num < 0 ? '#ff4d4f' : '#000');
68
+ });
69
+ const symbol = computed(() => presetSymbols[props.symbol!] ?? props.symbol ?? '');
70
+ </script>
71
+
72
+ <template>
73
+ <div class="amount-wrapper" :style="{ '--amount-color': amountColor }">
74
+ <!-- 约等于 -->
75
+ <span v-if="props.approx" class="color-$amount-color">≈</span>
76
+
77
+ <!-- 符号 -->
78
+ <img
79
+ v-if="symbol.startsWith('http')" class="symbol-logo" :src="symbol"
80
+ :alt="props.unit"
81
+ > <!-- 图片Logo -->
82
+ <span v-else class="color-$amount-color">{{ symbol }}</span> <!-- 文本Logo,如法定币种符号(¥、$) -->
83
+
84
+ <!-- 金额 -->
85
+ <span class="color-$amount-color amount">{{ amountText }}</span>
86
+
87
+ <!-- 单位 -->
88
+ <span v-if="props.unit" class="unit">{{ props.unit }}</span>
89
+ </div>
90
+ </template>
91
+
92
+ <style lang="scss">
93
+ .amount-wrapper {
94
+ display: flex;
95
+ align-items: center;
96
+
97
+ .symbol-logo {
98
+ display: block;
99
+ width: 1.1em;
100
+ height: 1.1em;
101
+ margin-right: 0.2em;
102
+ }
103
+
104
+ .amount {
105
+ font-family: 'dinm';
106
+ }
107
+
108
+ .currency-name {
109
+ margin-left: 0.2em;
110
+ }
111
+
112
+ .unit {
113
+ display: inline-block;
114
+ margin-left: 0.2em;
115
+ }
116
+ }
117
+ </style>
@@ -1,48 +1,48 @@
1
- <script setup lang="ts">
2
- import { Tooltip as ATooltip } from 'ant-design-vue';
3
- import { computed } from 'vue';
4
- import { getDependencies } from '../../../../kitDependencies';
5
-
6
- defineOptions({
7
- inheritAttrs: false,
8
- });
9
-
10
- const props = withDefaults(
11
- defineProps<{
12
- timestamp?: number | string
13
- template?: string
14
- }>(),
15
- {
16
- template: 'MM-DD HH:mm:ss',
17
- },
18
- );
19
- const { dayjs } = getDependencies()!;
20
- const timestamp = computed(() => {
21
- let tsStr = String(props.timestamp);
22
-
23
- if (tsStr.length === 10)
24
- tsStr += '000';
25
- if (tsStr.length !== 13)
26
- return;
27
-
28
- const tsNum = Number.parseInt(tsStr);
29
-
30
- return Number.isNaN(tsNum) ? undefined : tsNum;
31
- });
32
- </script>
33
-
34
- <template>
35
- <ATooltip destroyTooltipOnHide>
36
- <template v-if="timestamp" #title>
37
- <div>{{ dayjs(timestamp).fromNow?.() }}</div>
38
- <div>{{ dayjs(timestamp).format('YYYY-MM-DD HH:mm:ss') }}</div>
39
- </template>
40
- <span v-bind="$attrs" class="text">{{ timestamp ? dayjs(timestamp).format(props.template) : '-' }}</span>
41
- </ATooltip>
42
- </template>
43
-
44
- <style scoped lang="scss">
45
- .text {
46
- font-variant-numeric: tabular-nums;
47
- }
48
- </style>
1
+ <script setup lang="ts">
2
+ import { Tooltip as ATooltip } from 'ant-design-vue';
3
+ import { computed } from 'vue';
4
+ import { getDependencies } from '../../../../kitDependencies';
5
+
6
+ defineOptions({
7
+ inheritAttrs: false,
8
+ });
9
+
10
+ const props = withDefaults(
11
+ defineProps<{
12
+ timestamp?: number | string
13
+ template?: string
14
+ }>(),
15
+ {
16
+ template: 'MM-DD HH:mm:ss',
17
+ },
18
+ );
19
+ const { dayjs } = getDependencies()!;
20
+ const timestamp = computed(() => {
21
+ let tsStr = String(props.timestamp);
22
+
23
+ if (tsStr.length === 10)
24
+ tsStr += '000';
25
+ if (tsStr.length !== 13)
26
+ return;
27
+
28
+ const tsNum = Number.parseInt(tsStr);
29
+
30
+ return Number.isNaN(tsNum) ? undefined : tsNum;
31
+ });
32
+ </script>
33
+
34
+ <template>
35
+ <ATooltip destroyTooltipOnHide>
36
+ <template v-if="timestamp" #title>
37
+ <div>{{ dayjs(timestamp).fromNow?.() }}</div>
38
+ <div>{{ dayjs(timestamp).format('YYYY-MM-DD HH:mm:ss') }}</div>
39
+ </template>
40
+ <span v-bind="$attrs" class="text">{{ timestamp ? dayjs(timestamp).format(props.template) : '-' }}</span>
41
+ </ATooltip>
42
+ </template>
43
+
44
+ <style scoped lang="scss">
45
+ .text {
46
+ font-variant-numeric: tabular-nums;
47
+ }
48
+ </style>
@@ -1,26 +1,26 @@
1
- <script setup lang="ts">
2
- import { computed } from 'vue';
3
-
4
- const props = defineProps<{
5
- seconds: number
6
- }>();
7
-
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 = '';
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)}秒`);
19
-
20
- return formattedDuration;
21
- });
22
- </script>
23
-
24
- <template>
25
- <span>{{ formattedDuration }}</span>
26
- </template>
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue';
3
+
4
+ const props = defineProps<{
5
+ seconds: number
6
+ }>();
7
+
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 = '';
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)}秒`);
19
+
20
+ return formattedDuration;
21
+ });
22
+ </script>
23
+
24
+ <template>
25
+ <span>{{ formattedDuration }}</span>
26
+ </template>
@@ -1,51 +1,51 @@
1
- <script setup lang="ts">
2
- import { Tooltip as ATooltip, TypographyLink as ATypographyLink } from 'ant-design-vue';
3
- import { computed } from 'vue';
4
- import { desensitize, getScanBrowser } from '../../../../utils';
5
-
6
- type HashType = Parameters<typeof getScanBrowser>[2];
7
-
8
- defineOptions({
9
- inheritAttrs: false,
10
- });
11
-
12
- const props = withDefaults(
13
- defineProps<{
14
- hash: string
15
- hide?: boolean
16
- chain?: string
17
- type?: HashType
18
- empty?: string
19
- }>(),
20
- {
21
- hide: true,
22
- type: 'transaction',
23
- empty: '-',
24
- },
25
- );
26
-
27
- const href = computed(() => {
28
- const { hash, chain, type } = props;
29
-
30
- if (!hash || !chain || !type)
31
- return;
32
- return getScanBrowser(chain, hash, type);
33
- });
34
- const text = computed(() => {
35
- if (props.hash)
36
- return props.hide ? desensitize(props.hash) : props.hash;
37
- else
38
- return props.empty;
39
- });
40
- </script>
41
-
42
- <template>
43
- <ATypographyLink :href="href" :copyable="{ text: props.hash, tooltip: false }" target="_blank">
44
- <ATooltip>
45
- <template v-if="props.hide" #title>
46
- <span class="font-mono">{{ props.hash }}</span>
47
- </template>
48
- <span v-bind="$attrs"><slot><span class="font-mono">{{ text }}</span></slot></span>
49
- </ATooltip>
50
- </ATypographyLink>
51
- </template>
1
+ <script setup lang="ts">
2
+ import { Tooltip as ATooltip, TypographyLink as ATypographyLink } from 'ant-design-vue';
3
+ import { computed } from 'vue';
4
+ import { desensitize, getScanBrowser } from '../../../../utils';
5
+
6
+ type HashType = Parameters<typeof getScanBrowser>[2];
7
+
8
+ defineOptions({
9
+ inheritAttrs: false,
10
+ });
11
+
12
+ const props = withDefaults(
13
+ defineProps<{
14
+ hash: string
15
+ hide?: boolean
16
+ chain?: string
17
+ type?: HashType
18
+ empty?: string
19
+ }>(),
20
+ {
21
+ hide: true,
22
+ type: 'transaction',
23
+ empty: '-',
24
+ },
25
+ );
26
+
27
+ const href = computed(() => {
28
+ const { hash, chain, type } = props;
29
+
30
+ if (!hash || !chain || !type)
31
+ return;
32
+ return getScanBrowser(chain, hash, type);
33
+ });
34
+ const text = computed(() => {
35
+ if (props.hash)
36
+ return props.hide ? desensitize(props.hash) : props.hash;
37
+ else
38
+ return props.empty;
39
+ });
40
+ </script>
41
+
42
+ <template>
43
+ <ATypographyLink :href="href" :copyable="{ text: props.hash, tooltip: false }" target="_blank">
44
+ <ATooltip>
45
+ <template v-if="props.hide" #title>
46
+ <span class="font-mono">{{ props.hash }}</span>
47
+ </template>
48
+ <span v-bind="$attrs"><slot><span class="font-mono">{{ text }}</span></slot></span>
49
+ </ATooltip>
50
+ </ATypographyLink>
51
+ </template>
@@ -1,13 +1,13 @@
1
- import { computed, h } from 'vue';
2
- import { Tag as ATag } from 'ant-design-vue';
3
- import type { TagProps } from 'ant-design-vue';
4
-
5
- export function createTagGetter(typeMapFn: () => { [code: number | string]: [ text: string, color: TagProps['color'] ] }) {
6
- const typeMap = computed(typeMapFn);
7
-
8
- return (type: number) => {
9
- const [text, color] = typeMap.value[type] ?? [];
10
-
11
- return text ? h(ATag, { color }, () => text) : h('span', null, '-');
12
- };
13
- }
1
+ import { computed, h } from 'vue';
2
+ import { Tag as ATag } from 'ant-design-vue';
3
+ import type { TagProps } from 'ant-design-vue';
4
+
5
+ export function createTagGetter(typeMapFn: () => { [code: number | string]: [ text: string, color: TagProps['color'] ] }) {
6
+ const typeMap = computed(typeMapFn);
7
+
8
+ return (type: number) => {
9
+ const [text, color] = typeMap.value[type] ?? [];
10
+
11
+ return text ? h(ATag, { color }, () => text) : h('span', null, '-');
12
+ };
13
+ }