Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
HSunboy committed Nov 21, 2023
1 parent cc08d98 commit 483b9b9
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/main/windows/mainWeb/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { BrowserWindow } from 'electron';
import { BrowserWindow, dialog } from 'electron';
import { mainWebWindowConfig } from '../../../main/config';
import log from '../../utils/log';

Expand Down Expand Up @@ -62,9 +62,29 @@ export function newWindowEvent(mainWindow: BrowserWindow) {
log.error(`webcontent unresponsive, url: ${mainWindow.webContents.getURL()}`);
log.error(e);
});
mainWindow.addListener('close', (e) => {
mainWindow.on('close', (e) => {
log.warn(`webcontent close, url: ${mainWindow.webContents.getURL()}`);
log.warn(e);
const url = mainWindow.webContents?.getURL();
if (url.includes('localhost') && !url.includes('help-doc')) {
/**
* odc workspace confirm
*/
e.preventDefault();
const choice = dialog.showMessageBoxSync(mainWindow, {
type: 'question',
buttons: ['关闭', '取消'],
title: '关闭 ODC',
message: '确定关闭 ODC,您的SQL 窗口内容将会保留',
});

// 根据用户的选择进行处理
if (choice === 0) {
// 用户点击了“是”
// 主动关闭窗口
mainWindow.destroy();
}
return;
}
});
mainWindow.addListener('closed', (e) => {
log.warn(`webcontent closed`);
Expand Down

0 comments on commit 483b9b9

Please sign in to comment.