wui-components-v2 1.2.3 → 1.2.5
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.
|
@@ -38,7 +38,7 @@ const latestVersion = ref('')
|
|
|
38
38
|
async function beforeEnter() {
|
|
39
39
|
// 获取当前应用版本号
|
|
40
40
|
const v1 = await new Promise<string>((resolve, reject) => {
|
|
41
|
-
plus.runtime.getProperty(plus.runtime.appid || '',
|
|
41
|
+
plus.runtime.getProperty(plus.runtime.appid || '', widgetInfo => {
|
|
42
42
|
resolve(widgetInfo.version || '')
|
|
43
43
|
})
|
|
44
44
|
console.log(reject)
|
|
@@ -46,9 +46,9 @@ async function beforeEnter() {
|
|
|
46
46
|
currentVersion.value = v1
|
|
47
47
|
// 获取接口最新版本号
|
|
48
48
|
uni.request({
|
|
49
|
-
url:
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
url: `${
|
|
50
|
+
prop.baseUrl
|
|
51
|
+
}/v3/mstruc/data?sourceId=${prop.sourceId}&depth=1&sortColIds=创建时间_DESC&pageNo=1&pageSize=1&c_app编码_equals=${prop.appId}&c_标记删除_equals=否`,
|
|
52
52
|
method: 'GET',
|
|
53
53
|
header: {
|
|
54
54
|
'hydrocarbon-program-token': prop.hydrocarbonProgramToken,
|
|
@@ -59,13 +59,13 @@ async function beforeEnter() {
|
|
|
59
59
|
latestVersion.value = res.data.entities[0]['版本号'] // 最新版本号
|
|
60
60
|
isUpdate.value = compareVersions(currentVersion.value, latestVersion.value) // 比较版本号
|
|
61
61
|
if (isUpdate.value !== 0) {
|
|
62
|
-
show.value = true// 显示弹窗
|
|
62
|
+
show.value = true // 显示弹窗
|
|
63
63
|
}
|
|
64
64
|
entities.value = res.data.entities // 获取接口数据
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
|
-
fail:
|
|
68
|
+
fail: err => {
|
|
69
69
|
console.log('接口版本err:', err)
|
|
70
70
|
},
|
|
71
71
|
})
|
|
@@ -86,8 +86,7 @@ function compareVersions(v1: string, v2: string) {
|
|
|
86
86
|
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
|
87
87
|
const part1 = v1Parts[i] || 0
|
|
88
88
|
const part2 = v2Parts[i] || 0
|
|
89
|
-
if (part1 !== part2)
|
|
90
|
-
return part1 < part2 ? 1 : -1
|
|
89
|
+
if (part1 !== part2) return part1 < part2 ? 1 : -1
|
|
91
90
|
}
|
|
92
91
|
return 0
|
|
93
92
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, defineEmits, ref } from 'vue'
|
|
3
|
+
import { useManualTheme } from '../../composables/useManualTheme'
|
|
3
4
|
|
|
4
5
|
defineOptions({
|
|
5
6
|
name: 'WuiUpdateComponent',
|
|
6
7
|
})
|
|
8
|
+
|
|
9
|
+
const { currentThemeColor } = useManualTheme()
|
|
10
|
+
const primaryColor = computed(() => currentThemeColor.value.primary)
|
|
7
11
|
const prop = defineProps({
|
|
8
12
|
show: {
|
|
9
13
|
type: Boolean,
|
|
@@ -62,7 +66,7 @@ async function beforeEnter() {
|
|
|
62
66
|
loading.value = true
|
|
63
67
|
// 获取当前应用版本号
|
|
64
68
|
const v1 = await new Promise<string>((resolve, reject) => {
|
|
65
|
-
plus.runtime.getProperty(plus.runtime.appid || '',
|
|
69
|
+
plus.runtime.getProperty(plus.runtime.appid || '', widgetInfo => {
|
|
66
70
|
resolve(widgetInfo.version || '')
|
|
67
71
|
})
|
|
68
72
|
console.log(reject)
|
|
@@ -70,9 +74,9 @@ async function beforeEnter() {
|
|
|
70
74
|
currentVersion.value = v1
|
|
71
75
|
// 获取接口最新版本号
|
|
72
76
|
uni.request({
|
|
73
|
-
url:
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
url: `${
|
|
78
|
+
prop.baseUrl
|
|
79
|
+
}/v3/mstruc/data?sourceId=${prop.sourceId}&depth=1&sortColIds=创建时间_DESC&pageNo=1&pageSize=1&c_app编码_equals=${prop.appId}&c_标记删除_equals=否`,
|
|
76
80
|
method: 'GET',
|
|
77
81
|
header: {
|
|
78
82
|
'hydrocarbon-program-token': prop.hydrocarbonProgramToken,
|
|
@@ -89,7 +93,7 @@ async function beforeEnter() {
|
|
|
89
93
|
|
|
90
94
|
loading.value = false
|
|
91
95
|
},
|
|
92
|
-
fail:
|
|
96
|
+
fail: err => {
|
|
93
97
|
loading.value = false
|
|
94
98
|
console.log('接口版本err:', err)
|
|
95
99
|
},
|
|
@@ -101,10 +105,9 @@ function downloadApk(code: string, name: string) {
|
|
|
101
105
|
// 发起下载请求
|
|
102
106
|
const downloadTask = uni.downloadFile({
|
|
103
107
|
url: `${prop.baseUrl}/v3/files/hwane27308/${code}/${name}`,
|
|
104
|
-
success:
|
|
108
|
+
success: res => {
|
|
105
109
|
if (res.statusCode === 200) {
|
|
106
|
-
if (!res.tempFilePath)
|
|
107
|
-
return
|
|
110
|
+
if (!res.tempFilePath) return
|
|
108
111
|
// 下载完成后安装 APK
|
|
109
112
|
plus.runtime.install(
|
|
110
113
|
res.tempFilePath,
|
|
@@ -119,14 +122,14 @@ function downloadApk(code: string, name: string) {
|
|
|
119
122
|
percentage.value = 0
|
|
120
123
|
enterUpdate.value = false
|
|
121
124
|
closable.value = true
|
|
122
|
-
}
|
|
125
|
+
}
|
|
123
126
|
)
|
|
124
127
|
}
|
|
125
128
|
},
|
|
126
129
|
})
|
|
127
130
|
|
|
128
131
|
// 监听下载进度变化
|
|
129
|
-
downloadTask.onProgressUpdate(
|
|
132
|
+
downloadTask.onProgressUpdate(res => {
|
|
130
133
|
console.log('当前进度:', `${res.progress}%`)
|
|
131
134
|
// 更新 UI(例如进度条)
|
|
132
135
|
percentage.value = res.progress // 假设 this.progress 是绑定的数据
|
|
@@ -142,8 +145,7 @@ function compareVersions(v1: string, v2: string) {
|
|
|
142
145
|
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
|
143
146
|
const part1 = v1Parts[i] || 0
|
|
144
147
|
const part2 = v2Parts[i] || 0
|
|
145
|
-
if (part1 !== part2)
|
|
146
|
-
return part1 < part2 ? 1 : -1
|
|
148
|
+
if (part1 !== part2) return part1 < part2 ? 1 : -1
|
|
147
149
|
}
|
|
148
150
|
return 0
|
|
149
151
|
}
|
|
@@ -173,20 +175,36 @@ function actionUpdate() {
|
|
|
173
175
|
:closable="closable"
|
|
174
176
|
@close="handleClose"
|
|
175
177
|
@before-enter="beforeEnter"
|
|
178
|
+
class="custom-update-box"
|
|
176
179
|
>
|
|
177
|
-
<view v-if="loading" class="loadingBox">
|
|
178
|
-
<
|
|
180
|
+
<view v-if="loading" class="loadingBox" :style="{ '--update-primary': primaryColor }">
|
|
181
|
+
<view class="header" />
|
|
182
|
+
<view class="body">
|
|
183
|
+
<wd-loading />
|
|
184
|
+
</view>
|
|
179
185
|
</view>
|
|
180
|
-
<view v-else class="updateBox">
|
|
181
|
-
<
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
<view v-else class="updateBox" :style="{ '--update-primary': primaryColor }">
|
|
187
|
+
<view class="header" />
|
|
188
|
+
<view class="body">
|
|
189
|
+
<wd-text text="更新提示" :bold="true" color="#333" class="body-title" />
|
|
190
|
+
<wd-text class="body-center" :text="`当前版本:${currentVersion} 最新版本:${latestVersion}`" color="#333" />
|
|
191
|
+
<wd-text
|
|
192
|
+
v-if="isUpdate > 0 && !enterUpdate"
|
|
193
|
+
class="body-center"
|
|
194
|
+
:text="updateContent"
|
|
195
|
+
line-height="20px"
|
|
196
|
+
:lines="4"
|
|
197
|
+
/>
|
|
198
|
+
<wd-button
|
|
199
|
+
v-if="isUpdate !== 0 && !enterUpdate"
|
|
200
|
+
:custom-style="`background-color:${primaryColor};border-color:${primaryColor};margin-top:auto`"
|
|
201
|
+
@click="actionUpdate"
|
|
202
|
+
>
|
|
203
|
+
更新
|
|
204
|
+
</wd-button>
|
|
205
|
+
<view v-if="enterUpdate" class="calc">
|
|
206
|
+
<wd-progress :percentage="percentage" />
|
|
207
|
+
</view>
|
|
190
208
|
</view>
|
|
191
209
|
</view>
|
|
192
210
|
</wd-popup>
|
|
@@ -196,26 +214,68 @@ function actionUpdate() {
|
|
|
196
214
|
.updateBox {
|
|
197
215
|
display: flex;
|
|
198
216
|
flex-direction: column;
|
|
199
|
-
align-items: center;
|
|
200
217
|
width: 600rpx;
|
|
201
|
-
min-height:
|
|
202
|
-
|
|
218
|
+
min-height: 500rpx;
|
|
219
|
+
overflow: hidden;
|
|
203
220
|
background-color: #fff;
|
|
204
221
|
border-radius: 32rpx;
|
|
205
|
-
.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
222
|
+
.body {
|
|
223
|
+
display: flex;
|
|
224
|
+
flex: 1;
|
|
225
|
+
flex-direction: column;
|
|
226
|
+
padding: 48rpx 32rpx 32rpx;
|
|
227
|
+
.body-title {
|
|
228
|
+
margin-bottom: 20rpx;
|
|
229
|
+
text-align: center;
|
|
230
|
+
}
|
|
231
|
+
.body-center {
|
|
232
|
+
text-align: center;
|
|
233
|
+
}
|
|
234
|
+
.calc {
|
|
235
|
+
width: 100%;
|
|
236
|
+
margin-top: 40rpx;
|
|
237
|
+
text-align: center;
|
|
238
|
+
}
|
|
209
239
|
}
|
|
210
240
|
}
|
|
211
|
-
.
|
|
241
|
+
.header {
|
|
242
|
+
position: relative;
|
|
212
243
|
display: flex;
|
|
213
244
|
align-items: center;
|
|
214
245
|
justify-content: center;
|
|
246
|
+
height: 110rpx;
|
|
247
|
+
background-color: var(--update-primary);
|
|
248
|
+
border-radius: 32rpx 32rpx 0 0;
|
|
249
|
+
&::after {
|
|
250
|
+
position: absolute;
|
|
251
|
+
right: 0;
|
|
252
|
+
bottom: -24rpx;
|
|
253
|
+
left: 0;
|
|
254
|
+
height: 48rpx;
|
|
255
|
+
content: '';
|
|
256
|
+
background-image: radial-gradient(circle at 50% 0, var(--update-primary) 35rpx, transparent 36rpx);
|
|
257
|
+
background-repeat: repeat-x;
|
|
258
|
+
background-position: center bottom;
|
|
259
|
+
background-size: 70rpx 48rpx;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
.loadingBox {
|
|
263
|
+
display: flex;
|
|
264
|
+
flex-direction: column;
|
|
215
265
|
width: 600rpx;
|
|
216
|
-
|
|
217
|
-
padding: 32rpx;
|
|
266
|
+
overflow: hidden;
|
|
218
267
|
background-color: #fff;
|
|
219
268
|
border-radius: 32rpx;
|
|
269
|
+
.body {
|
|
270
|
+
display: flex;
|
|
271
|
+
flex: 1;
|
|
272
|
+
align-items: center;
|
|
273
|
+
justify-content: center;
|
|
274
|
+
min-height: 240rpx;
|
|
275
|
+
padding: 48rpx 32rpx 32rpx;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
.custom-update-box :deep(.wd-icon) {
|
|
279
|
+
color: #fff;
|
|
220
280
|
}
|
|
221
281
|
</style>
|
|
@@ -60,6 +60,6 @@ export const themeColorOptions: ThemeColorOption[] = [
|
|
|
60
60
|
*/
|
|
61
61
|
export const LocaleOptions: LocaleOption[] = [
|
|
62
62
|
{ name: '简体中文', value: 'zh-CN' },
|
|
63
|
-
{ name: 'English', value: 'en-US' },
|
|
64
|
-
{ name: '阿拉伯语', value: 'ar-SA' },
|
|
63
|
+
// { name: 'English', value: 'en-US' },
|
|
64
|
+
// { name: '阿拉伯语', value: 'ar-SA' },
|
|
65
65
|
]
|