hy-app 0.7.0 → 0.7.2
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/attributes.json +1 -1
- package/components/hy-calendar/hy-calendar.vue +2 -2
- package/components/hy-calendar/typing.d.ts +9 -0
- package/components/hy-count-down/hy-count-down.vue +8 -8
- package/components/hy-count-down/typing.d.ts +16 -0
- package/components/hy-count-to/hy-count-to.vue +7 -7
- package/components/hy-count-to/typing.d.ts +24 -0
- package/components/hy-dropdown-item/hy-dropdown-item.vue +1 -1
- package/components/hy-folding-panel/hy-folding-panel.vue +3 -3
- package/components/hy-folding-panel/typing.d.ts +23 -0
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +2 -2
- package/components/hy-folding-panel-item/typing.d.ts +21 -0
- package/components/hy-form/hy-form.vue +2 -2
- package/components/hy-form/typing.d.ts +37 -6
- package/components/hy-list/hy-list.vue +346 -226
- package/components/hy-list/index.scss +0 -1
- package/components/hy-list/props.ts +69 -69
- package/components/hy-notify/hy-notify.vue +2 -2
- package/components/hy-notify/typing.d.ts +34 -21
- package/components/hy-number-step/hy-number-step.vue +370 -367
- package/components/hy-number-step/index.scss +1 -0
- package/components/hy-number-step/props.ts +1 -1
- package/components/hy-popover/hy-popover.vue +2 -2
- package/components/hy-popover/typing.d.ts +1 -1
- package/components/hy-popup/hy-popup.vue +1 -1
- package/components/hy-signature/hy-signature.vue +17 -17
- package/components/hy-signature/typing.d.ts +1 -1
- package/components/hy-toast/hy-toast.vue +3 -3
- package/components/hy-toast/index.scss +1 -1
- package/components/hy-toast/typing.d.ts +14 -1
- package/libs/api/http.ts +122 -119
- package/libs/common/versionControl.ts +285 -102
- package/libs/css/theme.scss +2 -0
- package/package.json +1 -1
- package/web-types.json +1 -1
- package/components/hy-folding-panel/hy-folding-panel-group.vue +0 -163
|
@@ -1,102 +1,285 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
1
|
+
export interface UpdateVersionOptions {
|
|
2
|
+
/** 最新版本号 */
|
|
3
|
+
version: string
|
|
4
|
+
/** 更新内容 */
|
|
5
|
+
description: string
|
|
6
|
+
/** 下载地址 */
|
|
7
|
+
url: string
|
|
8
|
+
/** 是否强制更新 */
|
|
9
|
+
force?: boolean
|
|
10
|
+
/** iOS AppStore地址 */
|
|
11
|
+
iosStoreUrl?: string
|
|
12
|
+
/** 下载进度 */
|
|
13
|
+
onProgress?: (progress: OnProgressDownloadResult) => void
|
|
14
|
+
/** 更新前回调 */
|
|
15
|
+
beforeUpdate?: (version: string) => boolean | void
|
|
16
|
+
/** 更新成功 */
|
|
17
|
+
onSuccess?: () => void
|
|
18
|
+
/** 更新失败 */
|
|
19
|
+
onFail?: (error: string) => void
|
|
20
|
+
/** 点击确认回调 */
|
|
21
|
+
onConfirm?: () => void
|
|
22
|
+
/** 点击取消回调 */
|
|
23
|
+
onCancel?: () => void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const appInit = {
|
|
27
|
+
/**
|
|
28
|
+
* 检查更新
|
|
29
|
+
*/
|
|
30
|
+
updateVersion(options: UpdateVersionOptions) {
|
|
31
|
+
const {
|
|
32
|
+
version,
|
|
33
|
+
description,
|
|
34
|
+
url,
|
|
35
|
+
force = false,
|
|
36
|
+
iosStoreUrl,
|
|
37
|
+
onProgress,
|
|
38
|
+
beforeUpdate,
|
|
39
|
+
onSuccess,
|
|
40
|
+
onFail,
|
|
41
|
+
onConfirm,
|
|
42
|
+
onCancel
|
|
43
|
+
} = options
|
|
44
|
+
|
|
45
|
+
if (!version) {
|
|
46
|
+
console.error('version不能为空')
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
|
|
51
|
+
const localVersion = widgetInfo.version
|
|
52
|
+
const compareResult = this.compareVersion(version, localVersion)
|
|
53
|
+
if (compareResult !== 1) {
|
|
54
|
+
return uni.showToast({ title: '已是最新版本', icon: 'none' })
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (typeof beforeUpdate === 'function') {
|
|
58
|
+
const result = beforeUpdate(version)
|
|
59
|
+
|
|
60
|
+
if (result === false) {
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
uni.showModal({
|
|
66
|
+
title: `发现新版本 V${version}`,
|
|
67
|
+
content: description,
|
|
68
|
+
showCancel: !force,
|
|
69
|
+
confirmText: '立即更新',
|
|
70
|
+
success: (res) => {
|
|
71
|
+
if (!res.confirm) {
|
|
72
|
+
if (typeof onCancel === 'function') {
|
|
73
|
+
onCancel()
|
|
74
|
+
}
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (typeof onConfirm === 'function') {
|
|
79
|
+
onConfirm()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const platform = uni.getSystemInfoSync().platform
|
|
83
|
+
|
|
84
|
+
// iOS
|
|
85
|
+
if (platform === 'ios') {
|
|
86
|
+
if (iosStoreUrl) {
|
|
87
|
+
plus.runtime.openURL(iosStoreUrl)
|
|
88
|
+
} else {
|
|
89
|
+
uni.showToast({
|
|
90
|
+
title: '请配置AppStore地址',
|
|
91
|
+
icon: 'none'
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Android
|
|
98
|
+
this.downloadApp(url, {
|
|
99
|
+
onProgress,
|
|
100
|
+
onSuccess,
|
|
101
|
+
onFail
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 比较版本号
|
|
110
|
+
* 1:服务器版本大
|
|
111
|
+
* 0:相等
|
|
112
|
+
* -1:本地版本大
|
|
113
|
+
* @param serverVersion 最新版本
|
|
114
|
+
* @param localVersion 本地版本
|
|
115
|
+
*/
|
|
116
|
+
compareVersion(serverVersion: string, localVersion: string) {
|
|
117
|
+
if (!serverVersion || !localVersion) return 0
|
|
118
|
+
const v1 = serverVersion.split('.').map(Number)
|
|
119
|
+
const v2 = localVersion.split('.').map(Number)
|
|
120
|
+
const length = Math.max(v1.length, v2.length)
|
|
121
|
+
|
|
122
|
+
for (let i = 0; i < length; i++) {
|
|
123
|
+
const n1 = v1[i] || 0
|
|
124
|
+
const n2 = v2[i] || 0
|
|
125
|
+
|
|
126
|
+
if (n1 > n2) {
|
|
127
|
+
return 1
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (n1 < n2) {
|
|
131
|
+
return -1
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return 0
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* 下载更新包
|
|
140
|
+
*/
|
|
141
|
+
downloadApp(
|
|
142
|
+
downloadUrl: string,
|
|
143
|
+
callbacks?: {
|
|
144
|
+
onProgress?: (progress: OnProgressDownloadResult) => void
|
|
145
|
+
onSuccess?: () => void
|
|
146
|
+
onFail?: (error: string) => void
|
|
147
|
+
}
|
|
148
|
+
) {
|
|
149
|
+
const { onProgress, onSuccess, onFail } = callbacks || {}
|
|
150
|
+
|
|
151
|
+
if (!downloadUrl) {
|
|
152
|
+
const msg = '下载地址不能为空'
|
|
153
|
+
|
|
154
|
+
uni.showToast({
|
|
155
|
+
title: msg,
|
|
156
|
+
icon: 'none'
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
onFail?.(msg)
|
|
160
|
+
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const downloadTask = uni.downloadFile({
|
|
165
|
+
url: downloadUrl,
|
|
166
|
+
|
|
167
|
+
success: (res) => {
|
|
168
|
+
if (res.statusCode !== 200) {
|
|
169
|
+
const msg = '下载失败'
|
|
170
|
+
|
|
171
|
+
uni.showToast({
|
|
172
|
+
title: msg,
|
|
173
|
+
icon: 'none'
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
onFail?.(msg)
|
|
177
|
+
|
|
178
|
+
return
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
this.installPackage(res.tempFilePath, downloadUrl, onSuccess, onFail)
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
fail: (err) => {
|
|
185
|
+
console.error('下载失败', err)
|
|
186
|
+
|
|
187
|
+
const msg = '下载失败'
|
|
188
|
+
|
|
189
|
+
uni.showToast({
|
|
190
|
+
title: msg,
|
|
191
|
+
icon: 'none'
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
onFail?.(msg)
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
downloadTask.onProgressUpdate((res) => {
|
|
199
|
+
onProgress?.(res)
|
|
200
|
+
})
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* 安装更新包
|
|
205
|
+
*/
|
|
206
|
+
installPackage(
|
|
207
|
+
filePath: string,
|
|
208
|
+
downloadUrl: string,
|
|
209
|
+
onSuccess?: () => void,
|
|
210
|
+
onFail?: (error: string) => void
|
|
211
|
+
) {
|
|
212
|
+
const isWgt = downloadUrl.toLowerCase().endsWith('.wgt')
|
|
213
|
+
|
|
214
|
+
const isApk = downloadUrl.toLowerCase().endsWith('.apk')
|
|
215
|
+
|
|
216
|
+
// WGT热更新
|
|
217
|
+
if (isWgt) {
|
|
218
|
+
plus.runtime.install(
|
|
219
|
+
filePath,
|
|
220
|
+
{
|
|
221
|
+
force: false
|
|
222
|
+
},
|
|
223
|
+
() => {
|
|
224
|
+
uni.showToast({
|
|
225
|
+
title: '更新成功'
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
onSuccess?.()
|
|
229
|
+
|
|
230
|
+
setTimeout(() => {
|
|
231
|
+
plus.runtime.restart()
|
|
232
|
+
}, 1000)
|
|
233
|
+
},
|
|
234
|
+
(err) => {
|
|
235
|
+
console.error('安装失败', err)
|
|
236
|
+
|
|
237
|
+
const msg = `安装失败:${err.message}`
|
|
238
|
+
|
|
239
|
+
uni.showToast({
|
|
240
|
+
title: msg,
|
|
241
|
+
icon: 'none'
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
onFail?.(msg)
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
return
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// APK整包更新
|
|
252
|
+
if (isApk) {
|
|
253
|
+
plus.runtime.openFile(
|
|
254
|
+
filePath,
|
|
255
|
+
{},
|
|
256
|
+
() => {
|
|
257
|
+
onSuccess?.()
|
|
258
|
+
},
|
|
259
|
+
(err) => {
|
|
260
|
+
console.error('APK安装失败', err)
|
|
261
|
+
|
|
262
|
+
const msg = 'APK安装失败'
|
|
263
|
+
|
|
264
|
+
uni.showToast({
|
|
265
|
+
title: msg,
|
|
266
|
+
icon: 'none'
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
onFail?.(msg)
|
|
270
|
+
}
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
return
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const msg = '未知安装包格式'
|
|
277
|
+
|
|
278
|
+
uni.showToast({
|
|
279
|
+
title: msg,
|
|
280
|
+
icon: 'none'
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
onFail?.(msg)
|
|
284
|
+
}
|
|
285
|
+
}
|
package/libs/css/theme.scss
CHANGED
|
@@ -96,6 +96,8 @@ $hy-radius-semicircle: var(--hy-radius-semicircle, 100px) !default;
|
|
|
96
96
|
$hy-border-margin-padding-sm: var(--hy-border-margin-padding-sm, 10rpx) !default;
|
|
97
97
|
$hy-border-margin-padding-base: var(--hy-border-margin-padding-base, 20rpx) !default;
|
|
98
98
|
$hy-border-margin-padding-lg: var(--hy-border-margin-padding-lg, 30rpx) !default;
|
|
99
|
+
$hy-border-margin-padding-xl: var(--hy-border-margin-padding-xl, 48rpx) !default;
|
|
100
|
+
$hy-border-margin-padding-xxl: var(--hy-border-margin-padding-xxl, 64rpx) !default;
|
|
99
101
|
/* 底部线条 */
|
|
100
102
|
/* TODO: 边框不能写1rpx否则在某些机型无法显示 */
|
|
101
103
|
$hy-border-line: var(--hy-border-line, 1px solid #e8e8e8) !default;
|