This commit is contained in:
zh
2025-09-23 11:17:50 +08:00
parent f47c33c51e
commit ceb9705d5d
322 changed files with 4185 additions and 1981 deletions

View File

@ -6,6 +6,8 @@ import { Recorder } from "../preload/recorder";
import fs from 'fs'
import { exec } from 'child_process'
import dayjs from 'dayjs'
import { GetHomeDir } from './config'
import { start } from "./app";
// 开发环境路径处理 - 确保添加正确的file协议
@ -68,6 +70,8 @@ stopBatPath = process.platform === 'win32' ? stopBatPath.replace(/^(\w:)/, '/$1'
function createWindow(): void {
// Create the browser window.
start();
// 创建启动窗口
const splashWindow = new BrowserWindow({
width: 896,
@ -194,21 +198,65 @@ function createWindow(): void {
}
});
});
ipcMain.on("requireGEMarkerName", (event, obj) => {
/*
* obj= {
dirName: "GEMarker",
dirName1s: "GEMarker1s"
}
* */
console.log('GetHomeDir()', GetHomeDir())
let data = {};
for (const objKey in obj) {
let files = fs.readdirSync(
path.join(
global.__static ? global.__static : GetHomeDir() + "/src/renderer/public",
obj[objKey]
)
);
console.log(files);
for (let i = 0; i < files.length; i++) {
files[i] = obj[objKey] + "/" + files[i];
}
data[obj[objKey]] = files;
}
// let files = fs.readdirSync(path.join(global.__static ? global.__static : GetHomeDir() + "/static", dirName))
// data[dirName] = files
event.sender.send("dirFiles", data);
});
let _winMap = new Map();
// 监听渲染进程创建新窗口的请求
// @ts-ignore
ipcMain.handle('create-new-window', async (event, params, url, option) => {
ipcMain.handle('create-new-window', async (event, params, url, option, id) => {
try {
const newWindow = await new BrowserWindow(params)
if (url) {
await newWindow.loadURL(url)
await newWindow.webContents.send("data", option)
newWindow.on('closed', () => {
_winMap.delete(id);
// a.delete(newWindow.id)
// closeCB(newWindow.id)
});
}
return newWindow.id
_winMap.set(id, newWindow.id);
return _winMap
} catch (error) {
console.error('创建窗口失败:', error);
throw error; // 抛出错误以便渲染进程捕获
}
})
//@ts-ignore
ipcMain.handle('show-window-by-id', async (event, id) => {
BrowserWindow.fromId(id)?.show()
})
ipcMain.handle('get-_winMap',()=>{
return _winMap
})
// 设置窗口标题和图标
mainWindow.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url)
@ -285,15 +333,22 @@ app.whenReady().then(() => {
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', () => {
console.log('=================================================111111111', process.platform)
if (process.platform !== 'darwin') {
app.quit()
}
})
// 退出时注销所有快捷键
app.on('will-quit', () => {
globalShortcut.unregisterAll()
console.log('222222222222222222222')
// 关闭后台服务
exec(stopBatPath.substring(1, 200), (error, stdout, stderr) => {
dialog.showMessageBox({
type: 'info',
title: '信息1',
message: 'process.platform',
buttons: ['确定']
})
if (error) {
console.error(`执行错误: ${error.message}`);
return;
@ -304,7 +359,13 @@ app.on('will-quit', () => {
}
console.log(`批处理输出: ${stdout}`);
});
globalShortcut.unregisterAll()
})
console.log('=================================================')
global.sharedObject = {
hasService: false,
};
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.