态势列表页面
This commit is contained in:
@ -1,13 +1,13 @@
|
||||
import { app, shell, BrowserWindow, ipcMain, globalShortcut, dialog } from 'electron'
|
||||
import path, { join } from 'path'
|
||||
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
|
||||
import {app, shell, BrowserWindow, ipcMain, globalShortcut, dialog} from 'electron'
|
||||
import path, {join} from 'path'
|
||||
import {electronApp, optimizer, is} from '@electron-toolkit/utils'
|
||||
import icon from '../../resources/earth.png?asset'
|
||||
import { Recorder } from "../preload/recorder";
|
||||
import {Recorder} from "../preload/recorder";
|
||||
import fs from 'fs'
|
||||
import { exec } from 'child_process'
|
||||
import {exec} from 'child_process'
|
||||
import dayjs from 'dayjs'
|
||||
import { GetHomeDir } from './config'
|
||||
import { start, getServer } from "./app";
|
||||
import {GetHomeDir} from './config'
|
||||
import {start, getServer} from "./app";
|
||||
|
||||
|
||||
// 开发环境路径处理 - 确保添加正确的file协议
|
||||
@ -67,6 +67,7 @@ stopBatPath = process.platform === 'win32' ? stopBatPath.replace(/^(\w:)/, '/$1'
|
||||
// ? `${join(app.getAppPath(), 'src/renderer/public/startUp/startUp.html')}`
|
||||
// : `file://${join(app.getAppPath(), 'resources/app.asar/out/renderer/startUp/startUp.html')}`
|
||||
let isRestart = false
|
||||
|
||||
function createWindow(): void {
|
||||
// Create the browser window.
|
||||
|
||||
@ -102,7 +103,7 @@ function createWindow(): void {
|
||||
useContentSize: true, // 窗口尺寸包含内容区域而非边框
|
||||
simpleFullscreen: true, // 使用简单全屏模式(仅macOS有效)
|
||||
backgroundColor: '#00000000', // 添加这行设置透明背景
|
||||
...(process.platform === 'linux' ? { icon } : {}),
|
||||
...(process.platform === 'linux' ? {icon} : {}),
|
||||
webPreferences: {
|
||||
preload: join(__dirname, '../preload/index.js'),
|
||||
sandbox: false,
|
||||
@ -116,7 +117,7 @@ function createWindow(): void {
|
||||
ipcMain.on("restart", () => {
|
||||
// app.relaunch();
|
||||
// app.quit();
|
||||
// cleanupProcess.kill();
|
||||
// cleanupProcess.kill();
|
||||
// app.relaunch();
|
||||
isRestart = true
|
||||
windowAllClosed()
|
||||
@ -162,7 +163,7 @@ function createWindow(): void {
|
||||
event.sender.send("selectedItem", arr);
|
||||
});
|
||||
});
|
||||
ipcMain.on("saveFile", (event, { title, filename, filters }) => {
|
||||
ipcMain.on("saveFile", (event, {title, filename, filters}) => {
|
||||
dialog
|
||||
.showSaveDialog({
|
||||
title,
|
||||
@ -180,9 +181,13 @@ function createWindow(): void {
|
||||
ipcMain.handle('getIsFullScreen', () => {
|
||||
return mainWindow.isFullScreen()
|
||||
});
|
||||
ipcMain.on('toggle-fullscreen', (event) => {
|
||||
ipcMain.on('toggle-fullscreen', (event, flag = null) => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender);
|
||||
win!.setFullScreen(!win!.isFullScreen());
|
||||
let full = !win!.isFullScreen()
|
||||
if (flag != null) {
|
||||
full = flag
|
||||
}
|
||||
win!.setFullScreen(full);
|
||||
});
|
||||
mainWindow.on('enter-full-screen', () => {
|
||||
mainWindow.webContents.send('fullscreen-status-changed', true)
|
||||
@ -209,7 +214,7 @@ function createWindow(): void {
|
||||
let path = dialog.showSaveDialogSync({
|
||||
title: "保存视频文件",
|
||||
defaultPath: dayjs().format("YYYYMMDDHHmmss") + "视频录制.mp4",
|
||||
filters: [{ name: "文件类型", extensions: ["mp4"] }],
|
||||
filters: [{name: "文件类型", extensions: ["mp4"]}],
|
||||
});
|
||||
if (path != undefined) {
|
||||
recorder.move(path, () => {
|
||||
@ -292,7 +297,7 @@ function createWindow(): void {
|
||||
// 设置窗口标题和图标
|
||||
mainWindow.webContents.setWindowOpenHandler((details) => {
|
||||
shell.openExternal(details.url)
|
||||
return { action: 'deny' }
|
||||
return {action: 'deny'}
|
||||
})
|
||||
// 注册 F5 快捷键刷新
|
||||
globalShortcut.register('CommandOrControl+F5', () => {
|
||||
|
||||
Reference in New Issue
Block a user