This commit is contained in:
qingjiao 2025-12-29 18:24:06 +08:00
parent 6d9c19f7da
commit 5c7495fc71
4 changed files with 35 additions and 3 deletions

View File

@ -68,6 +68,10 @@ app.on('window-all-closed', () => {
}
})
ipcMain.on('window-all-closed', () => {
app.exit();
})
ipcMain.on('show-keyboard', () => {
if (process.platform === 'linux') {
const sudoUser = process.env.SUDO_USER;

View File

@ -13,7 +13,8 @@ if (process.contextIsolated) {
contextBridge.exposeInMainWorld('api', api)
contextBridge.exposeInMainWorld('electronAPI', {
showKeyboard: () => ipcRenderer.send('show-keyboard'),
closeKeyboard: () => ipcRenderer.send('close-keyboard')
closeKeyboard: () => ipcRenderer.send('close-keyboard'),
winClose: () => ipcRenderer.send('window-all-closed')
})
} catch (error) {
console.error(error)

View File

@ -91,6 +91,10 @@ class WebSocketManager {
else if(json.Key === "UpDate"){
const Code = json.Code;
if(Code === 0){
if(Config.UpDateIndex === -1){
Config.UpDateIndex = 0;
return;
}
Config.UpDateBtn = false;
Config.UpDateIndex = 0;
ElNotification.error('下载升级包失败')
@ -114,11 +118,22 @@ class WebSocketManager {
ElNotification.success('开始安装升级包,即将重启')
}
}
else if(json.Key === "exitSys"){
window.electronAPI.winClose();
}
else if(json.Key === "DownProgress"){
if(json.Value !== undefined){
Config.DownValue = json.Value;
}
}
else if(json.Key === "stopUpgrade"){
Config.UpDateBtn = false;
Config.UpDateIndex = -1;
ElNotification.warning('升级已取消');
}
else if(json.Key === "fullScreen"){
enterFullscreen();
}
}
catch (e){
console.log('this.ws.onmessage:',e);

View File

@ -48,7 +48,7 @@
</el-scrollbar>
</div>
<div class="UPGRADE-PROGRESS-BAR">
<div class="UPGRADE-PROGRESS-BAR" v-show="Config.UpDateBtn">
<el-progress
:text-inside="true"
:stroke-width="20"
@ -75,10 +75,16 @@
type="primary"
@click="handleUpgrade"
:disabled="Config.UpDateBtn"
v-loading="Config.UpDateBtn"
>
立即升级
</el-button>
<el-button
type="danger"
@click="handleStop"
v-if="Config.UpDateBtn"
>
停止升级
</el-button>
<el-button
@click="handleCancel"
>
@ -116,6 +122,11 @@ function handleUpgrade(){
ID: Config.selectedVersion
}));
}
function handleStop(){
sendMessage(JSON.stringify({
Key:'stopUpgrade'
}));
}
function getUpDateText(ID){
let item = null;
for (let i = 0; i < Config.versionOptions.length; i++){
@ -158,6 +169,7 @@ function getUpdateList() {
if(data.Code === 1){
Config.UpgradeList = data.List;
InitList();
ElMessage.success('获取升级列表成功');
}
},function(err){
Config.UpgradeList = [];