@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.
- package/admin/components/filter/src/FilterDrawer.vue +153 -153
- package/admin/components/filter/src/FilterParam.vue +76 -76
- package/admin/components/filter/src/FilterReset.vue +2 -2
- package/admin/components/filter/src/useFilterParams.ts +9 -0
- 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 +117 -117
- 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/classCover.scss +59 -2
- package/admin/styles/globalCover.scss +54 -54
- package/admin/types/assist.ts +2 -2
- package/antd/components/InputNumberRange.vue +53 -53
- package/antd/directives/formLabelAlign.ts +36 -36
- package/antd/hooks/useAntdDrawer.ts +73 -73
- package/antd/hooks/useAntdTable.ts +82 -71
- package/package.json +55 -54
- package/request/helpers.ts +49 -49
- package/request/interceptors/toLogin.ts +15 -15
- package/request/type.d.ts +92 -92
- package/stylelint.config.cjs +7 -7
- package/tsconfig.json +50 -50
- package/utils/date.ts +44 -0
- package/utils/index.ts +14 -8
- package/utils/number.ts +49 -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/vue/hooks/useComponentRef.ts +7 -1
- package/vue/hooks/useIsDark.ts +5 -0
- package/vue/hooks/useIsMounted.ts +3 -0
- package/vue/hooks/useTeleportTarget.ts +35 -2
- package/vue/index.ts +1 -1
- package/pnpm-lock.yaml +0 -5242
package/request/type.d.ts
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
declare namespace Api {
|
|
2
|
-
type Request = ((reqData: any, options?: Options) => Promise<any>) & {
|
|
3
|
-
id: string
|
|
4
|
-
setDefaultConfig: (config: Partial<import('axios').AxiosRequestConfig>) => Request
|
|
5
|
-
};
|
|
6
|
-
// type RequestPagination = (reqData: Partial<PageParam>, options?: Options) => Promise<PaginationData<any>>;
|
|
7
|
-
interface PageParam {
|
|
8
|
-
page: number
|
|
9
|
-
page_size: number
|
|
10
|
-
}
|
|
11
|
-
interface PageInfo {
|
|
12
|
-
has_more: boolean
|
|
13
|
-
page: number
|
|
14
|
-
page_size: number
|
|
15
|
-
total: number
|
|
16
|
-
}
|
|
17
|
-
interface PageData<T = any> {
|
|
18
|
-
list: T[] | null
|
|
19
|
-
pagination: PaginationInfo
|
|
20
|
-
[k in string]: any
|
|
21
|
-
}
|
|
22
|
-
interface Result<T = any | PageData<any>> {
|
|
23
|
-
code: number
|
|
24
|
-
msg: string
|
|
25
|
-
data: T
|
|
26
|
-
}
|
|
27
|
-
type GetParam<A extends Request> = A extends (reqData: infer R) => any ? R : any;
|
|
28
|
-
type GetData<A extends Request> = ReturnType<A> extends Promise<infer D> ? D : any;
|
|
29
|
-
type GetDataItem<A extends Request> = NonNullable<GetData<A>> extends { list: infer L }
|
|
30
|
-
? NonNullable<L> extends Array<infer I>
|
|
31
|
-
? I
|
|
32
|
-
: any
|
|
33
|
-
: any;
|
|
34
|
-
type GetDataField<R> = R extends { data: infer D } ? (D extends { list: any, pagination: any } ? D : D) : any;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 将api返回的分页数据转换成前端使用的分页数据格式,将分页数据格式统一
|
|
38
|
-
*
|
|
39
|
-
* ```
|
|
40
|
-
* {
|
|
41
|
-
* code: number,
|
|
42
|
-
* msg: string,
|
|
43
|
-
* data: {
|
|
44
|
-
* list: [],
|
|
45
|
-
* pagination: {},
|
|
46
|
-
* ...
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
type TransformPageResult<R> = R extends { pagination: infer P, data: infer D }
|
|
52
|
-
? D extends Record<string, any>
|
|
53
|
-
? D extends { list: any }
|
|
54
|
-
? {
|
|
55
|
-
[Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
|
|
56
|
-
} & {
|
|
57
|
-
data: D & { pagination: P }
|
|
58
|
-
}
|
|
59
|
-
: {
|
|
60
|
-
[Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
|
|
61
|
-
} & {
|
|
62
|
-
data: {
|
|
63
|
-
list: D
|
|
64
|
-
pagination: P
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
: R
|
|
68
|
-
: R;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 测试用例 ----------------------------
|
|
72
|
-
// type DDD1 = Api.TransformPageResult<{
|
|
73
|
-
// code: number
|
|
74
|
-
// msg: string
|
|
75
|
-
// data: {
|
|
76
|
-
// name: string
|
|
77
|
-
// }[]
|
|
78
|
-
// pagination: {
|
|
79
|
-
// page: number
|
|
80
|
-
// }
|
|
81
|
-
// }>
|
|
82
|
-
// type DDD2 = Api.TransformPageResult<{
|
|
83
|
-
// code: number
|
|
84
|
-
// msg: string
|
|
85
|
-
// data: {
|
|
86
|
-
// list: { name: string }[]
|
|
87
|
-
// total: {}
|
|
88
|
-
// }
|
|
89
|
-
// pagination: {
|
|
90
|
-
// page: number
|
|
91
|
-
// }
|
|
92
|
-
// }>
|
|
1
|
+
declare namespace Api {
|
|
2
|
+
type Request = ((reqData: any, options?: Options) => Promise<any>) & {
|
|
3
|
+
id: string
|
|
4
|
+
setDefaultConfig: (config: Partial<import('axios').AxiosRequestConfig>) => Request
|
|
5
|
+
};
|
|
6
|
+
// type RequestPagination = (reqData: Partial<PageParam>, options?: Options) => Promise<PaginationData<any>>;
|
|
7
|
+
interface PageParam {
|
|
8
|
+
page: number
|
|
9
|
+
page_size: number
|
|
10
|
+
}
|
|
11
|
+
interface PageInfo {
|
|
12
|
+
has_more: boolean
|
|
13
|
+
page: number
|
|
14
|
+
page_size: number
|
|
15
|
+
total: number
|
|
16
|
+
}
|
|
17
|
+
interface PageData<T = any> {
|
|
18
|
+
list: T[] | null
|
|
19
|
+
pagination: PaginationInfo
|
|
20
|
+
[k in string]: any
|
|
21
|
+
}
|
|
22
|
+
interface Result<T = any | PageData<any>> {
|
|
23
|
+
code: number
|
|
24
|
+
msg: string
|
|
25
|
+
data: T
|
|
26
|
+
}
|
|
27
|
+
type GetParam<A extends Request> = A extends (reqData: infer R) => any ? R : any;
|
|
28
|
+
type GetData<A extends Request> = ReturnType<A> extends Promise<infer D> ? D : any;
|
|
29
|
+
type GetDataItem<A extends Request> = NonNullable<GetData<A>> extends { list: infer L }
|
|
30
|
+
? NonNullable<L> extends Array<infer I>
|
|
31
|
+
? I
|
|
32
|
+
: any
|
|
33
|
+
: any;
|
|
34
|
+
type GetDataField<R> = R extends { data: infer D } ? (D extends { list: any, pagination: any } ? D : D) : any;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 将api返回的分页数据转换成前端使用的分页数据格式,将分页数据格式统一
|
|
38
|
+
*
|
|
39
|
+
* ```
|
|
40
|
+
* {
|
|
41
|
+
* code: number,
|
|
42
|
+
* msg: string,
|
|
43
|
+
* data: {
|
|
44
|
+
* list: [],
|
|
45
|
+
* pagination: {},
|
|
46
|
+
* ...
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
type TransformPageResult<R> = R extends { pagination: infer P, data: infer D }
|
|
52
|
+
? D extends Record<string, any>
|
|
53
|
+
? D extends { list: any }
|
|
54
|
+
? {
|
|
55
|
+
[Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
|
|
56
|
+
} & {
|
|
57
|
+
data: D & { pagination: P }
|
|
58
|
+
}
|
|
59
|
+
: {
|
|
60
|
+
[Rk in Exclude<keyof R, 'data' | 'pagination'>]: R[Rk];
|
|
61
|
+
} & {
|
|
62
|
+
data: {
|
|
63
|
+
list: D
|
|
64
|
+
pagination: P
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
: R
|
|
68
|
+
: R;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 测试用例 ----------------------------
|
|
72
|
+
// type DDD1 = Api.TransformPageResult<{
|
|
73
|
+
// code: number
|
|
74
|
+
// msg: string
|
|
75
|
+
// data: {
|
|
76
|
+
// name: string
|
|
77
|
+
// }[]
|
|
78
|
+
// pagination: {
|
|
79
|
+
// page: number
|
|
80
|
+
// }
|
|
81
|
+
// }>
|
|
82
|
+
// type DDD2 = Api.TransformPageResult<{
|
|
83
|
+
// code: number
|
|
84
|
+
// msg: string
|
|
85
|
+
// data: {
|
|
86
|
+
// list: { name: string }[]
|
|
87
|
+
// total: {}
|
|
88
|
+
// }
|
|
89
|
+
// pagination: {
|
|
90
|
+
// page: number
|
|
91
|
+
// }
|
|
92
|
+
// }>
|
package/stylelint.config.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
// root: true,
|
|
3
|
-
extends: ['@peng_kai/lint/vue/stylelint_v2'],
|
|
4
|
-
rules: {
|
|
5
|
-
'custom-property-pattern': '(antd-([a-z][a-zA-Z0-9]+)*)|(([a-z][a-z0-9]*)(-[a-z0-9]+)*)',
|
|
6
|
-
},
|
|
7
|
-
};
|
|
1
|
+
module.exports = {
|
|
2
|
+
// root: true,
|
|
3
|
+
extends: ['@peng_kai/lint/vue/stylelint_v2'],
|
|
4
|
+
rules: {
|
|
5
|
+
'custom-property-pattern': '(antd-([a-z][a-zA-Z0-9]+)*)|(([a-z][a-z0-9]*)(-[a-z0-9]+)*)',
|
|
6
|
+
},
|
|
7
|
+
};
|
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/date.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
3
|
+
import 'dayjs/locale/zh';
|
|
4
|
+
import 'dayjs/locale/en';
|
|
5
|
+
|
|
6
|
+
export { default as dayjs } from 'dayjs';
|
|
7
|
+
|
|
8
|
+
dayjs.locale('zh');
|
|
9
|
+
dayjs.extend(relativeTime);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 返回给定日期的一天的开始时间。
|
|
13
|
+
* @param day - 要获取一天的开始时间的日期。
|
|
14
|
+
* @returns 一天的开始时间作为Unix时间戳,如果输入无效则返回 undefined。
|
|
15
|
+
*/
|
|
16
|
+
export function startOfDay(day: dayjs.ConfigType) {
|
|
17
|
+
const _day = dayjs(day);
|
|
18
|
+
return _day.isValid() ? _day.startOf('day').valueOf() : undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 计算给定日期的当天结束时间。
|
|
23
|
+
* @param day - 要计算当天结束时间的日期。
|
|
24
|
+
* @returns 表示当天结束时间的时间戳值,如果输入无效则返回 undefined。
|
|
25
|
+
*/
|
|
26
|
+
export function endOfDay(day: dayjs.ConfigType) {
|
|
27
|
+
const _day = dayjs(day);
|
|
28
|
+
return _day.isValid() ? _day.endOf('day').valueOf() : undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 将秒数转换为时长格式化时间
|
|
33
|
+
* @param seconds 秒数
|
|
34
|
+
* @returns 时长格式化时间
|
|
35
|
+
*/
|
|
36
|
+
export function secondsToDuration(seconds: number) {
|
|
37
|
+
const units = [['天', 24 * 60 * 60], ['时', 60 * 60], ['分', 60], ['秒', 1]] as const;
|
|
38
|
+
|
|
39
|
+
return units.reduce((duration, [label, durationValue]) => {
|
|
40
|
+
const value = Math.floor(seconds / durationValue);
|
|
41
|
+
seconds %= durationValue;
|
|
42
|
+
return value > 0 ? duration += `${value + label}` : duration;
|
|
43
|
+
}, '');
|
|
44
|
+
}
|
package/utils/index.ts
CHANGED
|
@@ -18,9 +18,7 @@ export const ENV = {
|
|
|
18
18
|
* @param dur 时长
|
|
19
19
|
*/
|
|
20
20
|
export function sleep(dur: number) {
|
|
21
|
-
return new Promise(
|
|
22
|
-
setTimeout(resolve, dur);
|
|
23
|
-
});
|
|
21
|
+
return new Promise(resolve => setTimeout(resolve, dur));
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
/**
|
|
@@ -34,11 +32,6 @@ export function isSSR() {
|
|
|
34
32
|
return typeof window === 'undefined';
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
export function fixed() {
|
|
38
|
-
|
|
39
|
-
// return (12).toFixed
|
|
40
|
-
}
|
|
41
|
-
|
|
42
35
|
/**
|
|
43
36
|
* 字符串脱敏,省略中间字符串
|
|
44
37
|
* @param str 字符串
|
|
@@ -59,6 +52,15 @@ export function desensitize(str: string | undefined | null, startChars = 4, endC
|
|
|
59
52
|
return truncatedStr;
|
|
60
53
|
}
|
|
61
54
|
|
|
55
|
+
/**
|
|
56
|
+
* 生成指定长度的随机字符串
|
|
57
|
+
* @param length 要生成的随机字符串的长度
|
|
58
|
+
*/
|
|
59
|
+
export function randomString(length: number) {
|
|
60
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
61
|
+
return Array.from({ length }, () => characters[Math.floor(Math.random() * characters.length)]).join('');
|
|
62
|
+
}
|
|
63
|
+
|
|
62
64
|
/**
|
|
63
65
|
* 对应链的浏览器地址
|
|
64
66
|
* @param chain 链名
|
|
@@ -121,6 +123,10 @@ export function removeUrlSearchParam(key: string) {
|
|
|
121
123
|
window.history.replaceState({}, '', url);
|
|
122
124
|
}
|
|
123
125
|
|
|
126
|
+
/**
|
|
127
|
+
* 创建一个带有自身键的代理对象
|
|
128
|
+
* @returns 带有自身键的代理对象
|
|
129
|
+
*/
|
|
124
130
|
export function createSelfKeyProxy<T extends object>() {
|
|
125
131
|
return new Proxy({} as T, {
|
|
126
132
|
get(_, p) {
|
package/utils/number.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { calc } from 'a-calc';
|
|
2
|
+
|
|
3
|
+
export { default as bn } from 'bignumber.js';
|
|
4
|
+
export { calc } from 'a-calc';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 常用的数值格式化规则
|
|
8
|
+
*
|
|
9
|
+
* 命名规则:
|
|
10
|
+
* - d-decimal: 保留的小数位
|
|
11
|
+
* - p-pad: 当小数位不够填充指定的小数位时,是否填充0
|
|
12
|
+
* - r-round: 舍入规则。可选规则: R5四舍五入、R6四舍六入、R1向上取整、R0向下取整
|
|
13
|
+
* - t-thousand: 是否使用千位符
|
|
14
|
+
* - n-number: 返回数字类型
|
|
15
|
+
*/
|
|
16
|
+
export const numFmt = {
|
|
17
|
+
/** 保留18位小数,千位符 */
|
|
18
|
+
t: (num: any, err: any = null) => calc('a | <=18 ,', { a: String(num), _error: err }) as string | null,
|
|
19
|
+
/** 舍去小数,四舍五入,千位符 */
|
|
20
|
+
d0r5t: (num: any, err: any = null) => calc('a | =0 ~5 ,', { a: String(num), _error: err }) as string | null,
|
|
21
|
+
/** 舍去小数,向下取整,千位符 */
|
|
22
|
+
d0r0t: (num: any, err: any = null) => calc('a | =0 ~- ,', { a: String(num), _error: err }) as string | null,
|
|
23
|
+
/** 保留2位小数,四舍五入,千位符 */
|
|
24
|
+
d2r5t: (num: any, err: any = null) => calc('a | <=2 ~5 ,', { a: String(num), _error: err }) as string | null,
|
|
25
|
+
/** 保留2位小数,向下取整,千位符 */
|
|
26
|
+
d2r0t: (num: any, err: any = null) => calc('a | <=2 ~- ,', { a: String(num), _error: err }) as string | null,
|
|
27
|
+
/** 保留6位小数,四舍五入,千位符 */
|
|
28
|
+
d6r5t: (num: any, err: any = null) => calc('a | <=6 ~5 ,', { a: String(num), _error: err }) as string | null,
|
|
29
|
+
/** 保留6位小数,向下取整,千位符 */
|
|
30
|
+
d6r0t: (num: any, err: any = null) => calc('a | <=6 ~- ,', { a: String(num), _error: err }) as string | null,
|
|
31
|
+
/** 保留8位小数,四舍五入,千位符 */
|
|
32
|
+
d8r5t: (num: any, err: any = null) => calc('a | <=8 ~5 ,', { a: String(num), _error: err }) as string | null,
|
|
33
|
+
/** 保留8位小数,向下取整,千位符 */
|
|
34
|
+
d8r0t: (num: any, err: any = null) => calc('a | <=8 ~- ,', { a: String(num), _error: err }) as string | null,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 将给定的金额转换为格式化的字符串表示
|
|
39
|
+
* @param amount - 要转换的金额。
|
|
40
|
+
* @param decimal - 格式化字符串中包含的小数位数。默认为 0。
|
|
41
|
+
* @returns 金额的格式化字符串表示。
|
|
42
|
+
*/
|
|
43
|
+
export function toAmount(amount: any, decimal: string | number = 0) {
|
|
44
|
+
const res = calc('a / 10 ** d', { a: String(amount), d: Number(decimal), _error: null });
|
|
45
|
+
const fmt = (fmt: keyof typeof numFmt) => (numFmt[fmt] ?? numFmt.t)(res);
|
|
46
|
+
fmt.toString = () => numFmt.t(res);
|
|
47
|
+
|
|
48
|
+
return fmt;
|
|
49
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as InfiniteQuery } from './src/InfiniteQuery.vue';
|
|
1
|
+
export { default as InfiniteQuery } from './src/InfiniteQuery.vue';
|