stellar-ui-plus 1.25.11 → 1.25.13
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.
|
@@ -8,6 +8,7 @@ export interface AppUpdateProps {
|
|
|
8
8
|
appVersion: string;
|
|
9
9
|
zIndex: number;
|
|
10
10
|
fallbackApiUrl: string;
|
|
11
|
+
strictVersionCheck: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export default {
|
|
@@ -82,4 +83,11 @@ export default {
|
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
},
|
|
86
|
+
strictVersionCheck: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: false,
|
|
89
|
+
validator: (value: boolean) => {
|
|
90
|
+
return typeof value === 'boolean';
|
|
91
|
+
}
|
|
92
|
+
},
|
|
85
93
|
} satisfies Record<keyof AppUpdateProps, any>;
|
|
@@ -54,6 +54,12 @@
|
|
|
54
54
|
"type": "string",
|
|
55
55
|
"default": ""
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
"name": "strictVersionCheck",
|
|
59
|
+
"description": "严格版本检查,设为true时只有新版本大于当前版本才触发更新;开启后若服务端返回lastAllDetail且当前版本低于最后一次全量包版本,会优先使用全量包(apk)升级",
|
|
60
|
+
"type": "boolean",
|
|
61
|
+
"default": "false"
|
|
62
|
+
},
|
|
57
63
|
{
|
|
58
64
|
"name": "[event]cancel",
|
|
59
65
|
"description": "取消更新时触发"
|
|
@@ -91,6 +91,20 @@ const isVersionSkipped = (versionCode: string) => {
|
|
|
91
91
|
return skippedVersions.value.includes(versionCode);
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
+
const compareVersions = (newVersion: string, currentVersion: string): number => {
|
|
95
|
+
const newParts = newVersion.split('.').map(v => parseInt(v) || 0);
|
|
96
|
+
const currentParts = currentVersion.split('.').map(v => parseInt(v) || 0);
|
|
97
|
+
const maxLength = Math.max(newParts.length, currentParts.length);
|
|
98
|
+
|
|
99
|
+
for (let i = 0; i < maxLength; i++) {
|
|
100
|
+
const newPart = newParts[i] || 0;
|
|
101
|
+
const currentPart = currentParts[i] || 0;
|
|
102
|
+
if (newPart > currentPart) return 1;
|
|
103
|
+
if (newPart < currentPart) return -1;
|
|
104
|
+
}
|
|
105
|
+
return 0;
|
|
106
|
+
};
|
|
107
|
+
|
|
94
108
|
// 跳过当前版本
|
|
95
109
|
const skipVersion = () => {
|
|
96
110
|
if (!data.code) return;
|
|
@@ -167,12 +181,35 @@ const getData = async (callback?: (resVersion: { name: string; code: string; upd
|
|
|
167
181
|
return;
|
|
168
182
|
}
|
|
169
183
|
|
|
170
|
-
|
|
171
|
-
data.
|
|
172
|
-
data.
|
|
173
|
-
data.
|
|
174
|
-
data.
|
|
175
|
-
data.
|
|
184
|
+
const responseData = _data.data;
|
|
185
|
+
data.code = responseData.code;
|
|
186
|
+
data.name = responseData.name;
|
|
187
|
+
data.content = (responseData.desc || '').replace(/\n+/g, '<br />');
|
|
188
|
+
data.isForce = !!responseData.isForce;
|
|
189
|
+
data.updateFile = responseData.entireFile ? responseData.entireFile : responseData.updateFile;
|
|
190
|
+
data.package_type = responseData.entireFile ? 0 : 1;
|
|
191
|
+
|
|
192
|
+
// strictVersionCheck 为 true 时,优先检查是否需要先升级到最近一次全量包
|
|
193
|
+
const lastAllDetail = responseData.lastAllDetail;
|
|
194
|
+
if (props.strictVersionCheck && lastAllDetail && lastAllDetail.entireFile && lastAllDetail.name && lastAllDetail.code) {
|
|
195
|
+
let allName = lastAllDetail.name;
|
|
196
|
+
if (props.appType) {
|
|
197
|
+
const nvs = allName.split('.');
|
|
198
|
+
const nevn = nvs[nvs.length - 1];
|
|
199
|
+
if (props.appType === nevn) {
|
|
200
|
+
nvs.splice(nvs.length - 1);
|
|
201
|
+
allName = nvs.join('.');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (compareVersions(allName, version.value) > 0) {
|
|
205
|
+
data.code = lastAllDetail.code;
|
|
206
|
+
data.name = lastAllDetail.name;
|
|
207
|
+
data.content = (lastAllDetail.desc || '').replace(/\n+/g, '<br />');
|
|
208
|
+
data.isForce = !!lastAllDetail.isForce;
|
|
209
|
+
data.updateFile = lastAllDetail.entireFile;
|
|
210
|
+
data.package_type = 0;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
176
213
|
|
|
177
214
|
// 检查是否已跳过该版本
|
|
178
215
|
if (isVersionSkipped(data.code)) {
|
|
@@ -184,8 +221,8 @@ const getData = async (callback?: (resVersion: { name: string; code: string; upd
|
|
|
184
221
|
callback &&
|
|
185
222
|
callback(
|
|
186
223
|
{
|
|
187
|
-
code:
|
|
188
|
-
name:
|
|
224
|
+
code: data.code,
|
|
225
|
+
name: data.name,
|
|
189
226
|
updateFile: data.updateFile,
|
|
190
227
|
},
|
|
191
228
|
version.value
|
|
@@ -206,7 +243,11 @@ const getData = async (callback?: (resVersion: { name: string; code: string; upd
|
|
|
206
243
|
data.name = nvs.join('.');
|
|
207
244
|
}
|
|
208
245
|
|
|
209
|
-
|
|
246
|
+
const shouldUpdate = props.strictVersionCheck
|
|
247
|
+
? compareVersions(data.name, version.value) > 0
|
|
248
|
+
: data.code !== version.value;
|
|
249
|
+
|
|
250
|
+
if (data.updateFile && shouldUpdate) {
|
|
210
251
|
const downloadState = getDownloadState();
|
|
211
252
|
const hasValidDownloadState = downloadState
|
|
212
253
|
&& downloadState.versionCode === data.code
|