@zfqh/uniapp 0.3.14 → 0.3.16
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/CHANGELOG.md +16 -0
- package/docs/api/utils/update.md +23 -2
- package/lib/utils/permit.js +0 -4
- package/lib/utils/query.js +1 -2
- package/lib/utils/update.d.ts +4 -0
- package/lib/utils/update.js +36 -25
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.3.16](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.3.15...@zfqh/uniapp@0.3.16) (2026-09-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @zfqh/uniapp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.3.15](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.3.14...@zfqh/uniapp@0.3.15) (2026-08-28)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @zfqh/uniapp
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [0.3.14](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.3.13...@zfqh/uniapp@0.3.14) (2026-08-15)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @zfqh/uniapp
|
package/docs/api/utils/update.md
CHANGED
|
@@ -31,7 +31,7 @@ function checkVersion(options: CheckVersionOptions): Promise<CheckVersionResult>
|
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
- `code`: `0` 表示无更新或检查失败,`1` 表示有新版本可用
|
|
34
|
-
- `data.info`: 本地版本信息(`versionCode` 已归一化为 `number
|
|
34
|
+
- `data.info`: 本地版本信息(`versionCode` 已归一化为 `number`);传入 `versionCode` 时即为传入值
|
|
35
35
|
- `data.latest`: 远端最新版本信息(`VersionInfo`),无数据时为 `undefined`
|
|
36
36
|
- `message`: 失败时的错误信息
|
|
37
37
|
|
|
@@ -42,6 +42,21 @@ if (code === 1 && data.latest) {
|
|
|
42
42
|
}
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
下载失败重试时,建议回传首次检查记住的 `data.info`,跳过本地版本读取,以首次基线重新对比,避免期间本地版本发生变化导致 `code` 返回 `0`:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// 首次检查:记住基线
|
|
49
|
+
const { code, data } = await checkVersion({ appId: 'com.example.app' });
|
|
50
|
+
const info = data.info;
|
|
51
|
+
|
|
52
|
+
// 重试:传入首次基线版本
|
|
53
|
+
const retry = await checkVersion({
|
|
54
|
+
appId: 'com.example.app',
|
|
55
|
+
versionCode: info.versionCode,
|
|
56
|
+
versionName: info.versionName,
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
45
60
|
### installUpdate
|
|
46
61
|
|
|
47
62
|
下载并安装更新包。
|
|
@@ -98,12 +113,18 @@ restartApp();
|
|
|
98
113
|
```ts
|
|
99
114
|
interface CheckVersionOptions {
|
|
100
115
|
appId: string;
|
|
116
|
+
path?: string;
|
|
117
|
+
versionCode?: number;
|
|
118
|
+
versionName?: string;
|
|
101
119
|
}
|
|
102
120
|
```
|
|
103
121
|
|
|
104
122
|
| 字段 | 说明 |
|
|
105
123
|
| --- | --- |
|
|
106
124
|
| `appId` | 目标应用 ID |
|
|
125
|
+
| `path` | 子应用安装目录,App 端用于读取本地 `manifest.json`(默认 `_doc/`) |
|
|
126
|
+
| `versionCode` | 指定本地版本号(`number`)。传入后跳过本地 manifest 读取,直接以该值作为检查基线(下载失败重试场景) |
|
|
127
|
+
| `versionName` | 指定本地版本名称,与 `versionCode` 配套,回填到返回的 `data.info` |
|
|
107
128
|
|
|
108
129
|
### CheckVersionResult
|
|
109
130
|
|
|
@@ -163,7 +184,7 @@ interface InstallOptions {
|
|
|
163
184
|
| --- | --- |
|
|
164
185
|
| `appId` | 目标应用 ID |
|
|
165
186
|
| `url` | 安装包下载地址 |
|
|
166
|
-
| `progress` | 下载进度回调(0-100) |
|
|
187
|
+
| `progress` | 下载进度回调(0-99 的整数,下载完成时回调 100) |
|
|
167
188
|
| `success` | 安装成功回调 |
|
|
168
189
|
| `fail` | 安装失败回调 |
|
|
169
190
|
|
package/lib/utils/permit.js
CHANGED
package/lib/utils/query.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
const query = {};
|
|
2
2
|
export function parseQuery(search = '') {
|
|
3
|
-
search = decodeURIComponent(search);
|
|
4
3
|
const q = {};
|
|
5
4
|
search.split('&').forEach((value) => {
|
|
6
5
|
const [key, val] = value.split('=');
|
|
7
|
-
q[key] = val;
|
|
6
|
+
q[key] = decodeURIComponent(val);
|
|
8
7
|
});
|
|
9
8
|
return q;
|
|
10
9
|
}
|
package/lib/utils/update.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export interface InstallOptions {
|
|
|
19
19
|
export interface CheckVersionOptions {
|
|
20
20
|
appId: string;
|
|
21
21
|
path?: string;
|
|
22
|
+
/** 指定本地版本号,传入后跳过本地 manifest 读取(重试场景) */
|
|
23
|
+
versionCode?: number;
|
|
24
|
+
/** 指定本地版本名称,与 versionCode 配套 */
|
|
25
|
+
versionName?: string;
|
|
22
26
|
}
|
|
23
27
|
export declare function checkVersion(options: CheckVersionOptions): Promise<{
|
|
24
28
|
code: number;
|
package/lib/utils/update.js
CHANGED
|
@@ -44,21 +44,27 @@ function h5GetProperty(appId, path) {
|
|
|
44
44
|
}
|
|
45
45
|
// #endif
|
|
46
46
|
export async function checkVersion(options) {
|
|
47
|
-
const { appId } = options;
|
|
47
|
+
const { appId, versionCode = 0, versionName = '' } = options || {};
|
|
48
48
|
let info;
|
|
49
49
|
let latest;
|
|
50
50
|
let code = 0;
|
|
51
51
|
let message = '';
|
|
52
52
|
try {
|
|
53
53
|
let version = 0;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
if (options?.versionCode != null) {
|
|
55
|
+
info = { versionCode, versionName };
|
|
56
|
+
version = Number(info.versionCode || 0);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// #ifdef APP
|
|
60
|
+
info = await appGetProperty(appId, options.path);
|
|
61
|
+
version = Number(info.versionCode || 0);
|
|
62
|
+
// #endif
|
|
63
|
+
// #ifdef H5
|
|
64
|
+
info = await h5GetProperty(appId, options.path);
|
|
65
|
+
version = Number(info.versionCode || 0);
|
|
66
|
+
// #endif
|
|
67
|
+
}
|
|
62
68
|
info.versionCode = version;
|
|
63
69
|
let type = 3;
|
|
64
70
|
let plat;
|
|
@@ -107,25 +113,30 @@ function appInstall({ appId, url, path, progress, success, fail }) {
|
|
|
107
113
|
if (res.statusCode !== 200)
|
|
108
114
|
return fail?.({ message: 'download failed' });
|
|
109
115
|
progress?.(100);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
if (appId === app.appId) {
|
|
118
|
+
plus.runtime.install(res.tempFilePath, { force: true }, success, fail);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
plus.io.resolveLocalFileSystemURL('_doc/', (docDir) => {
|
|
122
|
+
if (path) {
|
|
123
|
+
docDir.getDirectory(path, { create: true }, (subDir) => {
|
|
124
|
+
plus.zip.decompress(res.tempFilePath, subDir.fullPath, success, fail);
|
|
125
|
+
}, (e) => fail?.({ message: e?.message || String(e) }));
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
plus.zip.decompress(res.tempFilePath, docDir.fullPath, success, fail);
|
|
129
|
+
}
|
|
130
|
+
}, (e) => fail?.({ message: e?.message || String(e) }));
|
|
131
|
+
}
|
|
132
|
+
}, 1000);
|
|
125
133
|
},
|
|
126
134
|
fail: (e) => fail?.({ message: e?.errMsg || String(e) }),
|
|
127
135
|
});
|
|
128
|
-
downloadTask.onProgressUpdate(({ progress: p }) =>
|
|
136
|
+
downloadTask.onProgressUpdate(({ progress: p }) => {
|
|
137
|
+
const value = Number.isFinite(p) ? Math.min(99, Math.max(0, Math.floor(p))) : 0;
|
|
138
|
+
progress?.(value);
|
|
139
|
+
});
|
|
129
140
|
}
|
|
130
141
|
// #endif
|
|
131
142
|
// #ifdef H5
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zfqh/uniapp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.16",
|
|
4
4
|
"description": "uniapp公共模块",
|
|
5
5
|
"author": "yinjiazeng@163.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/qs": "^6.9.16",
|
|
47
47
|
"@types/url-parse": "^1.4.11"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "482fb66642df55a676ac10fb902cba10da3720d2"
|
|
50
50
|
}
|