jiezhangxin-utils 0.0.2 → 0.0.4

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 CHANGED
@@ -1,63 +1,101 @@
1
1
  # jiezhangxin-utils
2
2
 
3
- # 捷账芯 智能财务系统工具库
4
-
5
- A utility toolkit for Vue 3 projects, providing common functions for date handling, string manipulation, array processing, and storage management.
3
+ A utility toolkit for Vue 3 projects, supporting tree-shaking and按需引入.
6
4
 
7
5
  ## Installation
8
- npm install jiezhangxin-utils --save
6
+
7
+ ```bash
8
+ npm install jiezhangxin-utils
9
+ # or
10
+ yarn add jiezhangxin-utils
11
+ # or
12
+ pnpm add jiezhangxin-utils
13
+ ```
14
+
15
+ ## Features
16
+
17
+ - ✅ **按需引入**:支持ES模块tree-shaking
18
+ - ✅ **多种格式**:CJS、ESM、UMD
19
+ - ✅ **Vue 3友好**:兼容Vue 3项目
20
+ - ✅ **类型安全**:良好的类型提示
21
+
9
22
  ## Usage
10
23
 
11
- ### In Vue 3 project
12
- // Import all utilities
13
- import * as jiezhangxinUtils from 'jiezhangxin-utils';
24
+ ### 整体引入
25
+
26
+ ```javascript
27
+ import * as utils from 'jiezhangxin-utils';
28
+
29
+ // 使用工具函数
30
+ utils.formatMoney(1000);
31
+ utils.handleViewFile('https://example.com/file.pdf');
32
+ ```
33
+
34
+ ### 按需引入(推荐)
35
+
36
+ ```javascript
37
+ import { formatMoney, handleViewFile } from 'jiezhangxin-utils';
38
+
39
+ // 只引入需要的函数
40
+ formatMoney(1000);
41
+ handleViewFile('https://example.com/file.pdf');
42
+ ```
43
+
44
+ ### 按需引入具体模块
45
+
46
+ ```javascript
47
+ // 引入工具函数
48
+ import { formatMoney } from 'jiezhangxin-utils';
14
49
 
15
- // Or import specific utilities
16
- import { formatDate, capitalize } from 'jiezhangxin-utils';
17
- ### Example
18
- // Format date
19
- console.log(formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss'));
50
+ // 引入cookie相关函数
51
+ import { getToken, setToken } from 'jiezhangxin-utils';
20
52
 
21
- // Capitalize string
22
- console.log(capitalize('hello world')); // Output: 'Hello world'
53
+ // 引入常量
54
+ import { CacheKey } from 'jiezhangxin-utils';
55
+ ```
23
56
 
24
- // Array deduplication
25
- console.log(uniqueArray([1, 2, 2, 3, 3, 3])); // Output: [1, 2, 3]
57
+ ## API
26
58
 
27
- // Local storage
28
- setLocalStorage('userInfo', { name: 'John', age: 30 });
29
- console.log(getLocalStorage('userInfo'));
30
- ## API Documentation
59
+ ### 工具函数
31
60
 
32
- ### Date Utilities
61
+ - `formatAmountToUnits(amount)` - 将金额格式化为单位数组
62
+ - `getCurrentMonth()` - 获取当前月份
63
+ - `formatMoney(money, decimalPlaces)` - 格式化金额,添加千分位
64
+ - `handleViewFile(fileUrl)` - 安全打开远程文件/PDF
65
+ - `exportFile(exportLoading, exportUrl, name)` - 导出文件
66
+ - `postExportFile(exportLoading, exportUrl, name, params)` - POST方式导出文件
67
+ - `getFileTypeFromUrlRegex(url)` - 从URL获取文件类型
33
68
 
34
- - `formatDate(date, format)`: Format date into string
35
- - `getDaysBetween(startDate, endDate)`: Get days between two dates
36
- - `isToday(date)`: Check if date is today
69
+ ### Cookie相关
37
70
 
38
- ### String Utilities
71
+ - `getToken()` - 获取token
72
+ - `setToken(token)` - 设置token
73
+ - `removeToken()` - 移除token
74
+ - `getUserInfo()` - 获取用户信息
75
+ - `setUserInfo(userInfo)` - 设置用户信息
76
+ - `removeUserInfo()` - 移除用户信息
77
+ - `getCompanyCode()` - 获取公司编码
78
+ - `setCompanyCode(code)` - 设置公司编码
79
+ - `removeCompanyCode()` - 移除公司编码
80
+ - `getCompanyName()` - 获取公司名称
81
+ - `setCompanyName(name)` - 设置公司名称
82
+ - `removeCompanyName()` - 移除公司名称
39
83
 
40
- - `trim(str)`: Remove whitespace from both ends of string
41
- - `capitalize(str)`: Capitalize the first letter of string
42
- - `maskStr(str, startLen, endLen, replaceChar)`: Mask string for privacy
43
- - `isEmail(str)`: Check if string is a valid email
44
- - `isPhone(str)`: Check if string is a valid phone number
84
+ ### 常量
45
85
 
46
- ### Array Utilities
86
+ - `CacheKey` - Cookie缓存键名常量
87
+ - `publicKey` - 公钥
88
+ - `version` - 工具库版本
47
89
 
48
- - `uniqueArray(arr)`: Remove duplicates from array
49
- - `sortArray(arr, key, isAsc)`: Sort array
50
- - `groupArray(arr, key)`: Group array by key
51
- - `flattenArray(arr)`: Flatten nested array
90
+ ## Build
52
91
 
53
- ### Storage Utilities
92
+ ```bash
93
+ # 构建生产版本
94
+ npm run build
54
95
 
55
- - `getLocalStorage(key)`: Get item from localStorage
56
- - `setLocalStorage(key, value)`: Set item to localStorage
57
- - `removeLocalStorage(key)`: Remove item from localStorage
58
- - `getSessionStorage(key)`: Get item from sessionStorage
59
- - `setSessionStorage(key, value)`: Set item to sessionStorage
60
- - `removeSessionStorage(key)`: Remove item from sessionStorage
96
+ # 开发模式(监听文件变化)
97
+ npm run dev
98
+ ```
61
99
 
62
100
  ## License
63
101