@zfqh/uniapp 0.2.18 → 0.2.20
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 +5 -5
- package/lib/utils/update.d.ts +2 -2
- package/lib/utils/update.js +16 -17
- 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.2.20](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.2.19...@zfqh/uniapp@0.2.20) (2026-06-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @zfqh/uniapp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.2.19](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.2.18...@zfqh/uniapp@0.2.19) (2026-06-25)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @zfqh/uniapp
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [0.2.18](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.2.17...@zfqh/uniapp@0.2.18) (2026-06-25)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @zfqh/uniapp
|
package/docs/api/utils/update.md
CHANGED
|
@@ -27,7 +27,7 @@ import { checkVersion, installUpdate, restartApp } from '@zfqh/uniapp';
|
|
|
27
27
|
检查指定应用是否有新版本可用。
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
|
-
function checkVersion(
|
|
30
|
+
function checkVersion(appId: string): Promise<VersionInfo | null>
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
- 返回 `VersionInfo` 表示有可用更新
|
|
@@ -50,7 +50,7 @@ function installUpdate(options: InstallOptions): void
|
|
|
50
50
|
|
|
51
51
|
```ts
|
|
52
52
|
installUpdate({
|
|
53
|
-
|
|
53
|
+
appId: 'com.example.app',
|
|
54
54
|
url: versionInfo.fileUrl || versionInfo.hotUpdateUrl,
|
|
55
55
|
progress(p) {
|
|
56
56
|
console.log(`下载进度: ${p}%`);
|
|
@@ -117,7 +117,7 @@ interface VersionInfo {
|
|
|
117
117
|
|
|
118
118
|
```ts
|
|
119
119
|
interface InstallOptions {
|
|
120
|
-
|
|
120
|
+
appId: string;
|
|
121
121
|
url: string;
|
|
122
122
|
progress?: (p: number) => void;
|
|
123
123
|
success?: () => void;
|
|
@@ -127,7 +127,7 @@ interface InstallOptions {
|
|
|
127
127
|
|
|
128
128
|
| 字段 | 说明 |
|
|
129
129
|
| --- | --- |
|
|
130
|
-
| `
|
|
130
|
+
| `appId` | 目标应用 ID |
|
|
131
131
|
| `url` | 安装包下载地址 |
|
|
132
132
|
| `progress` | 下载进度回调(0-100) |
|
|
133
133
|
| `success` | 安装成功回调 |
|
|
@@ -147,7 +147,7 @@ async function doUpdate() {
|
|
|
147
147
|
if (!url) return;
|
|
148
148
|
|
|
149
149
|
installUpdate({
|
|
150
|
-
|
|
150
|
+
appId: config.app.appId,
|
|
151
151
|
url,
|
|
152
152
|
progress(p) {
|
|
153
153
|
// 更新进度 UI
|
package/lib/utils/update.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface VersionInfo {
|
|
|
7
7
|
fileUrl: string;
|
|
8
8
|
}
|
|
9
9
|
export interface InstallOptions {
|
|
10
|
-
|
|
10
|
+
appId: string;
|
|
11
11
|
url: string;
|
|
12
12
|
progress?: (p: number) => void;
|
|
13
13
|
success?: () => void;
|
|
@@ -15,6 +15,6 @@ export interface InstallOptions {
|
|
|
15
15
|
message: string;
|
|
16
16
|
}) => void;
|
|
17
17
|
}
|
|
18
|
-
export declare function checkVersion(
|
|
18
|
+
export declare function checkVersion(appId: string): Promise<VersionInfo | null>;
|
|
19
19
|
export declare function installUpdate(options: InstallOptions): void;
|
|
20
20
|
export declare function restartApp(): void;
|
package/lib/utils/update.js
CHANGED
|
@@ -7,13 +7,13 @@ import { getLastVersion } from '../apis/core';
|
|
|
7
7
|
const { platform, brand } = SYSTEM_INFO;
|
|
8
8
|
let _installMessageHandler = null;
|
|
9
9
|
// #ifdef APP
|
|
10
|
-
function appGetProperty(
|
|
10
|
+
function appGetProperty(appId) {
|
|
11
11
|
return new Promise((resolve) => {
|
|
12
|
-
if (
|
|
12
|
+
if (appId === app.appId) {
|
|
13
13
|
plus.runtime.getProperty(String(plus.runtime.appid), (res) => resolve(res));
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
-
plus.io.resolveLocalFileSystemURL(`_doc/${
|
|
16
|
+
plus.io.resolveLocalFileSystemURL(`_doc/${appId}/manifest.json`, (entry) => {
|
|
17
17
|
entry.file((file) => {
|
|
18
18
|
const reader = new plus.io.FileReader();
|
|
19
19
|
reader.onloadend = (e) => {
|
|
@@ -32,28 +32,27 @@ function appGetProperty(appid) {
|
|
|
32
32
|
}
|
|
33
33
|
// #endif
|
|
34
34
|
// #ifdef H5
|
|
35
|
-
function h5GetProperty(
|
|
35
|
+
function h5GetProperty(appId) {
|
|
36
36
|
return new Promise((resolve) => {
|
|
37
|
-
if (
|
|
37
|
+
if (appId === app.appId) {
|
|
38
38
|
resolve({ version: ver.name, versionCode: ver.code });
|
|
39
39
|
}
|
|
40
40
|
else if (window.electron) {
|
|
41
|
-
window.electron.webUtils.getProperty(
|
|
41
|
+
window.electron.webUtils.getProperty(appId, (manifest) => resolve(manifest || {}));
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
// #endif
|
|
46
|
-
export async function checkVersion(
|
|
46
|
+
export async function checkVersion(appId) {
|
|
47
47
|
try {
|
|
48
48
|
let version = 0;
|
|
49
|
-
let packageName = appid;
|
|
50
49
|
let data = null;
|
|
51
50
|
// #ifdef APP
|
|
52
|
-
data = await appGetProperty(
|
|
51
|
+
data = await appGetProperty(appId);
|
|
53
52
|
version = data.versionCode || 0;
|
|
54
53
|
// #endif
|
|
55
54
|
// #ifdef H5
|
|
56
|
-
data = await h5GetProperty(
|
|
55
|
+
data = await h5GetProperty(appId);
|
|
57
56
|
version = data.versionCode || 0;
|
|
58
57
|
// #endif
|
|
59
58
|
let type = 1;
|
|
@@ -64,20 +63,20 @@ export async function checkVersion(appid) {
|
|
|
64
63
|
// #endif
|
|
65
64
|
const res = await getLastVersion({
|
|
66
65
|
version,
|
|
67
|
-
|
|
66
|
+
appId,
|
|
68
67
|
type,
|
|
69
|
-
platform: { android: 1, ios: 2, windows: 4 }[platform],
|
|
68
|
+
platform: { android: '1', ios: '2', harmony: '3', windows: '4', macos: '5' }[platform],
|
|
70
69
|
}, { custom: { message: false } });
|
|
71
70
|
const lastVer = { ...res?.data };
|
|
72
71
|
// #ifdef APP
|
|
73
|
-
if (uni.$store?.state?.dict && platform === 'android' &&
|
|
72
|
+
if (uni.$store?.state?.dict && platform === 'android' && appId === app.appId && env.key === 'prod') {
|
|
74
73
|
await uni.$store.dispatch('getDictInfo', { name: 'group_relation', cache: true });
|
|
75
74
|
if (uni.$store.state.dict.info.group_relation?.values?.includes(brand)) {
|
|
76
75
|
lastVer.hotUpdateUrl = '';
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
// #endif
|
|
80
|
-
if (
|
|
79
|
+
if (Number(lastVer.version) > Number(version)) {
|
|
81
80
|
return lastVer;
|
|
82
81
|
}
|
|
83
82
|
return null;
|
|
@@ -87,14 +86,14 @@ export async function checkVersion(appid) {
|
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
// #ifdef APP
|
|
90
|
-
function appInstall({
|
|
89
|
+
function appInstall({ appId, url, progress, success, fail }) {
|
|
91
90
|
const downloadTask = uni.downloadFile({
|
|
92
91
|
url,
|
|
93
92
|
success(res) {
|
|
94
93
|
if (res.statusCode !== 200)
|
|
95
94
|
return fail?.({ message: 'download failed' });
|
|
96
95
|
progress?.(100);
|
|
97
|
-
if (
|
|
96
|
+
if (appId === app.appId) {
|
|
98
97
|
plus.runtime.install(res.tempFilePath, { force: true }, success, fail);
|
|
99
98
|
}
|
|
100
99
|
else {
|
|
@@ -116,7 +115,7 @@ function h5Install(options) {
|
|
|
116
115
|
postMessage({
|
|
117
116
|
type: TYPES.MESSAGE.APP_INSTALL,
|
|
118
117
|
payload: {
|
|
119
|
-
|
|
118
|
+
appId: options.appId,
|
|
120
119
|
url: options.url,
|
|
121
120
|
},
|
|
122
121
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zfqh/uniapp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.20",
|
|
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": "795623145cc7dc0f0f9f7a1970a7a020b7bef16c"
|
|
50
50
|
}
|