@zfqh/uniapp 0.2.11 → 0.2.15
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 +32 -0
- package/docs/api/apis/core.md +1 -1
- package/docs/api/configs/index.md +0 -17
- package/docs/api/mixins/app.md +2 -2
- package/docs/api/utils/index.md +1 -1
- package/docs/api/utils/update.md +109 -111
- package/docs/components/index.md +0 -5
- package/docs/components/usage.md +1 -1
- package/lib/apis/core.js +1 -1
- package/lib/configs/index.d.ts +0 -5
- package/lib/configs/index.js +0 -3
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/mixins/app.js +1 -15
- package/lib/utils/update.d.ts +20 -9
- package/lib/utils/update.js +142 -348
- package/package.json +2 -2
- package/docs/api/configs/update.md +0 -25
- package/docs/components/g-env.md +0 -75
- package/lib/components/g-env/g-env.vue +0 -123
- package/lib/configs/update.d.ts +0 -45
- package/lib/configs/update.js +0 -6
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<template v-if="show">
|
|
3
|
-
<slot name="default" :open="open">
|
|
4
|
-
<text @tap.stop="open"> {{ prefix }}{{ env.name }}{{ suffix }} </text>
|
|
5
|
-
</slot>
|
|
6
|
-
<!-- #ifndef MP -->
|
|
7
|
-
<uv-action-sheet v-if="switchable" ref="actionSheet" :actions="list" title="切换环境" @select="select" />
|
|
8
|
-
<!-- #endif -->
|
|
9
|
-
</template>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script>
|
|
13
|
-
import color from '../../configs/color';
|
|
14
|
-
import ver from '../../configs/ver';
|
|
15
|
-
import update from '../../utils/update';
|
|
16
|
-
import { requestDelay } from '../../utils';
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
props: {
|
|
20
|
-
env: {
|
|
21
|
-
type: Object,
|
|
22
|
-
default: () => ({}),
|
|
23
|
-
},
|
|
24
|
-
data: {
|
|
25
|
-
type: Array,
|
|
26
|
-
default: () => [
|
|
27
|
-
{
|
|
28
|
-
name: '开发环境',
|
|
29
|
-
key: 'dev',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: '测试环境',
|
|
33
|
-
key: 'sit',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: '演示环境',
|
|
37
|
-
key: 'uat',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: '预生产环境',
|
|
41
|
-
key: 'pre',
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
prefix: {
|
|
46
|
-
type: String,
|
|
47
|
-
default: '',
|
|
48
|
-
},
|
|
49
|
-
suffix: {
|
|
50
|
-
type: String,
|
|
51
|
-
default: '',
|
|
52
|
-
},
|
|
53
|
-
switchable: {
|
|
54
|
-
type: Boolean,
|
|
55
|
-
default: true,
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
computed: {
|
|
59
|
-
show() {
|
|
60
|
-
return this.env.name !== 'prod';
|
|
61
|
-
},
|
|
62
|
-
list() {
|
|
63
|
-
return this.data.map((item) => ({
|
|
64
|
-
...item,
|
|
65
|
-
disabled: item.disabled || (item.key === this.env.name ? true : false),
|
|
66
|
-
}));
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
methods: {
|
|
70
|
-
open() {
|
|
71
|
-
if (this.switchable) {
|
|
72
|
-
// #ifdef MP-WEIXIN
|
|
73
|
-
uni.showModal({
|
|
74
|
-
title: '提示',
|
|
75
|
-
content: '请在"小程序助手"中切换环境',
|
|
76
|
-
showCancel: false,
|
|
77
|
-
confirmColor: color.primary,
|
|
78
|
-
});
|
|
79
|
-
// #endif
|
|
80
|
-
// #ifdef H5
|
|
81
|
-
if (!window.electron) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
// #endif
|
|
85
|
-
// #ifndef MP
|
|
86
|
-
this.$refs.actionSheet.open();
|
|
87
|
-
// #endif
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
// #ifndef MP
|
|
91
|
-
select(e) {
|
|
92
|
-
this.$refs.actionSheet.close();
|
|
93
|
-
if (this.current !== e.key) {
|
|
94
|
-
uni.showModal({
|
|
95
|
-
title: '提示',
|
|
96
|
-
content: `是否切换到${e.name}并重启应用?`,
|
|
97
|
-
confirmColor: color.primary,
|
|
98
|
-
success: async (res) => {
|
|
99
|
-
if (res.confirm) {
|
|
100
|
-
this.env.set(e.key);
|
|
101
|
-
ver.code = -1;
|
|
102
|
-
try {
|
|
103
|
-
uni.showLoading({ title: '切换中...' });
|
|
104
|
-
await requestDelay(() => Promise.resolve());
|
|
105
|
-
uni.hideLoading();
|
|
106
|
-
await update.check(true);
|
|
107
|
-
} catch (e) {
|
|
108
|
-
// #ifdef APP
|
|
109
|
-
plus.runtime.restart();
|
|
110
|
-
// #endif
|
|
111
|
-
// #ifdef H5
|
|
112
|
-
window.location.reload();
|
|
113
|
-
// #endif
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
// #endif
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
</script>
|
package/lib/configs/update.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
type UpdateRequestParams = {
|
|
2
|
-
/** 当前应用ID */
|
|
3
|
-
appId?: string;
|
|
4
|
-
/** 当前应用名称 */
|
|
5
|
-
appName?: string;
|
|
6
|
-
/** 当前应用资源版本号 */
|
|
7
|
-
versionCode?: number;
|
|
8
|
-
/** 当前应用资源版本名称 */
|
|
9
|
-
versionName?: string;
|
|
10
|
-
/** 当前应用程序版本号 */
|
|
11
|
-
appVersionCode?: number;
|
|
12
|
-
/** 当前应用程序版本名称 */
|
|
13
|
-
appVersionName?: string;
|
|
14
|
-
/** 应用平台 */
|
|
15
|
-
platform?: string;
|
|
16
|
-
};
|
|
17
|
-
type UpdateResponceData = {
|
|
18
|
-
/** 资源包热更新,0否 1是 */
|
|
19
|
-
hot_update?: number;
|
|
20
|
-
/** 新包版本号 */
|
|
21
|
-
version_code?: number;
|
|
22
|
-
/** 强制更新,0否 1是 */
|
|
23
|
-
force_update?: number;
|
|
24
|
-
/** 在APP外部安装 */
|
|
25
|
-
external_install?: number;
|
|
26
|
-
/** app资源包路径 */
|
|
27
|
-
wgt_url?: string;
|
|
28
|
-
/** 客户端资源包路径 */
|
|
29
|
-
zip_url?: string;
|
|
30
|
-
/** android包路径 */
|
|
31
|
-
apk_url?: string;
|
|
32
|
-
/** ios包路径 */
|
|
33
|
-
ipa_url?: string;
|
|
34
|
-
/** windows包路径 */
|
|
35
|
-
exe_url?: string;
|
|
36
|
-
/** macos包路径 */
|
|
37
|
-
dmg_url?: string;
|
|
38
|
-
};
|
|
39
|
-
export type UpdateConfig = {
|
|
40
|
-
/** 自动更新请求,获取最新更新资源 */
|
|
41
|
-
request: (data: UpdateRequestParams) => Promise<UpdateResponceData>;
|
|
42
|
-
};
|
|
43
|
-
/** 自动更新配置 */
|
|
44
|
-
declare const update: UpdateConfig;
|
|
45
|
-
export default update;
|