stellar-ui-plus 1.22.10 → 1.22.11

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.
@@ -50,16 +50,21 @@ export interface ClientData {
50
50
 
51
51
  export function download(
52
52
  data: ClientData,
53
- { success, error, onProgressUpdate }: { success?: () => void; error?: (e: any) => void; onProgressUpdate?: (res: UniApp.OnProgressDownloadResult) => void }
53
+ {
54
+ success,
55
+ error,
56
+ onProgressUpdate,
57
+ downloadSuccess,
58
+ }: { success?: () => void; error?: (e: any) => void; downloadSuccess?: (tempFilePath: string) => void; onProgressUpdate?: (res: UniApp.OnProgressDownloadResult) => void }
54
59
  ) {
55
60
  const package_type = data.package_type;
56
61
  const downloadTask = uni.downloadFile({
57
62
  url: data.updateFile,
58
63
  success: res => {
59
64
  if (res.statusCode === 200) {
65
+ downloadSuccess && downloadSuccess(res.tempFilePath);
60
66
  plus.runtime.install(
61
67
  res.tempFilePath,
62
- //true表示强制安装,不进行版本号的校验;false则需要版本号校验,
63
68
  { force: true },
64
69
  () => {
65
70
  // wgt升级
@@ -78,7 +83,6 @@ export function download(
78
83
  },
79
84
  e => {
80
85
  //提示部分wgt包无法安装的问题
81
- data.isForce = false;
82
86
  uni.showModal({
83
87
  title: '提示',
84
88
  content: e.message,
@@ -92,7 +96,6 @@ export function download(
92
96
  // 整包升级
93
97
  if (package_type == 0) {
94
98
  // 解决安装app点击取消,更新还在的问题
95
- data.isForce = false;
96
99
  success && success();
97
100
  }
98
101
  }
@@ -20,6 +20,7 @@ const percent = ref(0);
20
20
  const updateBtn = ref(true);
21
21
  const downloadedSize = ref('0');
22
22
  const packageFileSize = ref('0');
23
+ const tempFilePath = ref('');
23
24
 
24
25
  const emits = defineEmits<{
25
26
  (e: 'cancel'): void;
@@ -59,7 +60,6 @@ const getData = (callback?: (resVersion: { name: string; code: string; updateFil
59
60
  console.log(_data.msg);
60
61
  }
61
62
  // 无需升级
62
-
63
63
  emits('no-update');
64
64
  },
65
65
  fail: (err: any) => {
@@ -91,10 +91,12 @@ const confirm = () => {
91
91
  //apk整包升级 下载地址必须以.apk结尾
92
92
  if (data.updateFile.includes('.apk')) {
93
93
  updateBtn.value = false;
94
- download(data, { onProgressUpdate });
94
+ download(data, {
95
+ onProgressUpdate,
96
+ downloadSuccess: path => (tempFilePath.value = path),
97
+ });
95
98
  } else {
96
99
  //外部下载 一般是手机应用市场或者其他h5页面
97
- data.isForce = false; // 解决跳转外部链接后,更新提示还在的问题
98
100
  plus.runtime.openURL(data.updateFile);
99
101
  uni.navigateBack({
100
102
  delta: 1,
@@ -103,7 +105,7 @@ const confirm = () => {
103
105
  } else {
104
106
  updateBtn.value = false;
105
107
  //wgt资源包升级 下载地址必须以.wgt结尾
106
- download(data, { onProgressUpdate });
108
+ download(data, { onProgressUpdate, downloadSuccess: path => (tempFilePath.value = path) });
107
109
  }
108
110
  };
109
111
 
@@ -112,11 +114,38 @@ function close() {
112
114
  emits('cancel');
113
115
  }
114
116
 
117
+ const install = () => {
118
+ plus.runtime.install(
119
+ tempFilePath.value,
120
+ { force: true },
121
+ () => {
122
+ // wgt升级
123
+ if (data.package_type == 1) {
124
+ uni.showModal({
125
+ title: '提示',
126
+ content: '升级成功,请重新启动!',
127
+ confirmText: '确定',
128
+ showCancel: false,
129
+ success: () => {
130
+ plus.runtime.restart();
131
+ },
132
+ });
133
+ }
134
+ },
135
+ e => {
136
+ //提示部分wgt包无法安装的问题
137
+ uni.showModal({
138
+ title: '提示',
139
+ content: e.message,
140
+ showCancel: false,
141
+ success: () => {},
142
+ });
143
+ }
144
+ );
145
+ };
146
+
115
147
  defineExpose({
116
148
  start,
117
- stop() {
118
- data.isForce = false;
119
- },
120
149
  });
121
150
  </script>
122
151
  <template>
@@ -145,6 +174,7 @@ defineExpose({
145
174
  </view>
146
175
 
147
176
  <button class="content-button" style="border: none; color: #fff" plain @click="confirm" v-if="updateBtn">立即升级</button>
177
+ <button class="content-button" style="border: none; color: #fff" plain @click="install" v-else-if="tempFilePath">即刻安装</button>
148
178
  </view>
149
179
  </view>
150
180
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stellar-ui-plus",
3
- "version": "1.22.10",
3
+ "version": "1.22.11",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",