vue2server7 7.0.17 → 7.0.18
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/package.json +1 -1
- package/test/1/utils/version-update.ts +40 -25
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ElNotification } from 'element-plus';
|
|
2
|
+
import { h } from 'vue';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* 前端版本热更新检测模块(Element Plus 版)
|
|
5
6
|
*
|
|
6
7
|
* 工作原理:
|
|
7
8
|
* 1. 应用启动时,从 <meta name="app-version"> 读取当前构建版本号
|
|
@@ -54,7 +55,6 @@ export function initVersionCheck() {
|
|
|
54
55
|
try {
|
|
55
56
|
worker = new Worker(new URL('./version-check.worker.ts', import.meta.url), { type: 'module' });
|
|
56
57
|
} catch {
|
|
57
|
-
// 浏览器不支持 module Worker 或 URL 构造失败,静默降级
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -65,7 +65,6 @@ export function initVersionCheck() {
|
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
// 启动 Worker 轮询,传入当前版本号、远端地址和轮询间隔
|
|
69
68
|
worker.postMessage({ type: 'start', version: currentVersion, url: versionUrl, interval: POLL_INTERVAL });
|
|
70
69
|
|
|
71
70
|
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
@@ -86,29 +85,45 @@ function handleVisibilityChange() {
|
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
/**
|
|
89
|
-
*
|
|
90
|
-
* -
|
|
91
|
-
* -
|
|
88
|
+
* 弹出版本更新通知
|
|
89
|
+
* - 点击"立即刷新":刷新页面加载新版本
|
|
90
|
+
* - 关闭通知:进入静默期后重新开始检测
|
|
92
91
|
*/
|
|
93
92
|
function showUpdateDialog() {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
93
|
+
const notification = ElNotification({
|
|
94
|
+
title: '发现新版本',
|
|
95
|
+
message: h('div', [
|
|
96
|
+
h('p', { style: 'margin: 0 0 12px' }, '系统已更新,请刷新页面以获取最新功能和修复。'),
|
|
97
|
+
h('div', { style: 'text-align: right' }, [
|
|
98
|
+
h(
|
|
99
|
+
'button',
|
|
100
|
+
{
|
|
101
|
+
style: 'margin-right: 8px; padding: 5px 15px; cursor: pointer; border: 1px solid #dcdfe6; border-radius: 4px; background: #fff; color: #606266; font-size: 14px;',
|
|
102
|
+
onClick: () => {
|
|
103
|
+
notification.close();
|
|
104
|
+
scheduleRecheck();
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
'稍后提醒',
|
|
108
|
+
),
|
|
109
|
+
h(
|
|
110
|
+
'button',
|
|
111
|
+
{
|
|
112
|
+
style: 'padding: 5px 15px; cursor: pointer; border: none; border-radius: 4px; background: #409eff; color: #fff; font-size: 14px;',
|
|
113
|
+
onClick: () => {
|
|
114
|
+
notification.close();
|
|
115
|
+
window.location.reload();
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
'立即刷新',
|
|
119
|
+
),
|
|
120
|
+
]),
|
|
121
|
+
]),
|
|
122
|
+
type: 'info',
|
|
123
|
+
position: 'bottom-right',
|
|
124
|
+
duration: 0,
|
|
125
|
+
showClose: false,
|
|
126
|
+
onClose: scheduleRecheck,
|
|
112
127
|
});
|
|
113
128
|
}
|
|
114
129
|
|