Files
jeecg-boot/jeecgboot-vue3/electron/utils/window.ts
JEECG 6c15b45a8c 【合并v3.8.2最新版代码】
Squashed commit of the following:

commit f30a8c658a
Author: JEECG <445654970@qq.com>
Date:   Thu Jul 31 11:35:16 2025 +0800

    数据库缺少openapi微服务网关配置

commit e84d7726d2
Author: JEECG <445654970@qq.com>
Date:   Thu Jul 31 10:20:09 2025 +0800

    后台接口地址修改

commit 0f39802698
Author: JEECG <445654970@qq.com>
Date:   Thu Jul 31 09:56:24 2025 +0800

    docker自动化部署命令

commit a014a3ed0e
Author: JEECG <445654970@qq.com>
Date:   Wed Jul 30 21:55:16 2025 +0800

    v3.8.2 优化一键docker启动前后端

commit 5720d1a01e
Author: JEECG <445654970@qq.com>
Date:   Wed Jul 30 19:26:38 2025 +0800

    升级版本号到3.8.2

commit 5eed6ac6d2
Author: JEECG <445654970@qq.com>
Date:   Wed Jul 30 18:49:29 2025 +0800

    升级版本号到3.8.2

commit 0cfa1e223a
Author: JEECG <445654970@qq.com>
Date:   Wed Jul 30 18:28:10 2025 +0800

    v3.8.2 系统通知改造支持分类

commit 219869f4c0
Author: JEECG <445654970@qq.com>
Date:   Wed Jul 30 18:25:58 2025 +0800

    v3.8.2 版本前端代码

commit e6edde963a
Author: JEECG <445654970@qq.com>
Date:   Wed Jul 30 18:25:46 2025 +0800

    v3.8.2 版本后端代码

commit c44b66128e
Author: JEECG <445654970@qq.com>
Date:   Wed Jul 30 18:23:09 2025 +0800

    XXL-JOB(2.4.0 及以上)已被移除,分片参数获取方式变更。

commit 9356b04741
Author: JEECG <445654970@qq.com>
Date:   Wed Jul 30 10:57:52 2025 +0800

    升级online到3.8.2-beta

commit d0a094f9a3
Author: JEECG <445654970@qq.com>
Date:   Wed Jul 30 10:57:31 2025 +0800

    升级mybatis-plus到3.5.12、升级jsqlparser到4.9

commit 73eb625737
Author: JEECG <445654970@qq.com>
Date:   Wed Jul 30 09:51:34 2025 +0800

    升级jimureport到v2.1.1

commit 74880705b8
Author: JEECG <445654970@qq.com>
Date:   Wed Jul 30 09:18:46 2025 +0800

    升级online到3.8.2-beta

# Conflicts:
#	jeecg-boot/jeecg-boot-base-core/pom.xml
#	jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/Swagger3Config.java
#	jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/java/org/jeecg/JeecgSystemApplication.java
#	jeecg-boot/jeecg-server-cloud/jeecg-visual/jeecg-cloud-sentinel/pom.xml
#	jeecg-boot/pom.xml
2025-07-31 14:23:45 +08:00

92 lines
2.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type {BrowserWindowConstructorOptions} from 'electron';
import {app, BrowserWindow, dialog} from 'electron';
import path from 'path';
import {_PATHS} from '../paths';
import {$env, isDev} from '../env';
import {createTray} from './tray';
// 创建窗口
export function createBrowserWindow(options?: BrowserWindowConstructorOptions) {
const win = new BrowserWindow({
width: 1200,
height: 800,
webPreferences: {
preload: path.join(_PATHS.preloadRoot, 'index.js'),
nodeIntegration: false,
contextIsolation: true,
},
// 应用图标
icon: isDev ? _PATHS.appIcon : void 0,
...options,
});
// update-begin--author:liaozhiyang---date:20250725---for【JHHB-13】桌面应用消息通知
if (process.platform === 'darwin') { // 仅 macOS 生效
if (app.dock) {
app.dock.setIcon(path.join(_PATHS.electronRoot, './icons/mac/dock.png').replace(/[\\/]dist[\\/]/, '/'));
}
}
// update-end--author:liaozhiyang---date:20250725---for【JHHB-13】桌面应用消息通知
// 设置窗口打开处理器
win.webContents.setWindowOpenHandler(({url}) => {
const win = createBrowserWindow();
win.loadURL(url);
// 阻止创建新窗口,因为已经被接管
return {action: 'deny'};
});
// 当 beforeunload 阻止窗口关闭时触发
win.webContents.on('will-prevent-unload', () => {
const choice = dialog.showMessageBoxSync(win, {
type: 'question',
title: '确认关闭吗?',
message: '系统可能不会保存您所做的更改。',
buttons: ['关闭', '取消'],
defaultId: 1,
cancelId: 1,
noLink: true,
});
// 用户选择了关闭,直接销毁窗口
if (choice === 0) {
win.destroy();
}
});
return win;
}
// 创建主窗口、系统托盘
export function createMainWindow() {
const win = createIndexWindow()
// 设置系统托盘图标
createTray(win);
// 主窗口尝试关闭时,默认不直接退出应用,而是隐藏到托盘
win.on('close', (event) => {
event.preventDefault();
win.hide();
});
return win;
}
// 创建索引窗口
export function createIndexWindow() {
const win = createBrowserWindow({
width: 1600,
height: 1000,
title: $env.VITE_GLOB_APP_TITLE!,
});
// 开发环境加载Vite服务生产加载打包文件
if (isDev) {
win.loadURL($env.VITE_DEV_SERVER_URL!)
// 开发环境下,自动打开调试工具
// win.webContents.openDevTools()
} else {
win.loadFile(path.join(_PATHS.publicRoot, 'index.html'));
}
return win;
}