@peng_kai/kit 0.2.0-beta.29 → 0.2.0-beta.30

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.
@@ -1,153 +1,153 @@
1
- <script lang="ts" setup>
2
- import { computed, ref } from 'vue';
3
- import { Button as AButton, Drawer as ADrawer, Dropdown as ADropdown } from 'ant-design-vue';
4
-
5
- defineOptions({
6
- inheritAttrs: false,
7
- });
8
-
9
- const props = withDefaults(defineProps<{
10
- loading?: boolean
11
- filterQuery?: any
12
- filterParams?: any
13
- filterForm?: any
14
- }>(), {
15
- loading: undefined,
16
- });
17
- const emits = defineEmits<{
18
- (e: 'filter'): void
19
- (e: 'reset', value: number): void
20
- }>();
21
-
22
- const filterVisible = ref(false);
23
- const loading = computed(() => {
24
- const _loading1 = props.loading;
25
- const _loading2: boolean = props.filterQuery?.isFetching.value;
26
-
27
- if (_loading1 === undefined && _loading2 === undefined)
28
- return false;
29
-
30
- if (_loading1 !== undefined)
31
- return _loading1;
32
-
33
- return _loading2;
34
- });
35
-
36
- function filter() {
37
- props.filterParams?.update?.();
38
- emits('filter');
39
- filterVisible.value = false;
40
- }
41
-
42
- function reset() {
43
- props.filterForm?.$form.resetFields?.();
44
- props.filterParams?.update?.();
45
- emits('reset', 1);
46
- filterVisible.value = false;
47
- }
48
- </script>
49
-
50
- <template>
51
- <div class="p-3 bg-$antd-colorBgContainer text-14px rounded-2" v-bind="$attrs">
52
- <!-- .filter-params 为空时显示 .filter-params-tips -->
53
-
54
- <div class="m--3 p-3" @click="filterVisible = true">
55
- <div class="filter-params">
56
- <slot name="params" />
57
- </div>
58
- <div class="filter-params-tips">
59
- 条件筛选,点击打开
60
- </div>
61
- </div>
62
-
63
- <!-- 操作区 -->
64
- <div v-if="$slots.actions || $slots.moreActions" class="actions">
65
- <slot name="actions" />
66
-
67
- <ADropdown v-if="$slots.moreActions" trigger="click" destroyPopupOnHide>
68
- <AButton type="link" size="small">
69
- 更多
70
- </AButton>
71
- <template #overlay>
72
- <slot name="moreActions" />
73
- </template>
74
- </ADropdown>
75
- </div>
76
- </div>
77
-
78
- <ADrawer
79
- v-model:open="filterVisible" class="filter-drawer" placement="bottom"
80
- height="50vh"
81
- >
82
- <template #extra>
83
- <AButton class="mr-3 my--3" :disabled="loading" @click="reset()">
84
- 重置
85
- </AButton>
86
- <AButton class="my--3" type="primary" :loading="loading" @click="filter()">
87
- 筛选
88
- </AButton>
89
- </template>
90
- <template #default>
91
- <slot />
92
- </template>
93
- </ADrawer>
94
- </template>
95
-
96
- <style scoped lang="scss">
97
- .filter-params {
98
- display: flex;
99
- flex-wrap: wrap;
100
- justify-content: flex-start;
101
- gap: 5px 15px;
102
- }
103
-
104
- // .filter-params 为空时显示 .filter-params-tips
105
- .filter-params-tips {
106
- display: none;
107
- color: theme('colors.gray.DEFAULT');
108
- }
109
-
110
- .filter-params:empty {
111
- display: none;
112
- }
113
-
114
- .filter-params:empty + .filter-params-tips {
115
- display: block;
116
- }
117
-
118
- .actions {
119
- display: flex;
120
- align-items: center;
121
- justify-content: flex-end;
122
- border-top: 1px solid var(--antd-colorBorderSecondary);
123
- margin-top: 0.75rem;
124
- padding-top: 0.75rem;
125
- }
126
- </style>
127
-
128
- <style lang="scss">
129
- .filter-drawer {
130
- .ant-drawer-header {
131
- padding: 16px;
132
-
133
- .ant-drawer-close {
134
- --expand: 5px;
135
-
136
- padding: var(--expand);
137
- margin: calc(var(--expand) * -1) var(--expand) calc(var(--expand) * -1) 0;
138
- }
139
- }
140
-
141
- .ant-drawer-body {
142
- padding: 16px;
143
- }
144
-
145
- .ant-form-item {
146
- margin-bottom: 0;
147
-
148
- .ant-form-item-label {
149
- padding-bottom: 0;
150
- }
151
- }
152
- }
153
- </style>
1
+ <script lang="ts" setup>
2
+ import { computed, ref } from 'vue';
3
+ import { Button as AButton, Drawer as ADrawer, Dropdown as ADropdown } from 'ant-design-vue';
4
+
5
+ defineOptions({
6
+ inheritAttrs: false,
7
+ });
8
+
9
+ const props = withDefaults(defineProps<{
10
+ loading?: boolean
11
+ filterQuery?: any
12
+ filterParams?: any
13
+ filterForm?: any
14
+ }>(), {
15
+ loading: undefined,
16
+ });
17
+ const emits = defineEmits<{
18
+ (e: 'filter'): void
19
+ (e: 'reset', value: number): void
20
+ }>();
21
+
22
+ const filterVisible = ref(false);
23
+ const loading = computed(() => {
24
+ const _loading1 = props.loading;
25
+ const _loading2: boolean = props.filterQuery?.isFetching.value;
26
+
27
+ if (_loading1 === undefined && _loading2 === undefined)
28
+ return false;
29
+
30
+ if (_loading1 !== undefined)
31
+ return _loading1;
32
+
33
+ return _loading2;
34
+ });
35
+
36
+ function filter() {
37
+ props.filterParams?.update?.();
38
+ emits('filter');
39
+ filterVisible.value = false;
40
+ }
41
+
42
+ function reset() {
43
+ props.filterForm?.$form.resetFields?.();
44
+ props.filterParams?.update?.();
45
+ emits('reset', 1);
46
+ filterVisible.value = false;
47
+ }
48
+ </script>
49
+
50
+ <template>
51
+ <div class="p-3 bg-$antd-colorBgContainer text-14px rounded-2" v-bind="$attrs">
52
+ <!-- .filter-params 为空时显示 .filter-params-tips -->
53
+
54
+ <div class="m--3 p-3" @click="filterVisible = true">
55
+ <div class="filter-params">
56
+ <slot name="params" />
57
+ </div>
58
+ <div class="filter-params-tips">
59
+ 条件筛选,点击打开
60
+ </div>
61
+ </div>
62
+
63
+ <!-- 操作区 -->
64
+ <div v-if="$slots.actions || $slots.moreActions" class="actions">
65
+ <slot name="actions" />
66
+
67
+ <ADropdown v-if="$slots.moreActions" trigger="click" destroyPopupOnHide>
68
+ <AButton type="link" size="small">
69
+ 更多
70
+ </AButton>
71
+ <template #overlay>
72
+ <slot name="moreActions" />
73
+ </template>
74
+ </ADropdown>
75
+ </div>
76
+ </div>
77
+
78
+ <ADrawer
79
+ v-model:open="filterVisible" class="filter-drawer" placement="bottom"
80
+ height="50vh"
81
+ >
82
+ <template #extra>
83
+ <AButton class="mr-3 my--3" :disabled="loading" @click="reset()">
84
+ 重置
85
+ </AButton>
86
+ <AButton class="my--3" type="primary" :loading="loading" @click="filter()">
87
+ 筛选
88
+ </AButton>
89
+ </template>
90
+ <template #default>
91
+ <slot />
92
+ </template>
93
+ </ADrawer>
94
+ </template>
95
+
96
+ <style scoped lang="scss">
97
+ .filter-params {
98
+ display: flex;
99
+ flex-wrap: wrap;
100
+ justify-content: flex-start;
101
+ gap: 5px 15px;
102
+ }
103
+
104
+ // .filter-params 为空时显示 .filter-params-tips
105
+ .filter-params-tips {
106
+ display: none;
107
+ color: theme('colors.gray.DEFAULT');
108
+ }
109
+
110
+ .filter-params:empty {
111
+ display: none;
112
+ }
113
+
114
+ .filter-params:empty + .filter-params-tips {
115
+ display: block;
116
+ }
117
+
118
+ .actions {
119
+ display: flex;
120
+ align-items: center;
121
+ justify-content: flex-end;
122
+ border-top: 1px solid var(--antd-colorBorderSecondary);
123
+ margin-top: 0.75rem;
124
+ padding-top: 0.75rem;
125
+ }
126
+ </style>
127
+
128
+ <style lang="scss">
129
+ .filter-drawer {
130
+ .ant-drawer-header {
131
+ padding: 16px;
132
+
133
+ .ant-drawer-close {
134
+ --expand: 5px;
135
+
136
+ padding: var(--expand);
137
+ margin: calc(var(--expand) * -1) var(--expand) calc(var(--expand) * -1) 0;
138
+ }
139
+ }
140
+
141
+ .ant-drawer-body {
142
+ padding: 16px;
143
+ }
144
+
145
+ .ant-form-item {
146
+ margin-bottom: 0;
147
+
148
+ .ant-form-item-label {
149
+ padding-bottom: 0;
150
+ }
151
+ }
152
+ }
153
+ </style>
@@ -1 +1 @@
1
- export { default as ScrollNav } from './src/ScrollNav.vue';
1
+ export { default as ScrollNav } from './src/ScrollNav.vue';
@@ -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';
5
-
6
- export { createTagGetter } from './src/createTagGetter';
7
-
8
- export const Text = {
9
- Hash,
10
- Amount,
11
- Datetime,
12
- Duration,
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';
5
+
6
+ export { createTagGetter } from './src/createTagGetter';
7
+
8
+ export const Text = {
9
+ Hash,
10
+ Amount,
11
+ Datetime,
12
+ Duration,
13
+ };
@@ -1,121 +1,121 @@
1
- <script lang="ts">
2
- import { computed } from 'vue';
3
- import bigNumber from 'bignumber.js';
4
- import isNil from 'lodash-es/isNil';
5
-
6
- export const config = {
7
- aboveColor: '#52c41a',
8
- belowColor: '#ff4d4f',
9
- };
10
-
11
- /**
12
- * 当 symbol 为以下值时,使用预设的 Logo
13
- */
14
- const presetSymbols: Record<string, string> = {
15
- USDT: 'https://api.iconify.design/cryptocurrency-color:usdt.svg',
16
- TRX: 'https://api.iconify.design/cryptocurrency-color:trx.svg',
17
- USDC: 'https://api.iconify.design/cryptocurrency-color:usdc.svg',
18
- ETH: 'https://api.iconify.design/cryptocurrency-color:eth.svg',
19
- BNB: 'https://api.iconify.design/cryptocurrency-color:bnb.svg',
20
- BUSD: 'https://assets.coingecko.com/coins/images/9576/large/BUSD.png',
21
- MATIC: 'https://api.iconify.design/cryptocurrency-color:matic.svg',
22
- SOL: 'https://api.iconify.design/cryptocurrency-color:sol.svg',
23
- };
24
- </script>
25
-
26
- <script setup lang="ts">
27
- const props = withDefaults(
28
- defineProps<{
29
- /** 金额 */
30
- amount?: string | number
31
- /** 符号Logo, 可以是币种Logo的URL、法定货币符号($) */
32
- symbol?: string
33
- /** 精度 */
34
- precision?: number
35
- /** 单位,如币种名称 */
36
- unit?: string
37
- /** 保留小数的位数 */
38
- fractionDigits?: number
39
- /** 是否填充 0 */
40
- padZero?: boolean
41
- /** 金额是否红/绿显示 */
42
- colorful?: boolean
43
- /** 是否是大约数 */
44
- approx?: boolean
45
- }>(),
46
- {
47
- padZero: false,
48
- fractionDigits: 18,
49
- colorful: false,
50
- },
51
- );
52
-
53
- const amountText = computed(() => {
54
- const _amount = props.amount;
55
-
56
- if (isNil(_amount))
57
- return '-';
58
-
59
- let bn = bigNumber(_amount);
60
- bn = !isNil(props.precision) ? bn.dividedBy(10 ** props.precision) : bn;
61
- let bnt = bn.toFormat(props.fractionDigits);
62
- bnt = props.padZero ? bnt : bnt.replace(/\.?0+$/, '');
63
-
64
- return bnt;
65
- });
66
- const amountColor = computed(() => {
67
- const num = Number.parseFloat(props.amount as string);
68
-
69
- if (!props.colorful || (Number.isNaN(num) ? true : num === 0))
70
- return '';
71
-
72
- return num > 0 ? config.aboveColor : (num < 0 ? config.belowColor : '');
73
- });
74
- const symbol = computed(() => presetSymbols[props.symbol!] ?? props.symbol ?? '');
75
- </script>
76
-
77
- <template>
78
- <div class="amount-wrapper" :style="{ '--amount-color': amountColor }">
79
- <!-- 约等于 -->
80
- <span v-if="props.approx" class="color-$amount-color">≈</span>
81
-
82
- <!-- 符号 -->
83
- <img v-if="symbol.startsWith('http')" class="symbol-logo" :src="symbol">
84
-
85
- <!-- 图片Logo -->
86
- <span v-else class="color-$amount-color">{{ symbol }}</span> <!-- 文本Logo,如法定币种符号(¥、$) -->
87
-
88
- <!-- 金额 -->
89
- <span class="color-$amount-color amount">{{ amountText }}</span>
90
-
91
- <!-- 单位 -->
92
- <span v-if="props.unit" class="unit">{{ props.unit }}</span>
93
- </div>
94
- </template>
95
-
96
- <style lang="scss">
97
- .amount-wrapper {
98
- display: flex;
99
- align-items: center;
100
-
101
- .symbol-logo {
102
- display: block;
103
- width: 1.1em;
104
- height: 1.1em;
105
- margin-right: 0.2em;
106
- }
107
-
108
- .amount {
109
- font-family: 'dinm';
110
- }
111
-
112
- .currency-name {
113
- margin-left: 0.2em;
114
- }
115
-
116
- .unit {
117
- display: inline-block;
118
- margin-left: 0.2em;
119
- }
120
- }
121
- </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
+ export const config = {
7
+ aboveColor: '#52c41a',
8
+ belowColor: '#ff4d4f',
9
+ };
10
+
11
+ /**
12
+ * 当 symbol 为以下值时,使用预设的 Logo
13
+ */
14
+ const presetSymbols: Record<string, string> = {
15
+ USDT: 'https://api.iconify.design/cryptocurrency-color:usdt.svg',
16
+ TRX: 'https://api.iconify.design/cryptocurrency-color:trx.svg',
17
+ USDC: 'https://api.iconify.design/cryptocurrency-color:usdc.svg',
18
+ ETH: 'https://api.iconify.design/cryptocurrency-color:eth.svg',
19
+ BNB: 'https://api.iconify.design/cryptocurrency-color:bnb.svg',
20
+ BUSD: 'https://assets.coingecko.com/coins/images/9576/large/BUSD.png',
21
+ MATIC: 'https://api.iconify.design/cryptocurrency-color:matic.svg',
22
+ SOL: 'https://api.iconify.design/cryptocurrency-color:sol.svg',
23
+ };
24
+ </script>
25
+
26
+ <script setup lang="ts">
27
+ const props = withDefaults(
28
+ defineProps<{
29
+ /** 金额 */
30
+ amount?: string | number
31
+ /** 符号Logo, 可以是币种Logo的URL、法定货币符号($) */
32
+ symbol?: string
33
+ /** 精度 */
34
+ precision?: number
35
+ /** 单位,如币种名称 */
36
+ unit?: string
37
+ /** 保留小数的位数 */
38
+ fractionDigits?: number
39
+ /** 是否填充 0 */
40
+ padZero?: boolean
41
+ /** 金额是否红/绿显示 */
42
+ colorful?: boolean
43
+ /** 是否是大约数 */
44
+ approx?: boolean
45
+ }>(),
46
+ {
47
+ padZero: false,
48
+ fractionDigits: 18,
49
+ colorful: false,
50
+ },
51
+ );
52
+
53
+ const amountText = computed(() => {
54
+ const _amount = props.amount;
55
+
56
+ if (isNil(_amount))
57
+ return '-';
58
+
59
+ let bn = bigNumber(_amount);
60
+ bn = !isNil(props.precision) ? bn.dividedBy(10 ** props.precision) : bn;
61
+ let bnt = bn.toFormat(props.fractionDigits);
62
+ bnt = props.padZero ? bnt : bnt.replace(/\.?0+$/, '');
63
+
64
+ return bnt;
65
+ });
66
+ const amountColor = computed(() => {
67
+ const num = Number.parseFloat(props.amount as string);
68
+
69
+ if (!props.colorful || (Number.isNaN(num) ? true : num === 0))
70
+ return '';
71
+
72
+ return num > 0 ? config.aboveColor : (num < 0 ? config.belowColor : '');
73
+ });
74
+ const symbol = computed(() => presetSymbols[props.symbol!] ?? props.symbol ?? '');
75
+ </script>
76
+
77
+ <template>
78
+ <div class="amount-wrapper" :style="{ '--amount-color': amountColor }">
79
+ <!-- 约等于 -->
80
+ <span v-if="props.approx" class="color-$amount-color">≈</span>
81
+
82
+ <!-- 符号 -->
83
+ <img v-if="symbol.startsWith('http')" class="symbol-logo" :src="symbol">
84
+
85
+ <!-- 图片Logo -->
86
+ <span v-else class="color-$amount-color">{{ symbol }}</span> <!-- 文本Logo,如法定币种符号(¥、$) -->
87
+
88
+ <!-- 金额 -->
89
+ <span class="color-$amount-color amount">{{ amountText }}</span>
90
+
91
+ <!-- 单位 -->
92
+ <span v-if="props.unit" class="unit">{{ props.unit }}</span>
93
+ </div>
94
+ </template>
95
+
96
+ <style lang="scss">
97
+ .amount-wrapper {
98
+ display: flex;
99
+ align-items: center;
100
+
101
+ .symbol-logo {
102
+ display: block;
103
+ width: 1.1em;
104
+ height: 1.1em;
105
+ margin-right: 0.2em;
106
+ }
107
+
108
+ .amount {
109
+ font-family: 'dinm';
110
+ }
111
+
112
+ .currency-name {
113
+ margin-left: 0.2em;
114
+ }
115
+
116
+ .unit {
117
+ display: inline-block;
118
+ margin-left: 0.2em;
119
+ }
120
+ }
121
+ </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>