mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-28 04:40:37 +00:00
refactor: 新增 updateWindow 接口并移除废弃的预加载窗口调用
- 新增 updateWindow IPC handler,支持窗口/标签页内部导航时更新 URL 和名称 - 将前端 updateChildWindow 调用替换为 updateWindow - 移除 reloadPreloadWindow 调用(预加载窗口已删除)
This commit is contained in:
parent
4cfc5e6024
commit
cd58b418af
58
electron/electron.js
vendored
58
electron/electron.js
vendored
@ -1729,6 +1729,64 @@ ipcMain.on('openWindow', (event, args) => {
|
||||
event.returnValue = "ok"
|
||||
})
|
||||
|
||||
/**
|
||||
* 更新当前窗口/标签页的 URL 和名称(用于内部导航)
|
||||
* @param args {path, name}
|
||||
* - path: 要加载的新路径
|
||||
* - name: 可选,新的窗口/标签名称
|
||||
*/
|
||||
ipcMain.on('updateWindow', (event, args) => {
|
||||
if (!args) {
|
||||
event.returnValue = "ok"
|
||||
return
|
||||
}
|
||||
|
||||
if (!utils.isJson(args)) {
|
||||
args = {path: args}
|
||||
}
|
||||
|
||||
const sender = event.sender;
|
||||
let windowId, windowData, viewItem;
|
||||
|
||||
// 通过发送者查找窗口和视图
|
||||
for (const [id, data] of webTabWindows) {
|
||||
const found = data.views.find(v => v.view.webContents === sender);
|
||||
if (found) {
|
||||
windowId = id;
|
||||
windowData = data;
|
||||
viewItem = found;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!windowData || !viewItem) {
|
||||
event.returnValue = "ok"
|
||||
return
|
||||
}
|
||||
|
||||
// 更新 URL
|
||||
if (args.path) {
|
||||
utils.loadContentUrl(viewItem.view.webContents, serverUrl, args.path)
|
||||
}
|
||||
|
||||
// 更新名称
|
||||
if (args.name && args.name !== viewItem.name) {
|
||||
const oldName = viewItem.name;
|
||||
viewItem.name = args.name;
|
||||
|
||||
// 更新 webTabNameMap
|
||||
if (oldName) {
|
||||
webTabNameMap.delete(oldName);
|
||||
}
|
||||
webTabNameMap.set(args.name, {
|
||||
windowId: windowId,
|
||||
tabId: viewItem.id
|
||||
});
|
||||
}
|
||||
|
||||
event.returnValue = "ok"
|
||||
})
|
||||
|
||||
/**
|
||||
* 内置浏览器 - 激活标签
|
||||
* @param args {windowId, tabId} 或 tabId
|
||||
|
||||
@ -276,18 +276,10 @@ export default {
|
||||
params.path = params.url
|
||||
delete params.url
|
||||
}
|
||||
// 兼容旧格式:将 config 扁平化
|
||||
// 兼容旧格式
|
||||
if ($A.isJson(params.config)) {
|
||||
const config = params.config
|
||||
Object.assign(params, params.config)
|
||||
delete params.config
|
||||
params = Object.assign({
|
||||
title: config.title,
|
||||
titleFixed: config.titleFixed,
|
||||
width: config.width,
|
||||
height: config.height,
|
||||
minWidth: config.minWidth,
|
||||
minHeight: config.minHeight,
|
||||
}, params)
|
||||
}
|
||||
this.$store.dispatch('openWindow', params);
|
||||
},
|
||||
|
||||
1
resources/assets/js/language/index.js
vendored
1
resources/assets/js/language/index.js
vendored
@ -96,7 +96,6 @@ function setLanguage(language, silence = false) {
|
||||
utils.saveLanguage(language);
|
||||
(async () => {
|
||||
$A.IDBDel("callAt")
|
||||
$A.Electron?.sendMessage('reloadPreloadWindow');
|
||||
$A.reloadUrl()
|
||||
})()
|
||||
} else {
|
||||
|
||||
@ -56,7 +56,6 @@ export default {
|
||||
return
|
||||
}
|
||||
$A.messageSuccess('保存成功');
|
||||
this.$Electron?.sendMessage('reloadPreloadWindow');
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
2
resources/assets/js/store/actions.js
vendored
2
resources/assets/js/store/actions.js
vendored
@ -2533,7 +2533,7 @@ export default {
|
||||
}
|
||||
if ($A.isSubElectron) {
|
||||
if (task_id > 0) {
|
||||
$A.Electron.sendMessage('updateChildWindow', {
|
||||
$A.Electron.sendMessage('updateWindow', {
|
||||
name: `task-${task_id}`,
|
||||
path: `/single/task/${task_id}`,
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user