wui-components-v2 1.2.3 → 1.2.4

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 || '', (widgetInfo) => {
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
- `${prop.baseUrl
51
- }/v3/mstruc/data?sourceId=${prop.sourceId}&depth=1&sortColIds=创建时间_DESC&pageNo=1&pageSize=1&c_app编码_equals=${prop.appId}&c_标记删除_equals=否`,
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: (err) => {
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 || '', (widgetInfo) => {
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
- `${prop.baseUrl
75
- }/v3/mstruc/data?sourceId=${prop.sourceId}&depth=1&sortColIds=创建时间_DESC&pageNo=1&pageSize=1&c_app编码_equals=${prop.appId}&c_标记删除_equals=否`,
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: (err) => {
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: (res) => {
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((res) => {
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
  }
@@ -174,19 +176,34 @@ function actionUpdate() {
174
176
  @close="handleClose"
175
177
  @before-enter="beforeEnter"
176
178
  >
177
- <view v-if="loading" class="loadingBox">
178
- <wd-loading />
179
+ <view v-if="loading" class="loadingBox" :style="{ '--update-primary': primaryColor }">
180
+ <view class="header" />
181
+ <view class="body">
182
+ <wd-loading />
183
+ </view>
179
184
  </view>
180
- <view v-else class="updateBox">
181
- <wd-text text="更新提示" :bold="true" color="#333" />
182
- <wd-text :text="`当前版本:${currentVersion} 最新版本:${latestVersion}`" color="#333" />
183
- <wd-text v-if="isUpdate > 0" :text="updateContent" line-height="20px" :lines="4" />
184
- <wd-button v-if="isUpdate !== 0" style="margin-top: auto" @click="actionUpdate">
185
- 更新
186
- </wd-button>
187
- <view v-if="enterUpdate" class="calc">
188
- <wd-progress :percentage="percentage" />
189
- <!-- <wd-button @click="calce">取消</wd-button> -->
185
+ <view v-else class="updateBox" :style="{ '--update-primary': primaryColor }">
186
+ <view class="header" />
187
+ <view class="body">
188
+ <wd-text text="更新提示" :bold="true" color="#333" class="body-title" />
189
+ <wd-text class="body-center" :text="`当前版本:${currentVersion} 最新版本:${latestVersion}`" color="#333" />
190
+ <wd-text
191
+ v-if="isUpdate > 0 && !enterUpdate"
192
+ class="body-center"
193
+ :text="updateContent"
194
+ line-height="20px"
195
+ :lines="4"
196
+ />
197
+ <wd-button
198
+ v-if="isUpdate !== 0 && !enterUpdate"
199
+ :custom-style="`background-color:${primaryColor};border-color:${primaryColor};margin-top:auto`"
200
+ @click="actionUpdate"
201
+ >
202
+ 更新
203
+ </wd-button>
204
+ <view v-if="enterUpdate" class="calc">
205
+ <wd-progress :percentage="percentage" />
206
+ </view>
190
207
  </view>
191
208
  </view>
192
209
  </wd-popup>
@@ -196,26 +213,65 @@ function actionUpdate() {
196
213
  .updateBox {
197
214
  display: flex;
198
215
  flex-direction: column;
199
- align-items: center;
200
216
  width: 600rpx;
201
- min-height: 200rpx;
202
- padding: 32rpx;
217
+ min-height: 600rpx;
218
+ overflow: hidden;
203
219
  background-color: #fff;
204
220
  border-radius: 32rpx;
205
- .calc {
206
- width: 550rpx;
207
- margin-top: 40rpx;
208
- text-align: center;
221
+ .body {
222
+ display: flex;
223
+ flex: 1;
224
+ flex-direction: column;
225
+ padding: 48rpx 32rpx 32rpx;
226
+ .body-title {
227
+ margin-bottom: 20rpx;
228
+ text-align: center;
229
+ }
230
+ .body-center {
231
+ text-align: center;
232
+ }
233
+ .calc {
234
+ width: 100%;
235
+ margin-top: 40rpx;
236
+ text-align: center;
237
+ }
209
238
  }
210
239
  }
211
- .loadingBox {
240
+ .header {
241
+ position: relative;
212
242
  display: flex;
213
243
  align-items: center;
214
244
  justify-content: center;
245
+ height: 110rpx;
246
+ background-color: var(--update-primary);
247
+ border-radius: 32rpx 32rpx 0 0;
248
+ &::after {
249
+ position: absolute;
250
+ right: 0;
251
+ bottom: -24rpx;
252
+ left: 0;
253
+ height: 48rpx;
254
+ content: '';
255
+ background-image: radial-gradient(circle at 50% 0, var(--update-primary) 35rpx, transparent 36rpx);
256
+ background-repeat: repeat-x;
257
+ background-position: center bottom;
258
+ background-size: 70rpx 48rpx;
259
+ }
260
+ }
261
+ .loadingBox {
262
+ display: flex;
263
+ flex-direction: column;
215
264
  width: 600rpx;
216
- height: 200rpx;
217
- padding: 32rpx;
265
+ overflow: hidden;
218
266
  background-color: #fff;
219
267
  border-radius: 32rpx;
268
+ .body {
269
+ display: flex;
270
+ flex: 1;
271
+ align-items: center;
272
+ justify-content: center;
273
+ min-height: 240rpx;
274
+ padding: 48rpx 32rpx 32rpx;
275
+ }
220
276
  }
221
277
  </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
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",