share-light 0.0.5 → 1.0.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/LICENSE +9 -0
- package/README.md +21 -18
- package/lib/index.js +2 -4
- package/package.json +4 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 novlan1
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# 分享 SDK
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://img.shields.io/npm/dw/share-light">
|
|
5
|
+
<img src="https://img.shields.io/npm/unpacked-size/share-light">
|
|
6
|
+
<img src="https://img.shields.io/npm/v/share-light">
|
|
7
|
+
<img src="https://img.shields.io/npm/l/share-light">
|
|
8
|
+
<img src="https://img.shields.io/github/last-commit/novlan1/plugin-light">
|
|
9
|
+
<img src="https://img.shields.io/github/created-at/novlan1/plugin-light">
|
|
10
|
+
</p>
|
|
2
11
|
|
|
3
12
|
轻量级的分享 SDK。支持以下渠道
|
|
4
13
|
|
|
@@ -7,11 +16,11 @@
|
|
|
7
16
|
3. QQ、微信
|
|
8
17
|
4. 其他,包括系统浏览器
|
|
9
18
|
|
|
10
|
-
|
|
19
|
+
## 1. 如何使用
|
|
11
20
|
|
|
12
21
|
可直接引入,也可异步加载。
|
|
13
22
|
|
|
14
|
-
|
|
23
|
+
### 1.1. 直接引入
|
|
15
24
|
|
|
16
25
|
安装:
|
|
17
26
|
|
|
@@ -36,7 +45,7 @@ initShare({
|
|
|
36
45
|
openShareUI();
|
|
37
46
|
```
|
|
38
47
|
|
|
39
|
-
|
|
48
|
+
### 1.2. 异步加载
|
|
40
49
|
|
|
41
50
|
也可异步加载,并使用其提供的全局变量 `shareLightSDK`,性能更佳。
|
|
42
51
|
|
|
@@ -101,8 +110,7 @@ export function setupWzydShare(url: string) {
|
|
|
101
110
|
}
|
|
102
111
|
```
|
|
103
112
|
|
|
104
|
-
|
|
105
|
-
### 2. 类型
|
|
113
|
+
## 2. 类型
|
|
106
114
|
|
|
107
115
|
```ts
|
|
108
116
|
export const SHARE_TYPE_MAP = {
|
|
@@ -164,8 +172,7 @@ export interface ShareUIObject {
|
|
|
164
172
|
}
|
|
165
173
|
```
|
|
166
174
|
|
|
167
|
-
|
|
168
|
-
### 3. 内部配置
|
|
175
|
+
## 3. 内部配置
|
|
169
176
|
|
|
170
177
|
默认分享图片和提示文案等,可通过 `initShare` 参数覆盖。
|
|
171
178
|
|
|
@@ -181,15 +188,13 @@ export const DEFAULT_TIP_MAP = {
|
|
|
181
188
|
};
|
|
182
189
|
```
|
|
183
190
|
|
|
184
|
-
|
|
191
|
+
## 4. 更新日志
|
|
185
192
|
|
|
186
193
|
[点此查看](./CHANGELOG.md)
|
|
187
194
|
|
|
195
|
+
## 5. 制作背景
|
|
188
196
|
|
|
189
|
-
### 5.
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
#### 5.1. 当前痛点
|
|
197
|
+
### 5.1. 当前痛点
|
|
193
198
|
|
|
194
199
|
1. 引入了`jsapi`,体积太大,文件太多,可读性、可维护性太差。本来就是非常简单的东西,加载`sdk`、调用全局变量即可,现在变得非常麻烦
|
|
195
200
|
2. 类型缺失,使用、阅读、开发、调试困难
|
|
@@ -213,7 +218,7 @@ export const DEFAULT_TIP_MAP = {
|
|
|
213
218
|
<img src="https://mike-1255355338.cos.ap-guangzhou.myqcloud.com/article/2025/3/own_mike_d45c10acbf304f3975.png" width="600">
|
|
214
219
|
|
|
215
220
|
|
|
216
|
-
|
|
221
|
+
### 5.2. 优化思路
|
|
217
222
|
|
|
218
223
|
1. 去掉 `jsapi`
|
|
219
224
|
2. 补充类型提示
|
|
@@ -231,7 +236,7 @@ export const DEFAULT_TIP_MAP = {
|
|
|
231
236
|
6. `getEnvVersion` 去掉,没找到需要它的地方
|
|
232
237
|
7. `isTestEnv`,同样去掉
|
|
233
238
|
|
|
234
|
-
|
|
239
|
+
## 6. 效果
|
|
235
240
|
|
|
236
241
|
减少 `85KB`。
|
|
237
242
|
|
|
@@ -243,9 +248,7 @@ export const DEFAULT_TIP_MAP = {
|
|
|
243
248
|
|
|
244
249
|
<img src="https://mike-1255355338.cos.ap-guangzhou.myqcloud.com/article/2025/3/own_mike_8f266681fa965b8410.png" width="600">
|
|
245
250
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
### 7. 其他
|
|
251
|
+
## 7. 其他
|
|
249
252
|
|
|
250
253
|
更新为异步后,每次修改 `share-light`,需要:
|
|
251
254
|
|
package/lib/index.js
CHANGED
|
@@ -378,8 +378,7 @@
|
|
|
378
378
|
};
|
|
379
379
|
|
|
380
380
|
/**
|
|
381
|
-
*
|
|
382
|
-
* @description 根据传入的参数,移除原来的所有参数,根据传入的 keepParamsObj 进行重新拼接地址,以 hash 模式返回
|
|
381
|
+
* 根据传入的参数,移除原来的所有参数,根据传入的 keepParamsObj 进行重新拼接地址,以 hash 模式返回
|
|
383
382
|
* @param {string} url 地址
|
|
384
383
|
* @param {object} keepParamsObj 参数对象
|
|
385
384
|
* @returns 只有传入参数的地址
|
|
@@ -438,8 +437,7 @@
|
|
|
438
437
|
}
|
|
439
438
|
|
|
440
439
|
/**
|
|
441
|
-
*
|
|
442
|
-
* @description 提取链接参数,兼容hash模式和history模式,以及拼接异常情况
|
|
440
|
+
* 提取链接参数,兼容hash模式和history模式,以及拼接异常情况
|
|
443
441
|
* @param {string} [url=''] 地址
|
|
444
442
|
* @param {string} [key=''] 可选,若不为空,则提取返回该key对应的参数值
|
|
445
443
|
* @returns 地址参数对象,或者是指定参数值
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "share-light",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "轻量级的分享SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plugin-light",
|
|
7
7
|
"share-light",
|
|
8
8
|
"share-sdk"
|
|
9
9
|
],
|
|
10
|
-
"homepage": "https://novlan1.github.io/plugin-light/zh/share-light.html",
|
|
10
|
+
"homepage": "https://novlan1.github.io/docs/plugin-light/zh/share-light.html",
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/novlan1/plugin-light/issues"
|
|
13
13
|
},
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"url": "https://github.com/novlan1/plugin-light"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"author": "
|
|
19
|
+
"author": "novlan1",
|
|
20
20
|
"sideEffects": "false",
|
|
21
21
|
"main": "./lib/index",
|
|
22
22
|
"files": [
|
|
23
23
|
"lib"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"t-comm": "^1.5.
|
|
26
|
+
"t-comm": "^1.5.40"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": "12.x || 14.x || >= 16"
|