@zfqh/uniapp 0.3.15 → 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 CHANGED
@@ -3,6 +3,14 @@
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
+
6
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)
7
15
 
8
16
  **Note:** Version bump only for package @zfqh/uniapp
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 aniu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -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
 
@@ -118,10 +118,6 @@ export async function requestPermission(name, system = true) {
118
118
  break;
119
119
  }
120
120
  case 'storage': {
121
- result = await requestMpPermission('scope.userLocation');
122
- break;
123
- }
124
- case 'bluetooth': {
125
121
  break;
126
122
  }
127
123
  default: {
@@ -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;
@@ -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
- // #ifdef APP
55
- info = await appGetProperty(appId, options.path);
56
- version = Number(info.versionCode || 0);
57
- // #endif
58
- // #ifdef H5
59
- info = await h5GetProperty(appId, options.path);
60
- version = Number(info.versionCode || 0);
61
- // #endif
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
- if (appId === app.appId) {
111
- plus.runtime.install(res.tempFilePath, { force: true }, success, fail);
112
- }
113
- else {
114
- plus.io.resolveLocalFileSystemURL('_doc/', (docDir) => {
115
- if (path) {
116
- docDir.getDirectory(path, { create: true }, (subDir) => {
117
- plus.zip.decompress(res.tempFilePath, subDir.fullPath, success, fail);
118
- }, (e) => fail?.({ message: e?.message || String(e) }));
119
- }
120
- else {
121
- plus.zip.decompress(res.tempFilePath, docDir.fullPath, success, fail);
122
- }
123
- }, (e) => fail?.({ message: e?.message || String(e) }));
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 }) => 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.15",
3
+ "version": "0.3.16",
4
4
  "description": "uniapp公共模块",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "MIT",
@@ -45,5 +45,6 @@
45
45
  "@types/crypto-js": "^4.2.2",
46
46
  "@types/qs": "^6.9.16",
47
47
  "@types/url-parse": "^1.4.11"
48
- }
48
+ },
49
+ "gitHead": "482fb66642df55a676ac10fb902cba10da3720d2"
49
50
  }