提交
88
src/main/app.ts
Normal file
@ -0,0 +1,88 @@
|
||||
let net = require("net");
|
||||
const express = require("express");
|
||||
const path = require("path");
|
||||
const { ipcMain } = require('electron');
|
||||
// const bodyParser = require("body-parser");
|
||||
import { GetHomeDir } from "./config";
|
||||
|
||||
let SERVER_PORTS = 55110;
|
||||
|
||||
/**
|
||||
* 检测端口是否被占用
|
||||
* @param port
|
||||
* @param cb
|
||||
*/
|
||||
|
||||
function portIsOccupied(port, cb) {
|
||||
// 创建服务并监听该端口
|
||||
port = Number(port);
|
||||
let server = net.createServer().listen(port);
|
||||
|
||||
server.on("listening", function() {
|
||||
// 执行这块代码说明端口未被占用
|
||||
server.close(); // 关闭服务
|
||||
console.log("端口【" + port + "】 可用"); // 控制台输出信息
|
||||
SERVER_PORTS = port;
|
||||
cb(port);
|
||||
});
|
||||
|
||||
server.on("error", function(err) {
|
||||
if (err.code === "EADDRINUSE") {
|
||||
// 端口已经被使用
|
||||
console.log("端口【" + port + "】 被占用");
|
||||
portIsOccupied(++port, cb);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let apps;
|
||||
let availablePort
|
||||
|
||||
function createApp() {
|
||||
apps = express();
|
||||
// app.use(bodyParser.json());
|
||||
// app.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
let prefix =
|
||||
process.env.NODE_ENV === "development"
|
||||
? ""
|
||||
: "resources/app.asar/out/renderer/";
|
||||
let static_path = ["./", "src/renderer/public"];
|
||||
let home_dir = GetHomeDir();
|
||||
static_path.forEach((p) => {
|
||||
apps.use(
|
||||
express.static(
|
||||
path.join(path.join(home_dir, prefix), p) /*{maxAge: 60 * 1000 * 5}*/
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
function start() {
|
||||
createApp();
|
||||
portIsOccupied(SERVER_PORTS, (port) => {
|
||||
// avilablePort挂载全局
|
||||
// console.log(apps);
|
||||
apps.listen(port);
|
||||
availablePort = port;
|
||||
// console.log("global.sharedObject", global.avilablePort);
|
||||
global.sharedObject.availablePort = port;
|
||||
// ipcRenderer.invoke("set-global-variable", "avilablePort", avilablePort);
|
||||
});
|
||||
}
|
||||
//获取项目根目录
|
||||
// function GetHomeDir() {
|
||||
// let HOME_DIR = process.cwd()
|
||||
|
||||
// if (process.env.NODE_ENV === 'production') {
|
||||
// let arr = process.execPath.replaceAll("\\", "/").split("/")
|
||||
// arr.pop()
|
||||
// HOME_DIR = arr.join("/")
|
||||
// }
|
||||
// return HOME_DIR
|
||||
// }
|
||||
|
||||
ipcMain.handle('get-available-port', () => {
|
||||
return availablePort;
|
||||
});
|
||||
|
||||
export { apps, start };
|
||||
22
src/main/config.ts
Normal file
@ -0,0 +1,22 @@
|
||||
//获取项目根目录
|
||||
function GetHomeDir() {
|
||||
let HOME_DIR = process.cwd();
|
||||
// console.log("process.env.NODE_ENV", process.env.NODE_ENV);
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
let arr = process.execPath.replaceAll("\\", "/").split("/");
|
||||
arr.pop();
|
||||
HOME_DIR = arr.join("/");
|
||||
}
|
||||
return HOME_DIR;
|
||||
}
|
||||
//获取项目根目录
|
||||
function GetAsar() {
|
||||
let HOME_DIR = ''
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
let arr = process.execPath.replaceAll("\\", "/").split("/");
|
||||
arr.pop();
|
||||
HOME_DIR = arr.join("/");
|
||||
}
|
||||
return HOME_DIR;
|
||||
}
|
||||
export { GetHomeDir, GetAsar };
|
||||
@ -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.
|
||||
|
||||
1
src/renderer/components.d.ts
vendored
@ -13,6 +13,7 @@ declare module 'vue' {
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
ElCard: typeof import('element-plus/es')['ElCard']
|
||||
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
|
||||
ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
|
||||
ElCol: typeof import('element-plus/es')['ElCol']
|
||||
ElDialog: typeof import('element-plus/es')['ElDialog']
|
||||
ElForm: typeof import('element-plus/es')['ElForm']
|
||||
|
||||
BIN
src/renderer/public/GEMarker/000AAA.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
src/renderer/public/GEMarker/0a1.png
Normal file
|
After Width: | Height: | Size: 3.4 MiB |
BIN
src/renderer/public/GEMarker/1.gif
Normal file
|
After Width: | Height: | Size: 280 KiB |
BIN
src/renderer/public/GEMarker/1.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
src/renderer/public/GEMarker/A-Cable Car.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/public/GEMarker/A-Signal tower.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/A-airliner.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/public/GEMarker/A-airports.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/A-blu-blank.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src/renderer/public/GEMarker/A-blu-circle.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/renderer/public/GEMarker/A-blu-square.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
src/renderer/public/GEMarker/A-blu-stars.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/public/GEMarker/A-bus.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/A-cabs.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/A-camera1.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
src/renderer/public/GEMarker/A-ciclr-blue.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
src/renderer/public/GEMarker/A-ferry.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/A-heliport.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/public/GEMarker/A-homegardenbusiness.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/public/GEMarker/A-location.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/renderer/public/GEMarker/A-man.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
src/renderer/public/GEMarker/A-partly_cloudy.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/public/GEMarker/A-rail.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/A-realestate.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
src/renderer/public/GEMarker/A-sensor.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
src/renderer/public/GEMarker/A-subway.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/A-take-off.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/renderer/public/GEMarker/A-toilets.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/A-traffic lights.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/A-truck.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
src/renderer/public/GEMarker/A-warplane.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
src/renderer/public/GEMarker/A-water.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
src/renderer/public/GEMarker/A-wharf.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/A-woman.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/B-bank.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/B-camera2.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/B-dollar.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/renderer/public/GEMarker/B-euro.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/public/GEMarker/B-fire control.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/B-gas_stations.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/B-government.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/B-hospital.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/B-police office.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/B-police.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/B-school.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/B-wheel_chair_accessible.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/B-yen.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/B-ylw-diamond.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/renderer/public/GEMarker/B-ylw-stars.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/renderer/public/GEMarker/B-zhuixing.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/C-Shop.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/C-arts.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/C-bars.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/C-coffee.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/C-convenience.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/C-dining.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/C-grocery.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/renderer/public/GEMarker/C-lodging.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/C-movies.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/public/GEMarker/C-parks.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/C-residential quarters.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/C-salon.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/C-snack_bar.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/D-DefaultIcon.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
src/renderer/public/GEMarker/D-Left.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/renderer/public/GEMarker/D-battery.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/D-earthquake.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/public/GEMarker/D-electricity.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/D-front.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/D-no entry.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
src/renderer/public/GEMarker/D-no stopping.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
src/renderer/public/GEMarker/D-nuclear_power.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/D-power_overview.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/D-power_transmission_tower.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/D-red-diamond.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
src/renderer/public/GEMarker/D-red-stars.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
src/renderer/public/GEMarker/D-right.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/D-tower.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/D-transformer.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src/renderer/public/GEMarker/D-transformer_substation.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/D-turn Left right.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/renderer/public/GEMarker/D-turn a corner.png
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
src/renderer/public/GEMarker/D-volcano.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/D-voltage.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
src/renderer/public/GEMarker/E-Collapse.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
src/renderer/public/GEMarker/E-construction.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/renderer/public/GEMarker/E-falling_rocks.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/public/GEMarker/F-NEVs.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
src/renderer/public/GEMarker/F-charging_pile.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
src/renderer/public/GEMarker/F-factory.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
src/renderer/public/GEMarker/F-fishing.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
src/renderer/public/GEMarker/F-golf.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
src/renderer/public/GEMarker/F-grn-circle.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
src/renderer/public/GEMarker/F-hiker.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/renderer/public/GEMarker/F-horsebackriding.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
src/renderer/public/GEMarker/F-hydro-plant.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |