@base-web-kits/base-tools-ts 0.9.1 → 0.9.3
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 +65 -8
- package/package.json +46 -45
package/README.md
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
# Base Tools
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Web前端团队常用工具库,包含`ts`、`web`、`react`、`vue`、`uni`模块。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## 📖 在线文档
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
[https://gancao-web.github.io/base-tools/](https://gancao-web.github.io/base-tools/)
|
|
8
|
+
|
|
9
|
+
## 🚀 快速开始
|
|
10
|
+
|
|
11
|
+
### 安装
|
|
12
|
+
|
|
13
|
+
- 按需安装即可,模块之间不相互依赖
|
|
14
|
+
- 非ts环境和普通h5也能使用,因为所有函数已编译为es5
|
|
8
15
|
|
|
9
16
|
```js
|
|
10
|
-
// 通用
|
|
17
|
+
// 通用TS/JS模块
|
|
11
18
|
npm i @base-web-kits/base-tools-ts
|
|
12
19
|
|
|
13
20
|
// Web 模块
|
|
@@ -23,14 +30,14 @@ npm i @base-web-kits/base-tools-vue
|
|
|
23
30
|
npm i @base-web-kits/base-tools-uni
|
|
24
31
|
```
|
|
25
32
|
|
|
26
|
-
|
|
33
|
+
### 使用
|
|
27
34
|
|
|
28
35
|
```ts
|
|
29
|
-
// 通用
|
|
36
|
+
// 通用TS/JS模块
|
|
30
37
|
import { toDayjs, getUrlParam, toMaskPhone } from '@base-web-kits/base-tools-ts';
|
|
31
38
|
|
|
32
39
|
// Web 模块
|
|
33
|
-
import { copyText, isPC,
|
|
40
|
+
import { copyText, isPC, setCookie } from '@base-web-kits/base-tools-web';
|
|
34
41
|
|
|
35
42
|
// React 模块
|
|
36
43
|
import { useCountDown } from '@base-web-kits/base-tools-react';
|
|
@@ -39,5 +46,55 @@ import { useCountDown } from '@base-web-kits/base-tools-react';
|
|
|
39
46
|
import { useResizeObserver } from '@base-web-kits/base-tools-vue';
|
|
40
47
|
|
|
41
48
|
// Uni 模块
|
|
42
|
-
import { chooseMedia, toPayWx } from '@base-web-kits/base-tools-uni';
|
|
49
|
+
import { setAppConfig, chooseMedia, toPayWx } from '@base-web-kits/base-tools-uni';
|
|
50
|
+
|
|
51
|
+
setAppConfig({
|
|
52
|
+
pathHome: '/pages/tabbar/home/index',
|
|
53
|
+
pathLogin: '/pages/login/index',
|
|
54
|
+
pathWebview: '/pages/webview/index',
|
|
55
|
+
hostFile: 'https://xx.com/',
|
|
56
|
+
hostIcon: 'https://xx.com/xx/',
|
|
57
|
+
isTabBar: (url) => url.startsWith('/pages/tabbar/'),
|
|
58
|
+
isLogin: () => useUserStore().isLogin,
|
|
59
|
+
log: (level, data) => console.log({ level, data }),
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 普通h5
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<!DOCTYPE html>
|
|
67
|
+
<html>
|
|
68
|
+
<head>
|
|
69
|
+
<title>Base Tools 示例</title>
|
|
70
|
+
</head>
|
|
71
|
+
<body>
|
|
72
|
+
<script src="https://cdn.jsdelivr.net/npm/@base-web-kits/base-tools-ts@1.0.0/dist/base-tools-ts.umd.global.js"></script>
|
|
73
|
+
<script src="https://cdn.jsdelivr.net/npm/@base-web-kits/base-tools-web@1.0.0/dist/base-tools-web.umd.global.js"></script>
|
|
74
|
+
|
|
75
|
+
<script>
|
|
76
|
+
// 使用 base-tools-ts 中的函数
|
|
77
|
+
const { createTimeRandId, EventBus } = baseToolsTS;
|
|
78
|
+
|
|
79
|
+
// 使用 base-tools-web 中的函数
|
|
80
|
+
const { getCookie, setCookie } = baseToolsWeb;
|
|
81
|
+
|
|
82
|
+
// 示例:创建随机ID
|
|
83
|
+
const id = createTimeRandId();
|
|
84
|
+
console.log('随机ID:', id);
|
|
85
|
+
|
|
86
|
+
// 示例:使用EventBus
|
|
87
|
+
const emitter = new EventBus();
|
|
88
|
+
emitter.on('test', (data) => {
|
|
89
|
+
console.log('收到事件:', data);
|
|
90
|
+
});
|
|
91
|
+
emitter.emit('test', 'Hello World!');
|
|
92
|
+
|
|
93
|
+
// 示例:操作Cookie
|
|
94
|
+
setCookie('name', 'Base Tools', 7);
|
|
95
|
+
const name = getCookie('name');
|
|
96
|
+
console.log('Cookie值:', name);
|
|
97
|
+
</script>
|
|
98
|
+
</body>
|
|
99
|
+
</html>
|
|
43
100
|
```
|
package/package.json
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@base-web-kits/base-tools-ts",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"sideEffects": false,
|
|
5
|
-
"description": "Independent TS utilities package built from src/ts.",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"base-tools",
|
|
8
|
-
"ts",
|
|
9
|
-
"utilities",
|
|
10
|
-
"thin-wrapper"
|
|
11
|
-
],
|
|
12
|
-
"license": "MIT",
|
|
13
|
-
"main": "./index.cjs",
|
|
14
|
-
"module": "./index.js",
|
|
15
|
-
"types": "./index.d.ts",
|
|
16
|
-
"typesVersions": {
|
|
17
|
-
"*": {
|
|
18
|
-
"*": [
|
|
19
|
-
"./dist/*"
|
|
20
|
-
],
|
|
21
|
-
"index": [
|
|
22
|
-
"./dist/index.d.ts"
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"files": [
|
|
27
|
-
"dist",
|
|
28
|
-
"index.d.ts",
|
|
29
|
-
"index.js",
|
|
30
|
-
"index.cjs",
|
|
31
|
-
"base-tools-ts.umd.global.js",
|
|
32
|
-
"base-tools-ts.umd.global.js.map",
|
|
33
|
-
"README.md"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@base-web-kits/base-tools-ts",
|
|
3
|
+
"version": "0.9.3",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"description": "Independent TS utilities package built from src/ts.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"base-tools",
|
|
8
|
+
"ts",
|
|
9
|
+
"utilities",
|
|
10
|
+
"thin-wrapper"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"main": "./index.cjs",
|
|
14
|
+
"module": "./index.js",
|
|
15
|
+
"types": "./index.d.ts",
|
|
16
|
+
"typesVersions": {
|
|
17
|
+
"*": {
|
|
18
|
+
"*": [
|
|
19
|
+
"./dist/*"
|
|
20
|
+
],
|
|
21
|
+
"index": [
|
|
22
|
+
"./dist/index.d.ts"
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"index.d.ts",
|
|
29
|
+
"index.js",
|
|
30
|
+
"index.cjs",
|
|
31
|
+
"base-tools-ts.umd.global.js",
|
|
32
|
+
"base-tools-ts.umd.global.js.map",
|
|
33
|
+
"README.md",
|
|
34
|
+
"src"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"lodash-es": "^4.17.21",
|
|
38
|
+
"@types/lodash-es": "^4.17.12",
|
|
39
|
+
"bignumber.js": "^9.1.2",
|
|
40
|
+
"dayjs": "^1.11.19",
|
|
41
|
+
"mitt": "^3.0.1"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"registry": "https://registry.npmjs.org"
|
|
45
|
+
}
|
|
46
|
+
}
|