优化
This commit is contained in:
@@ -69,7 +69,6 @@
|
||||
"electron-log": "^5.4.0",
|
||||
"electron-store": "^8.0.0",
|
||||
"electron-updater": "^6.3.9",
|
||||
"jquery": "^3.7.1",
|
||||
"ws": "^8.18.2",
|
||||
"xe-utils": "^3.7.4"
|
||||
},
|
||||
|
||||
@@ -21,6 +21,11 @@ import WebSocketClient from './utils/WebSocketClient';
|
||||
|
||||
let wsClient=null
|
||||
|
||||
const isDebugger=getStoreValue("isDebugger");
|
||||
if (isDebugger==null||isDebugger==''){
|
||||
setStoreValue("isDebugger",0)
|
||||
}
|
||||
|
||||
// 延迟创建WebSocket连接,等待应用完全启动后再连接
|
||||
function createWebSocketClient() {
|
||||
try {
|
||||
|
||||
@@ -124,7 +124,19 @@ export function createTray() {
|
||||
click: () => {
|
||||
createConfigWindow()
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '打开日志目录',
|
||||
click: () => {
|
||||
try {
|
||||
const configDir = app.getPath('userData')
|
||||
logger.info('打开配置文件目录:', configDir)
|
||||
shell.openPath(configDir)
|
||||
} catch (error) {
|
||||
logger.error('打开配置文件目录失败:', error)
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ type: 'separator' },
|
||||
@@ -144,8 +156,6 @@ export function createTray() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
|
||||
@@ -134,7 +134,18 @@ export async function createWindow() {
|
||||
// 创建菜单
|
||||
createMenu(mainWindow, difyfullScreenWindow)
|
||||
|
||||
let code = `localStorage.setItem("IsHsAiApp","IsHsAiApp");localStorage.setItem("HsAppCode",${import.meta.env.VITE_HsAppCode});`
|
||||
|
||||
|
||||
const isDebugger=getStoreValue("isDebugger");
|
||||
|
||||
|
||||
const localStorageStatements = [
|
||||
`localStorage.setItem("IsHsAiApp","IsHsAiApp");`,
|
||||
`localStorage.setItem("HsAppCode",${import.meta.env.VITE_HsAppCode});`,
|
||||
`localStorage.setItem("isDebugger",${isDebugger});`
|
||||
].join('\n');
|
||||
|
||||
let code = `${localStorageStatements};`;
|
||||
|
||||
|
||||
const isAdmin = getStoreValue("isAdmin")
|
||||
@@ -156,12 +167,17 @@ export async function createWindow() {
|
||||
|
||||
// 监听快捷键 F12 来打开/关闭 DevTools
|
||||
mainWindow.webContents.on('before-input-event', (event, input) => {
|
||||
if (input.key === 'F12') {
|
||||
mainWindow.webContents.toggleDevTools()
|
||||
} else if (input.key === 'F5') {
|
||||
logger.info('主窗口 F5 快捷键触发')
|
||||
mainWindow.reload()
|
||||
|
||||
const isDebugger=getStoreValue("isDebugger");
|
||||
if (isDebugger==1){
|
||||
if (input.key === 'F12') {
|
||||
mainWindow.webContents.toggleDevTools()
|
||||
} else if (input.key === 'F5') {
|
||||
logger.info('全屏窗口 F5 快捷键触发')
|
||||
mainWindow.reload()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
@@ -340,8 +356,15 @@ function registerShortcuts(window=null) {
|
||||
|
||||
logger.info(`F5快捷键注册${success ? '成功' : '失败'}`)
|
||||
|
||||
const isRegistered_F12 = globalShortcut.isRegistered('F12');
|
||||
logger.info(`Is F12 registered: ${isRegistered_F12}`);
|
||||
|
||||
|
||||
const isDebugger=getStoreValue("isDebugger");
|
||||
if (isDebugger==1){
|
||||
const isRegistered_F12 = globalShortcut.isRegistered('F12');
|
||||
logger.info(`Is F12 registered: ${isRegistered_F12}`);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 桌面端快要退出的时候,注销快捷键
|
||||
app.on('will-quit', () => {
|
||||
@@ -455,12 +478,16 @@ export async function createNewWindow(url, access_token, refresh_token,sandbox=f
|
||||
|
||||
// 监听快捷键 F12 来打开/关闭 DevTools
|
||||
difyfullScreenWindow.webContents.on('before-input-event', (event, input) => {
|
||||
if (input.key === 'F12') {
|
||||
difyfullScreenWindow.webContents.toggleDevTools()
|
||||
} else if (input.key === 'F5') {
|
||||
logger.info('全屏窗口 F5 快捷键触发')
|
||||
difyfullScreenWindow.reload()
|
||||
const isDebugger=getStoreValue("isDebugger");
|
||||
if (isDebugger==1){
|
||||
if (input.key === 'F12') {
|
||||
difyfullScreenWindow.webContents.toggleDevTools()
|
||||
} else if (input.key === 'F5') {
|
||||
logger.info('全屏窗口 F5 快捷键触发')
|
||||
difyfullScreenWindow.reload()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
difyfullScreenWindow.webContents.setWindowOpenHandler((details) => {
|
||||
|
||||
@@ -18,26 +18,5 @@ if (process.contextIsolated) {
|
||||
window.electron = electronAPI
|
||||
window.api = api
|
||||
|
||||
// ✅ 重点修复:覆盖 require('jquery') 让它返回 jQuery
|
||||
try {
|
||||
// 保存原始 require 避免循环
|
||||
const originalRequire = require;
|
||||
// 重写 require 函数,让 'jquery' 请求返回 jQuery
|
||||
require = (request) => {
|
||||
if (request === 'jquery') {
|
||||
// 确保 jQuery 已加载
|
||||
if (!window.jQuery) {
|
||||
window.jQuery = originalRequire('jquery');
|
||||
window.$ = window.jQuery;
|
||||
}
|
||||
return window.jQuery;
|
||||
}
|
||||
return originalRequire(request);
|
||||
};
|
||||
// 初始化 jQuery(触发上面的逻辑)
|
||||
window.jQuery = require('jquery');
|
||||
window.$ = window.jQuery;
|
||||
} catch (e) {
|
||||
console.error('Failed to load jQuery:', e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user