From 8d2a2eef97172e6bee6dad8a73c8c943fd3845c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A4=8F=E5=A4=A7=E8=83=86?= <1101282782@qq.com>
Date: Wed, 3 Dec 2025 10:23:18 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
resources/java/app/application.yml | 2 +-
src/main/index.ts | 89 ++++++++++++++++---
.../setPup/components/engineering.vue | 2 +-
.../setPup/components/graphLabelManage.vue | 21 +++--
.../setPup/components/photoManage.vue | 21 +++--
.../components/setPup/components/setting.vue | 5 +-
.../components/propertyBox/CircleViewShed.vue | 18 +++-
.../views/components/propertyBox/CutFill.vue | 8 ++
.../views/components/propertyBox/photo.vue | 72 +++++++++------
9 files changed, 175 insertions(+), 63 deletions(-)
diff --git a/resources/java/app/application.yml b/resources/java/app/application.yml
index 09039c9..41e4c70 100644
--- a/resources/java/app/application.yml
+++ b/resources/java/app/application.yml
@@ -1,7 +1,7 @@
server:
host: 127.0.0.1
port: 8848
- path: C:\Users\takeshita\AppData\Roaming\dzsp_shijingjun_offline_Y_save
+ path: C:\Users\Administrator\AppData\Roaming\dzsp_shijingjun_offline_Y_save
poi:
global:
enabled: false
diff --git a/src/main/index.ts b/src/main/index.ts
index eb297f0..a5c441e 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -1,4 +1,4 @@
-import { app, shell, BrowserWindow, ipcMain, globalShortcut, dialog } from 'electron'
+import { app, shell, BrowserWindow, ipcMain, globalShortcut, dialog, session } from 'electron'
import path, { join } from 'path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
import icon from '../../resources/earth.png?asset'
@@ -376,21 +376,90 @@ function createWindow(): void {
let _winMap = new Map();
// 监听渲染进程创建新窗口的请求
+ function createTempSession() {
+ // 生成唯一会话名称(避免冲突)
+ const sessionName = `temp-session-${Date.now()}-${Math.random().toString(36).slice(2)}`;
+ // 创建独立会话(基于默认分区,但命名唯一)
+ const tempSession = session.fromPartition(sessionName, {
+ cache: true, // 允许缓存,但会话独立
+ persistent: false // 非持久化,关闭后自动清理
+ });
+
+ // 清空会话初始缓存(确保无残留)
+ tempSession.clearStorageData({
+ storages: [
+ 'appcache', 'cookies', 'localstorage', 'sessionstorage',
+ 'indexdb', 'cachestorage', 'websql'
+ ]
+ }).catch(err => console.error('清空临时会话缓存失败:', err));
+
+ return tempSession;
+ }
// @ts-ignore
ipcMain.handle('create-new-window', async (event, params, url, option, id) => {
+ // try {
+ // console.log('create-new-window', params, url, option, id)
+ // 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)
+ // });
+ // }
+ // _winMap.set(id, newWindow.id);
+ // return _winMap
+ // } catch (error) {
+ // console.error('创建窗口失败:', error);
+ // throw error; // 抛出错误以便渲染进程捕获
+ // }
+
try {
- const newWindow = await new BrowserWindow(params)
+
+ // 1. 创建独立临时会话
+ const tempSession = createTempSession();
+
+ // 2. 合并窗口配置:注入独立会话
+ const windowConfig = {
+ ...params,
+ webPreferences: {
+ ...params.webPreferences,
+ session: tempSession, // 关键:使用独立会话
+ nodeIntegration: true,
+ contextIsolation: false,
+ devTools: true,
+ webSecurity: false,
+ allowRunningInsecureContent: true
+ }
+ };
+
+ // 3. 创建新窗口
+ const newWindow = new BrowserWindow(windowConfig);
+
+ // 4. 加载URL并发送初始化数据
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)
- });
+ await newWindow.loadURL(url);
+ await newWindow.webContents.send("data", option);
}
+
+ // 5. 窗口关闭时清理会话和映射
+ newWindow.on('closed', async () => {
+ _winMap.delete(id);
+ // 清空会话缓存并销毁
+ await tempSession.clearStorageData({
+ storages: ['all'] // 清空所有存储
+ });
+ // 解除会话引用(触发GC)
+ tempSession.clearCache();
+ session.removePartition(tempSession.getPartition());
+ });
+
+ // 6. 记录窗口映射
_winMap.set(id, newWindow.id);
- return _winMap
+
+ return _winMap;
} catch (error) {
console.error('创建窗口失败:', error);
throw error; // 抛出错误以便渲染进程捕获
diff --git a/src/renderer/src/views/components/headers/components/setPup/components/engineering.vue b/src/renderer/src/views/components/headers/components/setPup/components/engineering.vue
index 4e9717f..21e741e 100644
--- a/src/renderer/src/views/components/headers/components/setPup/components/engineering.vue
+++ b/src/renderer/src/views/components/headers/components/setPup/components/engineering.vue
@@ -79,7 +79,7 @@
y6!J193Mm (t~M671LPZXkTQ@1pqSB!h-vFBwGH
z2wIGB693mCy}{xR$ZHpD;BXUvx=5v- ~}nVyc`+dyBWJ=&Y!W)H*~fGK!av^Fp+-Run4EvgAcI
z5;We@#xSkuUA4Tlc@(A{%PR(?Ag?1GK@tiX)SC~yHfbZTHvHRU&DTsyL{FdHlrgV}6Utw?7|
zK3nQ|Q+cUok4)9~8wHaunZ8Dtmhj0kc56llWlM2N*4zK;)=~7N4RZZXFUEaP@;$6;
ziI;E-*2kU#XeLMY8PrCCXtwvEFdMHTUHCg1#Ii%e*(1rOM^?;=(lRf_zGu(v)7TvQ
z50eaBg&(@dgj7hh{nWZtKPg=Bp~-Wv11CAS1t|wnICGQNV(0bW{lsO#SK0SZrQFpU
zwi#But;-K3of3G6KLlq
zc$v&IQIXe!vcMITP%1A)D-s@4G?Y!rqn>L*l=jMsGfJtv?8>?;QmWI0`bUAicUEvA
z1Vr0t`+oMPa&tRRt)K|@1lh8aQy6%2V$LmEmYRnt@1uOSk};cFZDBcI!)w;EwOk4O
zO&fJ8oK#p;O@N3xQjJ@gPv%bGp24-JyQoWkcsIue;034r+iu#|HB)LR#ndAz|Rg!BY*GX=W+$4!3xkYlD
cWKPVp{MIYD41MG^CgH#o{S=^bj?8hN8Ih0Ix?8K`MvPTm#
zRO2RB4-|fvl^vHOJ5pxzro+GO&sPpkj!f{bF^)!uC2!`l`ULrPFeU*eI@hobY$fn5
zpf!K0t}l2%ERMqK^k)h^!J9CW?cS9+D6A~G=py%D2gEYN?RH-tp*kQUWor;p_8n>0
zh#5ttFCK}Zv7R*sjIwK3$Ec@4u2GXp#n1K9XuC#_vFiN~rSX(Cc8;}a$iXH5Lp|P`
zxcd&AqCPoA6^CZ)HQt``x(T8WhH|m;>LYHsOb>q1#D>lW9M`t}<;7%2R;kTW`j}-z
zDfNjGN@_QS@pFASS$Tl8VX