twcpt 0.0.2
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/LICENSE +22 -0
- package/README.md +189 -0
- package/dist/charts-CKv8I1ye.js +879 -0
- package/dist/charts-DIdINgA4.cjs +1 -0
- package/dist/charts.cjs.js +1 -0
- package/dist/charts.css +1 -0
- package/dist/charts.d.ts +7 -0
- package/dist/charts.es.js +9 -0
- package/dist/components/j-ch-bar/index.d.ts +50 -0
- package/dist/components/j-ch-bar/types.d.ts +42 -0
- package/dist/components/j-ch-bar-line/index.d.ts +49 -0
- package/dist/components/j-ch-bar-line/types.d.ts +42 -0
- package/dist/components/j-ch-bubble/index.d.ts +54 -0
- package/dist/components/j-ch-bubble/types.d.ts +51 -0
- package/dist/components/j-ch-line/index.d.ts +57 -0
- package/dist/components/j-ch-line/types.d.ts +42 -0
- package/dist/components/j-ch-pie-doughnut/index.d.ts +60 -0
- package/dist/components/j-ch-pie-doughnut/types.d.ts +55 -0
- package/dist/components/j-ch-radar/index.d.ts +49 -0
- package/dist/components/j-ch-radar/types.d.ts +42 -0
- package/dist/components/j-tw-btn/index.d.ts +606 -0
- package/dist/components/j-tw-btn/types.d.ts +104 -0
- package/dist/composables/useI18n.d.ts +12 -0
- package/dist/global.d.ts +75 -0
- package/dist/i18n/en-US/index.d.ts +90 -0
- package/dist/i18n/index.d.ts +10 -0
- package/dist/i18n/zh-CN/index.d.ts +90 -0
- package/dist/index-BrYPwI7i.cjs +1 -0
- package/dist/index-C5mRo5Yi.cjs +1 -0
- package/dist/index-DsQ7r9Ci.js +76 -0
- package/dist/index-s5XCGtM9.js +76 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +68 -0
- package/dist/resolver.cjs +1 -0
- package/dist/resolver.d.ts +2 -0
- package/dist/resolver.mjs +36 -0
- package/dist/twcpt-styles.css +1 -0
- package/dist/twcpt-styles.d.ts +1 -0
- package/dist/twcpt-styles.js +1 -0
- package/dist/twcpt.cjs.js +1 -0
- package/dist/twcpt.es.js +2003 -0
- package/dist/types.d.ts +27 -0
- package/dist/utils/chart.d.ts +28 -0
- package/dist/utils/custom-svg.d.ts +3 -0
- package/dist/utils/helper/array.d.ts +289 -0
- package/dist/utils/helper/dom.d.ts +281 -0
- package/dist/utils/helper/index.d.ts +11 -0
- package/dist/utils/helper/number.d.ts +250 -0
- package/dist/utils/helper/object.d.ts +240 -0
- package/dist/utils/helper/perf.d.ts +231 -0
- package/dist/utils/helper/regex.d.ts +265 -0
- package/dist/utils/helper/string.d.ts +248 -0
- package/dist/utils/helper/url.d.ts +259 -0
- package/dist/utils/icon-map.d.ts +19 -0
- package/dist/utils/init.d.ts +35 -0
- package/dist/utils/resolver.d.ts +34 -0
- package/dist/utils/storage.d.ts +3 -0
- package/dist/utils/storageSync.d.ts +20 -0
- package/dist/utils/tool.d.ts +103 -0
- package/dist/utils/website-config.d.ts +15 -0
- package/package.json +90 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL 处理工具函数
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 解析 URL 参数为对象
|
|
6
|
+
* @param url URL 字符串,默认为当前页面 URL
|
|
7
|
+
* @returns 参数对象
|
|
8
|
+
* @example
|
|
9
|
+
* parseQuery('?name=Tom&age=20')
|
|
10
|
+
* // { name: 'Tom', age: '20' }
|
|
11
|
+
*
|
|
12
|
+
* parseQuery('http://example.com?name=Tom&age=20')
|
|
13
|
+
* // { name: 'Tom', age: '20' }
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseQuery(url?: string): Record<string, string | string[]>;
|
|
16
|
+
/**
|
|
17
|
+
* 对象转 URL 参数字符串
|
|
18
|
+
* @param params 参数对象
|
|
19
|
+
* @returns URL 参数字符串(不包含 ?)
|
|
20
|
+
* @example
|
|
21
|
+
* stringifyQuery({ name: 'Tom', age: 20 })
|
|
22
|
+
* // 'name=Tom&age=20'
|
|
23
|
+
*
|
|
24
|
+
* stringifyQuery({ tags: ['a', 'b', 'c'] })
|
|
25
|
+
* // 'tags=a&tags=b&tags=c'
|
|
26
|
+
*/
|
|
27
|
+
export declare function stringifyQuery(params: Record<string, any>): string;
|
|
28
|
+
/**
|
|
29
|
+
* 获取 URL 指定参数的值
|
|
30
|
+
* @param key 参数名
|
|
31
|
+
* @param url URL 字符串,默认为当前页面 URL
|
|
32
|
+
* @returns 参数值,不存在返回 null
|
|
33
|
+
* @example
|
|
34
|
+
* getQueryParam('name', '?name=Tom&age=20')
|
|
35
|
+
* // 'Tom'
|
|
36
|
+
*/
|
|
37
|
+
export declare function getQueryParam(key: string, url?: string): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* 获取 URL 所有同名参数的值(数组)
|
|
40
|
+
* @param key 参数名
|
|
41
|
+
* @param url URL 字符串,默认为当前页面 URL
|
|
42
|
+
* @returns 参数值数组
|
|
43
|
+
* @example
|
|
44
|
+
* getQueryParams('tags', '?tags=a&tags=b&tags=c')
|
|
45
|
+
* // ['a', 'b', 'c']
|
|
46
|
+
*/
|
|
47
|
+
export declare function getQueryParams(key: string, url?: string): string[];
|
|
48
|
+
/**
|
|
49
|
+
* 更新 URL 参数(不刷新页面)
|
|
50
|
+
* @param params 要更新的参数对象
|
|
51
|
+
* @param mode 更新模式:'push' 添加历史记录,'replace' 替换当前记录
|
|
52
|
+
* @example
|
|
53
|
+
* updateQueryParams({ name: 'Tom', age: 20 }, 'push')
|
|
54
|
+
*/
|
|
55
|
+
export declare function updateQueryParams(params: Record<string, any>, mode?: 'push' | 'replace'): void;
|
|
56
|
+
/**
|
|
57
|
+
* 删除 URL 指定参数(不刷新页面)
|
|
58
|
+
* @param keys 要删除的参数名数组
|
|
59
|
+
* @param mode 更新模式:'push' 添加历史记录,'replace' 替换当前记录
|
|
60
|
+
* @example
|
|
61
|
+
* removeQueryParams(['name', 'age'], 'replace')
|
|
62
|
+
*/
|
|
63
|
+
export declare function removeQueryParams(keys: string[], mode?: 'push' | 'replace'): void;
|
|
64
|
+
/**
|
|
65
|
+
* 清空所有 URL 参数(不刷新页面)
|
|
66
|
+
* @param mode 更新模式:'push' 添加历史记录,'replace' 替换当前记录
|
|
67
|
+
* @example
|
|
68
|
+
* clearQueryParams('replace')
|
|
69
|
+
*/
|
|
70
|
+
export declare function clearQueryParams(mode?: 'push' | 'replace'): void;
|
|
71
|
+
/**
|
|
72
|
+
* 拼接 URL(自动处理斜杠)
|
|
73
|
+
* @param parts URL 片段数组
|
|
74
|
+
* @returns 拼接后的 URL
|
|
75
|
+
* @example
|
|
76
|
+
* joinUrl('http://example.com/', '/api/', 'users/', '123')
|
|
77
|
+
* // 'http://example.com/api/users/123'
|
|
78
|
+
*/
|
|
79
|
+
export declare function joinUrl(...parts: string[]): string;
|
|
80
|
+
/**
|
|
81
|
+
* 解析 URL 为各个组成部分
|
|
82
|
+
* @param url URL 字符串
|
|
83
|
+
* @returns URL 各部分的对象
|
|
84
|
+
* @example
|
|
85
|
+
* parseUrl('https://user:pass@example.com:8080/path?query=1#hash')
|
|
86
|
+
* // {
|
|
87
|
+
* // protocol: 'https:',
|
|
88
|
+
* // username: 'user',
|
|
89
|
+
* // password: 'pass',
|
|
90
|
+
* // hostname: 'example.com',
|
|
91
|
+
* // port: '8080',
|
|
92
|
+
* // pathname: '/path',
|
|
93
|
+
* // search: '?query=1',
|
|
94
|
+
* // hash: '#hash',
|
|
95
|
+
* // host: 'example.com:8080',
|
|
96
|
+
* // origin: 'https://example.com:8080',
|
|
97
|
+
* // href: 'https://user:pass@example.com:8080/path?query=1#hash'
|
|
98
|
+
* // }
|
|
99
|
+
*/
|
|
100
|
+
export declare function parseUrl(url: string): {
|
|
101
|
+
protocol: string;
|
|
102
|
+
username: string;
|
|
103
|
+
password: string;
|
|
104
|
+
hostname: string;
|
|
105
|
+
port: string;
|
|
106
|
+
pathname: string;
|
|
107
|
+
search: string;
|
|
108
|
+
hash: string;
|
|
109
|
+
host: string;
|
|
110
|
+
origin: string;
|
|
111
|
+
href: string;
|
|
112
|
+
params: Record<string, string | string[]>;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* 构建 URL
|
|
116
|
+
* @param options URL 各部分配置
|
|
117
|
+
* @returns 完整的 URL 字符串
|
|
118
|
+
* @example
|
|
119
|
+
* buildUrl({
|
|
120
|
+
* protocol: 'https',
|
|
121
|
+
* hostname: 'example.com',
|
|
122
|
+
* pathname: '/api/users',
|
|
123
|
+
* params: { page: 1, size: 10 }
|
|
124
|
+
* })
|
|
125
|
+
* // 'https://example.com/api/users?page=1&size=10'
|
|
126
|
+
*/
|
|
127
|
+
export declare function buildUrl(options: {
|
|
128
|
+
protocol?: string;
|
|
129
|
+
hostname?: string;
|
|
130
|
+
port?: string | number;
|
|
131
|
+
pathname?: string;
|
|
132
|
+
params?: Record<string, any>;
|
|
133
|
+
hash?: string;
|
|
134
|
+
}): string;
|
|
135
|
+
/**
|
|
136
|
+
* 判断是否为外部链接(http/https 开头)
|
|
137
|
+
* @param url URL 字符串
|
|
138
|
+
* @returns 是否为外部链接
|
|
139
|
+
* @example
|
|
140
|
+
* isExternalLink('https://example.com')
|
|
141
|
+
* // true
|
|
142
|
+
* isExternalLink('/path/to/page')
|
|
143
|
+
* // false
|
|
144
|
+
*/
|
|
145
|
+
export declare function isExternalLink(url: string): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* 判断是否为绝对路径
|
|
148
|
+
* @param url URL 字符串
|
|
149
|
+
* @returns 是否为绝对路径
|
|
150
|
+
* @example
|
|
151
|
+
* isAbsolutePath('/path/to/page')
|
|
152
|
+
* // true
|
|
153
|
+
* isAbsolutePath('path/to/page')
|
|
154
|
+
* // false
|
|
155
|
+
*/
|
|
156
|
+
export declare function isAbsolutePath(url: string): boolean;
|
|
157
|
+
/**
|
|
158
|
+
* 判断两个 URL 是否同源
|
|
159
|
+
* @param url1 URL 1
|
|
160
|
+
* @param url2 URL 2
|
|
161
|
+
* @returns 是否同源
|
|
162
|
+
* @example
|
|
163
|
+
* isSameOrigin('https://example.com/a', 'https://example.com/b')
|
|
164
|
+
* // true
|
|
165
|
+
* isSameOrigin('https://example.com', 'https://other.com')
|
|
166
|
+
* // false
|
|
167
|
+
*/
|
|
168
|
+
export declare function isSameOrigin(url1: string, url2: string): boolean;
|
|
169
|
+
/**
|
|
170
|
+
* 编码 URL 参数值
|
|
171
|
+
* @param value 参数值
|
|
172
|
+
* @returns 编码后的值
|
|
173
|
+
* @example
|
|
174
|
+
* encodeParam('hello world')
|
|
175
|
+
* // 'hello%20world'
|
|
176
|
+
*/
|
|
177
|
+
export declare function encodeParam(value: string): string;
|
|
178
|
+
/**
|
|
179
|
+
* 解码 URL 参数值
|
|
180
|
+
* @param value 编码的参数值
|
|
181
|
+
* @returns 解码后的值
|
|
182
|
+
* @example
|
|
183
|
+
* decodeParam('hello%20world')
|
|
184
|
+
* // 'hello world'
|
|
185
|
+
*/
|
|
186
|
+
export declare function decodeParam(value: string): string;
|
|
187
|
+
/**
|
|
188
|
+
* 安全编码 URL(处理已编码的情况)
|
|
189
|
+
* @param url URL 字符串
|
|
190
|
+
* @returns 编码后的 URL
|
|
191
|
+
*/
|
|
192
|
+
export declare function safeEncodeUrl(url: string): string;
|
|
193
|
+
/**
|
|
194
|
+
* 安全解码 URL(处理未编码的情况)
|
|
195
|
+
* @param url 编码的 URL 字符串
|
|
196
|
+
* @returns 解码后的 URL
|
|
197
|
+
*/
|
|
198
|
+
export declare function safeDecodeUrl(url: string): string;
|
|
199
|
+
/**
|
|
200
|
+
* 添加 URL 参数
|
|
201
|
+
* @param url 原始 URL
|
|
202
|
+
* @param params 要添加的参数
|
|
203
|
+
* @returns 添加参数后的 URL
|
|
204
|
+
* @example
|
|
205
|
+
* addQueryParams('http://example.com/api', { page: 1, size: 10 })
|
|
206
|
+
* // 'http://example.com/api?page=1&size=10'
|
|
207
|
+
*
|
|
208
|
+
* addQueryParams('http://example.com/api?id=1', { page: 1 })
|
|
209
|
+
* // 'http://example.com/api?id=1&page=1'
|
|
210
|
+
*/
|
|
211
|
+
export declare function addQueryParams(url: string, params: Record<string, any>): string;
|
|
212
|
+
/**
|
|
213
|
+
* 移除 URL 中的指定参数
|
|
214
|
+
* @param url 原始 URL
|
|
215
|
+
* @param keys 要移除的参数名数组
|
|
216
|
+
* @returns 移除参数后的 URL
|
|
217
|
+
* @example
|
|
218
|
+
* removeQueryParamsFromUrl('http://example.com?a=1&b=2&c=3', ['b', 'c'])
|
|
219
|
+
* // 'http://example.com?a=1'
|
|
220
|
+
*/
|
|
221
|
+
export declare function removeQueryParamsFromUrl(url: string, keys: string[]): string;
|
|
222
|
+
/**
|
|
223
|
+
* 获取 URL 的域名
|
|
224
|
+
* @param url URL 字符串
|
|
225
|
+
* @returns 域名
|
|
226
|
+
* @example
|
|
227
|
+
* getDomain('https://www.example.com/path')
|
|
228
|
+
* // 'www.example.com'
|
|
229
|
+
*/
|
|
230
|
+
export declare function getDomain(url: string): string;
|
|
231
|
+
/**
|
|
232
|
+
* 获取 URL 的根域名(不含子域名)
|
|
233
|
+
* @param url URL 字符串
|
|
234
|
+
* @returns 根域名
|
|
235
|
+
* @example
|
|
236
|
+
* getRootDomain('https://www.example.com/path')
|
|
237
|
+
* // 'example.com'
|
|
238
|
+
*/
|
|
239
|
+
export declare function getRootDomain(url: string): string;
|
|
240
|
+
/**
|
|
241
|
+
* 获取当前页面的完整 URL
|
|
242
|
+
* @returns 当前页面 URL
|
|
243
|
+
*/
|
|
244
|
+
export declare function getCurrentUrl(): string;
|
|
245
|
+
/**
|
|
246
|
+
* 获取当前页面的路径(不含域名和参数)
|
|
247
|
+
* @returns 当前页面路径
|
|
248
|
+
*/
|
|
249
|
+
export declare function getCurrentPath(): string;
|
|
250
|
+
/**
|
|
251
|
+
* 获取当前页面的查询参数
|
|
252
|
+
* @returns 查询参数对象
|
|
253
|
+
*/
|
|
254
|
+
export declare function getCurrentQuery(): Record<string, string | string[]>;
|
|
255
|
+
/**
|
|
256
|
+
* 获取当前页面的 Hash
|
|
257
|
+
* @returns Hash 值(不含 #)
|
|
258
|
+
*/
|
|
259
|
+
export declare function getCurrentHash(): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type IconMapResult = {
|
|
2
|
+
icon: string;
|
|
3
|
+
} | {
|
|
4
|
+
cls: string;
|
|
5
|
+
content?: string;
|
|
6
|
+
};
|
|
7
|
+
export type IconMapFn = (iconName: string) => IconMapResult | void;
|
|
8
|
+
/**
|
|
9
|
+
* twcpt 内置图标映射函数(基于 src/utils/custom-svg.ts 的 base64 svg)。
|
|
10
|
+
*
|
|
11
|
+
* 匹配策略(多候选 key):
|
|
12
|
+
* - 带/不带 `app:` 前缀
|
|
13
|
+
* - 原样/小写
|
|
14
|
+
*/
|
|
15
|
+
export declare const twcptIconMapFn: IconMapFn;
|
|
16
|
+
/**
|
|
17
|
+
* 组合多个 iconMapFn:按顺序尝试,谁先返回结果就用谁的。
|
|
18
|
+
*/
|
|
19
|
+
export declare function composeIconMapFn(...fns: Array<IconMapFn | undefined | null>): IconMapFn;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { App, Ref, InjectionKey } from 'vue';
|
|
2
|
+
import { default as defaultColors } from '../config/colors.json';
|
|
3
|
+
import { Locale } from '../composables/useI18n';
|
|
4
|
+
export declare const PAGE_PERMISSION_KEY: InjectionKey<Ref<string[]>>;
|
|
5
|
+
export declare const PAGE_ACTION_PERMISSION_KEY: InjectionKey<Ref<string[]>>;
|
|
6
|
+
export type ColorConfig = Partial<typeof defaultColors>;
|
|
7
|
+
export interface TWcptInitOptions {
|
|
8
|
+
app: App;
|
|
9
|
+
router?: any;
|
|
10
|
+
store?: any;
|
|
11
|
+
i18n?: any;
|
|
12
|
+
pagePermissionIds?: Ref<string[]> | string[];
|
|
13
|
+
pageActionPermissionIds?: Ref<string[]> | string[];
|
|
14
|
+
defaultLanguage?: Locale;
|
|
15
|
+
colors?: ColorConfig;
|
|
16
|
+
disableBFCache?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 初始化 twcpt 组件库
|
|
20
|
+
* @param options 初始化配置选项
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { createApp } from 'vue';
|
|
24
|
+
* import { twcptInit } from 'twcpt';
|
|
25
|
+
*
|
|
26
|
+
* const app = createApp(App);
|
|
27
|
+
* twcptInit({
|
|
28
|
+
* app,
|
|
29
|
+
* defaultLanguage: 'en-US',
|
|
30
|
+
* colors: { primary: '#FF5722' },
|
|
31
|
+
* disableBFCache: true,
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function twcptInit(options: TWcptInitOptions): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ComponentResolver } from 'unplugin-vue-components/types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolver for twcpt components
|
|
4
|
+
* Automatically imports twcpt components (JTW*, JC*, JCh*) when used in templates
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { twcptResolver } from 'twcpt/resolver'
|
|
9
|
+
*
|
|
10
|
+
* // in vite.config.ts
|
|
11
|
+
* Components({
|
|
12
|
+
* resolvers: [twcptResolver()]
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function twcptResolver(): ComponentResolver;
|
|
17
|
+
/**
|
|
18
|
+
* Options for twcptResolver
|
|
19
|
+
*/
|
|
20
|
+
export interface TwcptResolverOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Exclude components that should not be auto-imported
|
|
23
|
+
* @example ['JTWBtn', 'JCTable']
|
|
24
|
+
*/
|
|
25
|
+
exclude?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Prefix for component resolution (default: none, matches JTW*, JC*, JCh*)
|
|
28
|
+
*/
|
|
29
|
+
prefix?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Configurable resolver for twcpt components
|
|
33
|
+
*/
|
|
34
|
+
export declare function twcptResolverWithOptions(options?: TwcptResolverOptions): ComponentResolver;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* 创建一个与 localStorage 同步的响应式 ref
|
|
4
|
+
* 支持跨标签页同步(通过 storage 事件)
|
|
5
|
+
*
|
|
6
|
+
* @param key - localStorage 的 key
|
|
7
|
+
* @param initialValue - 初始值
|
|
8
|
+
* @param serializer - 序列化函数(将值转为字符串存储)
|
|
9
|
+
* @param deserializer - 反序列化函数(从字符串读取值)
|
|
10
|
+
* @returns 响应式 ref
|
|
11
|
+
*/
|
|
12
|
+
export declare function useLocalStorageSync<T>(key: string, initialValue: T, serializer?: (value: T) => string, deserializer?: (value: string) => T): Ref<T>;
|
|
13
|
+
/**
|
|
14
|
+
* 创建与 localStorage 同步的页面权限 ID ref
|
|
15
|
+
*/
|
|
16
|
+
export declare function usePagePermissionSync(key: string): Ref<string[]>;
|
|
17
|
+
/**
|
|
18
|
+
* 创建与 localStorage 同步的页面操作权限 ID ref
|
|
19
|
+
*/
|
|
20
|
+
export declare function usePageActionPermissionSync(key: string): Ref<string[]>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 格式化数据
|
|
3
|
+
* 把数字转成指定单位
|
|
4
|
+
*/
|
|
5
|
+
type TSizeUnit = 'B' | 'KB' | 'MB' | 'GB' | 'TB';
|
|
6
|
+
/**
|
|
7
|
+
* 默认填充函数,处理 falsy 值
|
|
8
|
+
* @param val 要处理的值
|
|
9
|
+
* @returns 默认填充的字符串
|
|
10
|
+
*/
|
|
11
|
+
export declare function defaultFill(val: any): any;
|
|
12
|
+
export declare function formatSize(options: {
|
|
13
|
+
maxUnit?: TSizeUnit;
|
|
14
|
+
numberFormatOptions?: Intl.NumberFormatOptions;
|
|
15
|
+
size: number;
|
|
16
|
+
unit?: TSizeUnit;
|
|
17
|
+
}): string;
|
|
18
|
+
export declare function getUpperSize(sizeUnit: {
|
|
19
|
+
size: number;
|
|
20
|
+
unit?: TSizeUnit;
|
|
21
|
+
}, options?: {
|
|
22
|
+
maxUnit?: TSizeUnit;
|
|
23
|
+
}): {
|
|
24
|
+
size: number;
|
|
25
|
+
unit: TSizeUnit;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* 1. 先检查值是不是数字0或字符串'0',是的话就应用格式化或返回原值,保留0
|
|
30
|
+
* 2. 再检查其他所有当空白处理的 falsy 值 (null, undefined, '', false, NaN)
|
|
31
|
+
* 3. 否则应用可选的自定义格式化函数
|
|
32
|
+
*
|
|
33
|
+
* @param customFormatter 可选的自定义格式化函数
|
|
34
|
+
* @param fallbackValue 默认的替代值,默认是 '-'
|
|
35
|
+
* @returns QTable columns 接受的格式化函数
|
|
36
|
+
*/
|
|
37
|
+
export declare function defaultFormat(customFormatter?: (val: any, row: any) => string | number, fallbackValue?: string): (val: any, row: any) => any;
|
|
38
|
+
/**
|
|
39
|
+
* 可接受的日期输入类型
|
|
40
|
+
*/
|
|
41
|
+
export type DateInput = Date | string | number;
|
|
42
|
+
/**
|
|
43
|
+
* 日期格式化字符串类型
|
|
44
|
+
* 支持的格式标记:YYYY YY MM M DD D HH H hh h mm m ss s SSS SS S A a
|
|
45
|
+
*/
|
|
46
|
+
export type DateFormatString = string;
|
|
47
|
+
/**
|
|
48
|
+
* 格式化日期/时间戳的工具函数。
|
|
49
|
+
* * 示例:
|
|
50
|
+
* formatDate(Date.now(), 'YYYY-MM-DD HH:mm:ss')
|
|
51
|
+
* formatDate('2025-11-13T23:00:57.123Z', 'YYYY年MM月DD日')
|
|
52
|
+
* * @param dateInput 要格式化的日期或时间戳。
|
|
53
|
+
* @param dateInput
|
|
54
|
+
* @param formatString 格式化字符串 (例如 'YYYY-MM-DD HH:mm:ss.SSS')。
|
|
55
|
+
* @returns 格式化后的日期字符串。
|
|
56
|
+
*/
|
|
57
|
+
export declare function formatDate(dateInput: DateInput, formatString?: DateFormatString): string;
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* 结合 defaultFormat 的空值处理逻辑和 formatDate 的日期格式化功能
|
|
61
|
+
* 1. 先检查值是不是数字0或字符串'0',是的话就返回原值,保留0
|
|
62
|
+
* 2. 再检查其他所有当空白处理的 falsy 值 (null, undefined, '', false, NaN)
|
|
63
|
+
* 3. 否则应用 formatDate 进行格式化
|
|
64
|
+
*
|
|
65
|
+
* @param formatString 格式化字符串 (例如 'YYYY-MM-DD HH:mm:ss')
|
|
66
|
+
* @param fallbackValue 默认的替代值,默认是 '-'
|
|
67
|
+
* @returns QTable columns 接受的格式化函数
|
|
68
|
+
*/
|
|
69
|
+
export declare function defaultDateFormat(formatString?: DateFormatString, fallbackValue?: string): (val: DateInput | null | undefined, _row: any) => string;
|
|
70
|
+
/**
|
|
71
|
+
* 流量数据格式化函数:
|
|
72
|
+
* 1. 用 defaultFormat 处理 falsy 值,显示 '-',0 除外
|
|
73
|
+
* 2. 用 formatSize 进行流量单位转换,默认从 B 开始转换
|
|
74
|
+
*/
|
|
75
|
+
export declare function defaultDataFormat(fallbackValue?: string, options?: {
|
|
76
|
+
digits?: number;
|
|
77
|
+
unit?: TSizeUnit;
|
|
78
|
+
}): (val: any, row: any) => any;
|
|
79
|
+
/**
|
|
80
|
+
* 流量数据格式化函数2,输入如果是 【unit】/ 1024 是整数,则转换为父级的单位,如果不是整数,则保留当前单位。
|
|
81
|
+
* 1. 使用 defaultFormat 处理 falsy 值 (显示 '-',0 除外)。
|
|
82
|
+
* 2. 智能单位转换:如果值能被 1024 整除,自动向上转换单位(MB → GB → TB)。
|
|
83
|
+
* 3. 如果不能整除,保持原始单位。
|
|
84
|
+
*/
|
|
85
|
+
export declare function defaultAutoDataFormat(fallbackValue?: string, options?: {
|
|
86
|
+
digits?: number;
|
|
87
|
+
unit?: TSizeUnit;
|
|
88
|
+
}): (val: any, row: any) => any;
|
|
89
|
+
/**
|
|
90
|
+
* 流量单位转换函数,支持 B、KB、MB、GB、TB 之间的任意转换
|
|
91
|
+
* @param value 要转换的数值
|
|
92
|
+
* @param fromUnit 源单位
|
|
93
|
+
* @param toUnit 目标单位
|
|
94
|
+
* @param options 配置项
|
|
95
|
+
* @param options.digits 保留小数位数,默认为 2
|
|
96
|
+
* @param options.showUnit 是否显示单位,默认为 true
|
|
97
|
+
* @returns 转换后的字符串或数字
|
|
98
|
+
*/
|
|
99
|
+
export declare function convertDataUnit(value: number | string, fromUnit: TSizeUnit, toUnit: TSizeUnit, options?: {
|
|
100
|
+
digits?: number;
|
|
101
|
+
showUnit?: boolean;
|
|
102
|
+
}): string | number;
|
|
103
|
+
export { setTitleAndLogo, getTitle, getNavLogo } from './website-config';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 根据域名修改网页的标签栏logo
|
|
3
|
+
*/
|
|
4
|
+
export declare function setTitleAndLogo(): void;
|
|
5
|
+
/**
|
|
6
|
+
* 根据域名返回平台名称
|
|
7
|
+
* @param lang
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTitle(lang: string): Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* 根据域名返回导航栏logo
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function getNavLogo(): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "twcpt",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "A Vue 3 component library built with Vite and TypeScript, featuring components integrated with Element-plus.",
|
|
5
|
+
"main": "dist/twcpt.umd.js",
|
|
6
|
+
"module": "dist/twcpt.es.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"p": "npm publish",
|
|
11
|
+
"build:colors": "node scripts/generate-colors.js",
|
|
12
|
+
"build:svg": "node scripts/generate-custom-svg.js",
|
|
13
|
+
"build:types": "node scripts/generate-global-types.js",
|
|
14
|
+
"build": "vite build",
|
|
15
|
+
"build-all": "npm run build:colors && npm run build:svg && npm run build:types && vite build",
|
|
16
|
+
"dev": "npm run build:colors && npm run build:svg && vite build --watch",
|
|
17
|
+
"yalc:publish": "npm run build-all && npx yalc push",
|
|
18
|
+
"yalc:push": "npm run build-all && npx yalc push",
|
|
19
|
+
"yalc:dev": "node scripts/yalc-dev.js",
|
|
20
|
+
"patch": "npm version patch && npm run p",
|
|
21
|
+
"minor": "npm version minor && npm run p",
|
|
22
|
+
"major": "npm version major && npm run p"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/twcpt.es.js",
|
|
33
|
+
"require": "./dist/twcpt.cjs.js"
|
|
34
|
+
},
|
|
35
|
+
"./resolver": {
|
|
36
|
+
"types": "./dist/resolver.d.ts",
|
|
37
|
+
"import": "./dist/resolver.mjs",
|
|
38
|
+
"require": "./dist/resolver.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./charts": {
|
|
41
|
+
"types": "./dist/charts.d.ts",
|
|
42
|
+
"import": "./dist/charts.es.js",
|
|
43
|
+
"require": "./dist/charts.cjs.js"
|
|
44
|
+
},
|
|
45
|
+
"./twcpt.css": "./dist/index.css",
|
|
46
|
+
"./twcpt-styles.css": "./dist/twcpt-styles.css",
|
|
47
|
+
"./dist/index.css": "./dist/index.css",
|
|
48
|
+
"./dist/twcpt-styles.css": "./dist/twcpt-styles.css"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"chart.js": "^4.0.0",
|
|
52
|
+
"element-plus": "^2.5.5",
|
|
53
|
+
"vue": "^3.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
57
|
+
"chart.js": "^4.4.7",
|
|
58
|
+
"debug": "^4.4.3",
|
|
59
|
+
"prettier": "^2.5.1",
|
|
60
|
+
"element-plus": "^2.5.5",
|
|
61
|
+
"resolve": "^1.22.11",
|
|
62
|
+
"sass": "^1.94.2",
|
|
63
|
+
"typescript": "^5.9.3",
|
|
64
|
+
"unplugin-vue-components": "^30.0.0",
|
|
65
|
+
"vite": "^6.0.7",
|
|
66
|
+
"vite-plugin-dts": "^4.5.4",
|
|
67
|
+
"vue": "^3.5.25"
|
|
68
|
+
},
|
|
69
|
+
"keywords": [
|
|
70
|
+
"vue",
|
|
71
|
+
"element-plus",
|
|
72
|
+
"component-library",
|
|
73
|
+
"typescript"
|
|
74
|
+
],
|
|
75
|
+
"author": "tw-hejian",
|
|
76
|
+
"license": "MIT",
|
|
77
|
+
"repository": {
|
|
78
|
+
"type": "git",
|
|
79
|
+
"url": "https://codeup.aliyun.com/kwtw/frontend/twcpt",
|
|
80
|
+
"directory": "."
|
|
81
|
+
},
|
|
82
|
+
"homepage": "https://www.npmjs.com/package/twcpt",
|
|
83
|
+
"bugs": {
|
|
84
|
+
"url": "https://codeup.aliyun.com/kwtw/frontend/twcpt/issues"
|
|
85
|
+
},
|
|
86
|
+
"engines": {
|
|
87
|
+
"node": ">=16.0.0"
|
|
88
|
+
},
|
|
89
|
+
"dependencies": {}
|
|
90
|
+
}
|