@zl-ui-kit/utils 0.3.3 → 0.5.0
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/README.md +2 -2
- package/dist/index.d.ts +1 -23
- package/dist/index.js +0 -17
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **完整使用文档**:[`@zl-ui-kit/components` 的 README(npm 页面)](https://www.npmjs.com/package/@zl-ui-kit/components) 即 UI 组件权威文档 ——
|
|
4
4
|
> 本包的 Hooks / 工具 / 主题 / 国际化用法都在其中,本文只保留本包速查与运行前提。
|
|
5
5
|
|
|
6
|
-
ZL UI 通用工具函数库(TypeScript):数组/对象/DOM/函数、AES 加解密(crypto-js)、文件工具、axios 请求封装(`createRequest`:防重复、qs 序列化、`{cipher}`
|
|
6
|
+
ZL UI 通用工具函数库(TypeScript):数组/对象/DOM/函数、AES 加解密(crypto-js)、文件工具、axios 请求封装(`createRequest`:防重复、qs 序列化、`{cipher}` 响应解密)、分页/格式化等。
|
|
7
7
|
|
|
8
8
|
## 快速上手
|
|
9
9
|
|
|
@@ -13,7 +13,7 @@ import { createRequest, convertArrayToTree, paginate, aesEncrypt } from '@zl-ui-
|
|
|
13
13
|
const request = createRequest({ baseURL: '/api', onError(code, err) { /* ... */ } })
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
注入式设计(决策 §12-Q3):`baseURL
|
|
16
|
+
注入式设计(决策 §12-Q3):`baseURL`、调试开关等均由参数注入,**不读取构建环境变量**,Vite/webpack 消费方均可使用。
|
|
17
17
|
|
|
18
18
|
## 模块说明
|
|
19
19
|
|
package/dist/index.d.ts
CHANGED
|
@@ -118,28 +118,6 @@ declare function isBoolean(val: unknown): val is boolean;
|
|
|
118
118
|
declare function isNumber(val: unknown): val is number;
|
|
119
119
|
declare function isDefined<T>(val: T | undefined): val is T;
|
|
120
120
|
|
|
121
|
-
/**
|
|
122
|
-
* 微前端 URL 工具(micro-app 约定)
|
|
123
|
-
* 注入式改造(需求 §12-Q3):开发态源地址映射由调用方传入,不再读取构建环境变量
|
|
124
|
-
*/
|
|
125
|
-
interface FormatMicroUrlOptions {
|
|
126
|
-
/** 是否处于开发环境(替换微应用源为本机 dev server) */
|
|
127
|
-
dev?: boolean;
|
|
128
|
-
/** 微应用标识 → 开发态源地址映射,如 { dsc: 'http://localhost:5204' } */
|
|
129
|
-
origins?: Record<string, string>;
|
|
130
|
-
}
|
|
131
|
-
interface FormatMicroUrlResult {
|
|
132
|
-
/** 从 URL 第一段路径提取的微应用标识 */
|
|
133
|
-
micro: string;
|
|
134
|
-
URL: URL;
|
|
135
|
-
url: string;
|
|
136
|
-
fullpath: string;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* 格式化微前端 URL 地址
|
|
140
|
-
*/
|
|
141
|
-
declare function formatMicroUrl(url: string, options?: FormatMicroUrlOptions | boolean): FormatMicroUrlResult;
|
|
142
|
-
|
|
143
121
|
/**
|
|
144
122
|
* 对象工具
|
|
145
123
|
*/
|
|
@@ -219,4 +197,4 @@ declare function formatNumber(number: number | string): string;
|
|
|
219
197
|
/** 计算表格行序号(当前页第 rowIndex 行的全局序号,从 1 开始) */
|
|
220
198
|
declare function getIndex(rowIndex: number, pageNum: number, pageSize: number): number;
|
|
221
199
|
|
|
222
|
-
export { CRYPTO_CIPHER_CODE, type ConvertArrayToTreeOptions, DATABASE_AES_IV_KEY, DATABASE_AES_KEY, DEFAULT_AES_IV_KEY, DEFAULT_AES_KEY, type FilePreviewType, type FormatFilesizeOptions, type
|
|
200
|
+
export { CRYPTO_CIPHER_CODE, type ConvertArrayToTreeOptions, DATABASE_AES_IV_KEY, DATABASE_AES_KEY, DEFAULT_AES_IV_KEY, DEFAULT_AES_KEY, type FilePreviewType, type FormatFilesizeOptions, type PaginateResult, type RelativeRect, RequestError, type RequestOptions, aesDecrypt, aesEncrypt, convertArrayToTree, createRequest, debounce, deepCopy, downloadFileByUrl, ensureArray, fileUrlPreviewType, formatFilesize, formatNumber, generateUUID, getIndex, getRandomInt, getRelativeRect, getStyle, hasOwn, isArray, isBoolean, isDefined, isFunction, isNumber, isObject, isPlainObject, isPromise, joinFilePrefix, paginate, createRequest as request, setupRequest, shallowCopy, traverseTree, withResolvers };
|
package/dist/index.js
CHANGED
|
@@ -205,22 +205,6 @@ function withResolvers() {
|
|
|
205
205
|
return { resolve, reject, promise };
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
// src/micro.ts
|
|
209
|
-
function formatMicroUrl(url, options = {}) {
|
|
210
|
-
const { dev = false, origins = {} } = typeof options === "boolean" ? { dev: options } : options;
|
|
211
|
-
let _url = new URL(url, window.location.origin);
|
|
212
|
-
const micro = _url.pathname.split("/")[1] ?? "";
|
|
213
|
-
if (dev && origins[micro]) {
|
|
214
|
-
_url = new URL(_url.pathname + _url.search, origins[micro]);
|
|
215
|
-
}
|
|
216
|
-
return {
|
|
217
|
-
micro,
|
|
218
|
-
URL: _url,
|
|
219
|
-
url: _url.href,
|
|
220
|
-
fullpath: _url.pathname + _url.search
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
208
|
// src/object.ts
|
|
225
209
|
function shallowCopy(obj) {
|
|
226
210
|
if (isObject(obj)) {
|
|
@@ -405,7 +389,6 @@ export {
|
|
|
405
389
|
saveAs as fileSave,
|
|
406
390
|
fileUrlPreviewType,
|
|
407
391
|
formatFilesize,
|
|
408
|
-
formatMicroUrl,
|
|
409
392
|
formatNumber,
|
|
410
393
|
generateUUID,
|
|
411
394
|
getIndex,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zl-ui-kit/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ZL UI 通用工具函数库(数组/对象/DOM/加密/文件/请求封装/微前端 URL 等)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"tsup": "^8.3.5",
|
|
38
38
|
"typescript": "^5.7.3",
|
|
39
39
|
"vitest": "^2.1.8",
|
|
40
|
-
"@jichuang/
|
|
41
|
-
"@jichuang/
|
|
40
|
+
"@jichuang/eslint-config": "1.0.0",
|
|
41
|
+
"@jichuang/tsconfig": "1.0.0"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|