@peng_kai/kit 0.3.0-beta.21 → 0.3.0-beta.23

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.
@@ -78,7 +78,7 @@ const current = customRef((track, trigger) => {
78
78
  <Select class="tta-tz-select" v-model:value="current" :bordered="false" :virtual="false"
79
79
  :dropdownMatchSelectWidth="120" :options="offsetOptions">
80
80
  <template #suffixIcon>
81
- <i class="i-iconoir:time-zone text-5 text-white" />
81
+ <i class="i-iconoir:time-zone text-5 text-$antd-colorTextBase" />
82
82
  </template>
83
83
  </Select>
84
84
  </template>
@@ -25,7 +25,7 @@ const props = withDefaults(
25
25
  modelValue: string;
26
26
  disabled?: boolean;
27
27
  plugins?: string[];
28
- height: string;
28
+ height?: string;
29
29
  }>(),
30
30
  {
31
31
  disabled: false,
@@ -28,14 +28,21 @@ interface TNotice {
28
28
 
29
29
  <script lang="ts" setup>
30
30
  const props = defineProps<{
31
- noticesQry: UseQueryReturnType<TNotice[], Error>
31
+ noticesQry: UseQueryReturnType<{num: number; list: TNotice[]}, Error>
32
+ onOpen?: (item: TNotice) => void;
32
33
  }>()
33
34
 
34
35
  const router = useRouter();
35
36
  const visible = ref(false);
36
- const noticeNum = computed(() => props.noticesQry.data.value?.length ?? 0);
37
+ const noticeNum = computed(() => props.noticesQry.data.value?.num ?? 0);
38
+ const noticeList = computed(() => props.noticesQry.data.value?.list ?? []);
37
39
 
38
40
  function operate(notice: TNotice) {
41
+ if (props.onOpen) {
42
+ props.onOpen(notice);
43
+ return;
44
+ }
45
+
39
46
  if (router.currentRoute.value.path !== notice.url) {
40
47
  router.push(notice.url);
41
48
  }
@@ -87,11 +94,11 @@ useIntervalFn(() => {
87
94
  </div>
88
95
  <template #overlay>
89
96
  <Menu v-if="noticeNum" @click="visible = false" class="max-h-100 overflow-y-auto">
90
- <MenuItem v-for="(item, i) of noticesQry.data.value" :key="i" @click="operate(item)">
97
+ <MenuItem v-for="(item, i) of noticeList" :key="i" @click="operate(item)">
91
98
  <div class="min-w-50">
92
99
  <div>{{ item.title }}</div>
93
100
  <div class="mt-1 text-xs text-$antd-colorTextSecondary">
94
- {{ dayjs().format('MM-DD HH:mm:ss') }}
101
+ {{ dayjs(item.time).format('MM-DD HH:mm:ss') }}
95
102
  </div>
96
103
  </div>
97
104
  </MenuItem>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peng_kai/kit",
3
3
  "type": "module",
4
- "version": "0.3.0-beta.21",
4
+ "version": "0.3.0-beta.23",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "ISC",
package/utils/number.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { BigNumber } from 'bignumber.js';
2
1
  import bn from 'bignumber.js';
3
2
 
4
3
  export { default as bn } from 'bignumber.js';
@@ -22,42 +21,42 @@ export const numFmt = {
22
21
  /** 舍去小数,四舍五入,千位符 */
23
22
  d0r5t: (num: any, fallback: any = 'NaN') => {
24
23
  const result = bn(num);
25
- return result.isNaN() ? fallback : result.decimalPlaces(0, bn.ROUND_HALF_UP).toFormat(0);
24
+ return result.isNaN() ? fallback : result.decimalPlaces(0, bn.ROUND_HALF_UP).toFormat();
26
25
  },
27
26
  /** 舍去小数,向下取整,千位符 */
28
27
  d0r0t: (num: any, fallback: any = 'NaN') => {
29
28
  const result = bn(num);
30
- return result.isNaN() ? fallback : result.decimalPlaces(0, bn.ROUND_DOWN).toFormat(0);
29
+ return result.isNaN() ? fallback : result.decimalPlaces(0, bn.ROUND_DOWN).toFormat();
31
30
  },
32
31
  /** 保留2位小数,四舍五入,千位符 */
33
32
  d2r5t: (num: any, fallback: any = 'NaN') => {
34
33
  const result = bn(num);
35
- return result.isNaN() ? fallback : result.decimalPlaces(2, bn.ROUND_HALF_UP).toFormat(2);
34
+ return result.isNaN() ? fallback : result.decimalPlaces(2, bn.ROUND_HALF_UP).toFormat();
36
35
  },
37
36
  /** 保留2位小数,向下取整,千位符 */
38
37
  d2r0t: (num: any, fallback: any = 'NaN') => {
39
38
  const result = bn(num);
40
- return result.isNaN() ? fallback : result.decimalPlaces(2, bn.ROUND_DOWN).toFormat(2);
39
+ return result.isNaN() ? fallback : result.decimalPlaces(2, bn.ROUND_DOWN).toFormat();
41
40
  },
42
41
  /** 保留6位小数,四舍五入,千位符 */
43
42
  d6r5t: (num: any, fallback: any = 'NaN') => {
44
43
  const result = bn(num);
45
- return result.isNaN() ? fallback : result.decimalPlaces(6, bn.ROUND_HALF_UP).toFormat(6);
44
+ return result.isNaN() ? fallback : result.decimalPlaces(6, bn.ROUND_HALF_UP).toFormat();
46
45
  },
47
46
  /** 保留6位小数,向下取整,千位符 */
48
47
  d6r0t: (num: any, fallback: any = 'NaN') => {
49
48
  const result = bn(num);
50
- return result.isNaN() ? fallback : result.decimalPlaces(6, bn.ROUND_DOWN).toFormat(6);
49
+ return result.isNaN() ? fallback : result.decimalPlaces(6, bn.ROUND_DOWN).toFormat();
51
50
  },
52
51
  /** 保留8位小数,四舍五入,千位符 */
53
52
  d8r5t: (num: any, fallback: any = 'NaN') => {
54
53
  const result = bn(num);
55
- return result.isNaN() ? fallback : result.decimalPlaces(8, bn.ROUND_HALF_UP).toFormat(8);
54
+ return result.isNaN() ? fallback : result.decimalPlaces(8, bn.ROUND_HALF_UP).toFormat();
56
55
  },
57
56
  /** 保留8位小数,向下取整,千位符 */
58
57
  d8r0t: (num: any, fallback: any = 'NaN') => {
59
58
  const result = bn(num);
60
- return result.isNaN() ? fallback : result.decimalPlaces(8, bn.ROUND_DOWN).toFormat(8);
59
+ return result.isNaN() ? fallback : result.decimalPlaces(8, bn.ROUND_DOWN).toFormat();
61
60
  },
62
61
  };
63
62