@zfqh/uniapp 0.3.15 → 0.3.17

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,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.17](http://10.10.10.16/caoben/front-end/compare/@zfqh/uniapp@0.3.16...@zfqh/uniapp@0.3.17) (2026-09-03)
7
+
8
+ **Note:** Version bump only for package @zfqh/uniapp
9
+
10
+
11
+
12
+
13
+
14
+ ## [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)
15
+
16
+ **Note:** Version bump only for package @zfqh/uniapp
17
+
18
+
19
+
20
+
21
+
6
22
  ## [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
23
 
8
24
  **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.
@@ -192,10 +192,37 @@ if (config.mp.envVersion === MP_ENV_VERSION.develop) {
192
192
 
193
193
  ## LANGUAGE 使用示例
194
194
 
195
- 当前语言标识,用于请求 header 和国际化。
195
+ 当前语言标识,用于请求 header 和国际化。key 为 uni-app/vue-i18n 的 locale 标识,value 为请求头 `X-Language` 的语言代码。
196
196
 
197
197
  ```ts
198
198
  import { LANGUAGE } from '@zfqh/uniapp';
199
199
 
200
- headers['X-Language'] = LANGUAGE;
200
+ // locale 取 uni.getLocale() / uni.$i18n.global.locale 或宿主传入的 query.locale
201
+ headers['X-Language'] = LANGUAGE[locale];
201
202
  ```
203
+
204
+ ### 支持的语言
205
+
206
+ | 分组 | locale key | 语言 | X-Language 值 |
207
+ | --- | --- | --- | --- |
208
+ | 亚洲语言 | `zh-Hans` | 简体中文 | `zh-CN` |
209
+ | 亚洲语言 | `zh-Hant` | 繁体中文 | `zh-TW` |
210
+ | 亚洲语言 | `ja` | 日语 | `ja-JP` |
211
+ | 亚洲语言 | `ko` | 韩语 | `ko-KR` |
212
+ | 亚洲语言 | `ar` | 阿拉伯语 | `ar-SA` |
213
+ | 亚洲语言 | `fa` | 伊朗语(波斯语) | `fa-IR` |
214
+ | 亚洲语言 | `th` | 泰语 | `th-TH` |
215
+ | 亚洲语言 | `vi` | 越南语 | `vi-VN` |
216
+ | 亚洲语言 | `my` | 缅甸语 | `my-MM` |
217
+ | 亚洲语言 | `km` | 柬埔寨语 | `km-KH` |
218
+ | 欧洲语言 | `en` | 英语 | `en-US` |
219
+ | 欧洲语言 | `fr` | 法语 | `fr-FR` |
220
+ | 欧洲语言 | `es` | 西班牙语 | `es-ES` |
221
+ | 欧洲语言 | `ru` | 俄语 | `ru-RU` |
222
+ | 欧洲语言 | `pt` | 葡萄牙语 | `pt-PT` |
223
+ | 欧洲语言 | `de` | 德语 | `de-DE` |
224
+ | 欧洲语言 | `it` | 意大利语 | `it-IT` |
225
+ | 欧洲语言 | `el` | 希腊语 | `el-GR` |
226
+ | 欧洲语言 | `pl` | 波兰语 | `pl-PL` |
227
+
228
+ > **提示**:`LANGUAGE[uni.getLocale()]` 仅在对应 locale 已注册到业务侧 vue-i18n `messages` 时才能命中;未注册时 `uni.getLocale()` 会回退到 `fallbackLocale`(`zh-Hans`)。宿主可通过 `query.locale`(如 `?locale=ar`)直接指定语言。
@@ -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
 
@@ -36,7 +36,7 @@ http.interceptors.request.use((conf) => {
36
36
  }
37
37
  // #endif
38
38
  const header = {
39
- 'X-Language': LANGUAGE[query.locale || uni.getLocale()],
39
+ 'X-Language': query.xLanguage || LANGUAGE[query.locale || uni.getLocale()],
40
40
  'Tenant-Id': tenantId || 1,
41
41
  channel,
42
42
  terminal,
@@ -1,6 +1,6 @@
1
1
  import Url from 'url-parse';
2
2
  import { stringify, parse } from 'qs';
3
- import { PLATFORM_CODE, IS_WEBVIEW_ENV, SYSTEM_INFO, TYPES } from '../utils/consts';
3
+ import { PLATFORM_CODE, IS_WEBVIEW_ENV, SYSTEM_INFO, TYPES, LANGUAGE } from '../utils/consts';
4
4
  import app from '../configs/app';
5
5
  import { requestPermission, openAuthorizeSetting } from '../utils/permit';
6
6
  import web from '../configs/web';
@@ -39,6 +39,7 @@ export default {
39
39
  safeTop: SYSTEM_INFO.safeAreaInsets.top,
40
40
  safeBottom: SYSTEM_INFO.safeAreaInsets.bottom,
41
41
  locale: uni.$i18n?.global?.locale,
42
+ xLanguage: LANGUAGE[uni.$i18n?.global?.locale],
42
43
  accelerate: cdn.isAccelerate ? 1 : undefined,
43
44
  };
44
45
  if (query.primary) {
@@ -30,9 +30,22 @@ export declare const LANGUAGE: {
30
30
  'zh-Hans': string;
31
31
  'zh-Hant': string;
32
32
  ja: string;
33
+ ko: string;
34
+ ar: string;
35
+ fa: string;
36
+ th: string;
37
+ vi: string;
38
+ my: string;
39
+ km: string;
33
40
  en: string;
34
41
  fr: string;
35
42
  es: string;
43
+ ru: string;
44
+ pt: string;
45
+ de: string;
46
+ it: string;
47
+ el: string;
48
+ pl: string;
36
49
  };
37
50
  export declare const TYPES: {
38
51
  readonly MESSAGE: {
@@ -60,12 +60,27 @@ export var CHANNEL;
60
60
  CHANNEL[CHANNEL["\u95E8\u5E97\u7AEF"] = 3] = "\u95E8\u5E97\u7AEF";
61
61
  })(CHANNEL || (CHANNEL = {}));
62
62
  export const LANGUAGE = {
63
- 'zh-Hans': 'zh-CN',
64
- 'zh-Hant': 'zh-TW',
65
- ja: 'ja-JP',
66
- en: 'en-US',
67
- fr: 'fr-FR',
68
- es: 'es-ES',
63
+ // 亚洲语言
64
+ 'zh-Hans': 'zh-CN', // 简体中文
65
+ 'zh-Hant': 'zh-TW', // 繁体中文
66
+ ja: 'ja-JP', // 日语
67
+ ko: 'ko-KR', // 韩语
68
+ ar: 'ar-SA', // 阿拉伯语
69
+ fa: 'fa-IR', // 伊朗语(波斯语)
70
+ th: 'th-TH', // 泰语
71
+ vi: 'vi-VN', // 越南语
72
+ my: 'my-MM', // 缅甸语
73
+ km: 'km-KH', // 柬埔寨语
74
+ // 欧洲语言
75
+ en: 'en-US', // 英语
76
+ fr: 'fr-FR', // 法语
77
+ es: 'es-ES', // 西班牙语
78
+ ru: 'ru-RU', // 俄语
79
+ pt: 'pt-PT', // 葡萄牙语
80
+ de: 'de-DE', // 德语
81
+ it: 'it-IT', // 意大利语
82
+ el: 'el-GR', // 希腊语
83
+ pl: 'pl-PL', // 波兰语
69
84
  };
70
85
  // webview 与宿主环境通信的消息类型
71
86
  export const TYPES = {
@@ -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.17",
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": "d56ac10822cd04b832695122cc7daa21e67d6628"
49
50
  }