Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f2bf83a50 | |||
| b3d77ba14d |
@@ -1,2 +0,0 @@
|
||||
VITE_h5_client_url=https://bqwlg.ii999.live:20038
|
||||
VITE_HsAppCode=1
|
||||
@@ -1,2 +1,2 @@
|
||||
VITE_h5_client_url=http://10.101.27.243:18900
|
||||
VITE_h5_client_url=http://10.102.9.139:18901
|
||||
VITE_HsAppCode=1
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
VITE_h5_client_url=http://172.22.33.66:18900
|
||||
VITE_HsAppCode=1
|
||||
@@ -1,2 +0,0 @@
|
||||
VITE_h5_client_url=http://10.9.18.138:18900
|
||||
VITE_HsAppCode=1
|
||||
@@ -1,44 +0,0 @@
|
||||
appId: com.huashiai.dify-market-manager-gui
|
||||
compression: maximum
|
||||
productName: 深燃智能体平台
|
||||
directories:
|
||||
buildResources: build
|
||||
files:
|
||||
- '!**/.vscode/*'
|
||||
- '!src/*'
|
||||
- '!electron.vite.config.{js,ts,mjs,cjs}'
|
||||
- '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}'
|
||||
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
|
||||
asarUnpack:
|
||||
- resources/**
|
||||
win:
|
||||
executableName: 深燃智能体平台
|
||||
nsis:
|
||||
artifactName: ${name}-${version}-setup.${ext}
|
||||
shortcutName: ${productName}
|
||||
uninstallDisplayName: ${productName}
|
||||
createDesktopShortcut: always
|
||||
mac:
|
||||
entitlementsInherit: build/entitlements.mac.plist
|
||||
extendInfo:
|
||||
- NSCameraUsageDescription: Application requests access to the device's camera.
|
||||
- NSMicrophoneUsageDescription: Application requests access to the device's microphone.
|
||||
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
|
||||
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
|
||||
notarize: false
|
||||
dmg:
|
||||
artifactName: ${name}-${version}.${ext}
|
||||
linux:
|
||||
target:
|
||||
- AppImage
|
||||
- deb
|
||||
maintainer: huashiai.org
|
||||
category: Utility
|
||||
appImage:
|
||||
artifactName: ${name}-${version}.${ext}
|
||||
npmRebuild: false
|
||||
publish:
|
||||
provider: generic
|
||||
url: ""
|
||||
electronDownload:
|
||||
mirror: https://npmmirror.com/mirrors/electron/
|
||||
@@ -1,6 +1,6 @@
|
||||
appId: com.huashiai.dify-market-manager-gui
|
||||
compression: maximum
|
||||
productName: 百千万AI智能体共创平台
|
||||
productName: 龙岗区百千万AI智能体共创平台
|
||||
directories:
|
||||
buildResources: build
|
||||
files:
|
||||
@@ -12,7 +12,7 @@ files:
|
||||
asarUnpack:
|
||||
- resources/**
|
||||
win:
|
||||
executableName: 百千万AI智能体共创平台
|
||||
executableName: 龙岗区百千万AI智能体共创平台
|
||||
nsis:
|
||||
artifactName: ${name}-${version}-setup.${ext}
|
||||
shortcutName: ${productName}
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
"dev": "electron-vite --mode 13_27",
|
||||
"dev:11_120_test": "electron-vite --mode 11_120_test",
|
||||
"dev:lgzs": "electron-vite --mode lgzs",
|
||||
"dev:shenranqi": "electron-vite --mode shenranqi",
|
||||
"dev:pingshan": "electron-vite --mode pingshan",
|
||||
"dev:lgzs_test": "electron-vite --mode lgzs_test",
|
||||
"dev:lg_mirror": "electron-vite --mode lg_mirror",
|
||||
"package": "electron-forge package",
|
||||
@@ -24,10 +22,9 @@
|
||||
"build:unpack": "npm run build && electron-builder --dir",
|
||||
"build:win": "electron-vite build --mode 11.120 && electron-builder --win ",
|
||||
"build:win_11_120": "electron-vite build --mode 11_120 && electron-builder --win ",
|
||||
"build:win_shenranqi": "electron-vite build --mode shenranqi && electron-builder --win ",
|
||||
"build:win_13_27": "electron-vite build --mode 13_27 && electron-builder --win ",
|
||||
"build:win_14_200": "electron-vite build --mode 14_200 && electron-builder --win ",
|
||||
"build:win_lgzs": "electron-vite build --mode lgzs && electron-builder --win ",
|
||||
"build:win_lgzs_test": "electron-vite build --mode lgzs_test && electron-builder --win ",
|
||||
"build:win_jiangsu": "electron-vite build --mode jiangsu && electron-builder --win ",
|
||||
"build:win_nanshan": "electron-vite build --mode nanshan && electron-builder --win",
|
||||
"build:win_huashiai": "electron-vite build --mode huashiai && electron-builder --win",
|
||||
@@ -56,8 +53,6 @@
|
||||
"xe-utils": "^3.7.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron-forge/cli": "^6.2.1",
|
||||
"@electron-forge/maker-deb": "^6.2.1",
|
||||
"@electron-toolkit/eslint-config": "^2.0.0",
|
||||
"@electron-toolkit/eslint-config-prettier": "^3.0.0",
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
|
||||
@@ -25,9 +25,11 @@ export function setupIPC() {
|
||||
logger.info('=======================================initClientData')
|
||||
logger.info(data)
|
||||
|
||||
setStoreValue("h5_data", data);
|
||||
setStoreValue("token", data.token);
|
||||
setStoreValue("dify_access_token:", data.dify_access_token);
|
||||
setStoreValue("dify_refresh_token", data.dify_refresh_token);
|
||||
setStoreValue("dify_csrf_token", data.dify_csrf_token);
|
||||
setStoreValue("userInfo", data.userInfo);
|
||||
|
||||
setStoreValue("apiUrl", data.apiUrl);
|
||||
|
||||
@@ -17,6 +17,8 @@ let difyfullScreenWindow = null
|
||||
let drageWindow = null
|
||||
let apiConfigWindow = null
|
||||
let configWindow = null
|
||||
|
||||
let cookieLogTimer = null
|
||||
import { clearAllSessionData } from './utils/cacheUtils.js'
|
||||
// 权限授权
|
||||
async function checkMediaAccess(mediaType){
|
||||
@@ -85,7 +87,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")
|
||||
@@ -107,12 +120,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()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
@@ -291,19 +309,30 @@ 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', () => {
|
||||
globalShortcut.unregisterAll() // 注销所有快捷键
|
||||
})
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
export async function createNewWindow(url, access_token, refresh_token,sandbox=false) {
|
||||
const origin_url = url
|
||||
logger.info('==========createNewWindow')
|
||||
logger.info('==========createNewWindow sandbox',sandbox)
|
||||
const csrf_token=getStoreValue("dify_csrf_token")
|
||||
|
||||
await checkAndApplyDeviceAccessPrivilege()
|
||||
|
||||
@@ -313,6 +342,7 @@ export async function createNewWindow(url, access_token, refresh_token,sandbox=f
|
||||
show: false,
|
||||
icon: icon,
|
||||
webPreferences: {
|
||||
partition: 'persist:my-shared-session',
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true,
|
||||
nodeIntegrationInWorker: true,
|
||||
@@ -329,9 +359,25 @@ export async function createNewWindow(url, access_token, refresh_token,sandbox=f
|
||||
registerShortcuts(difyfullScreenWindow)
|
||||
})
|
||||
|
||||
let code = `localStorage.setItem("IsHsAiApp","IsHsAiApp");localStorage.setItem("console_token","${access_token}");localStorage.setItem("refresh_token","12");`
|
||||
const isAdmin = getStoreValue("isAdmin")
|
||||
const hs_version = getStoreValue("hs_version")
|
||||
const dify_csrf_token = getStoreValue("dify_csrf_token")
|
||||
|
||||
const cookieStatements = [
|
||||
`document.cookie = "access_token=${access_token}; path=/";`,
|
||||
`document.cookie = "refresh_token=${refresh_token}; path=/";`,
|
||||
`document.cookie = "csrf_token=${dify_csrf_token}; path=/";`,
|
||||
`document.cookie = "hs_version=${hs_version}; path=/";`
|
||||
].join('\n');
|
||||
|
||||
const localStorageStatements = [
|
||||
`localStorage.setItem("IsHsAiApp", "IsHsAiApp");`,
|
||||
`localStorage.setItem("console_token", "${access_token}");`,
|
||||
`localStorage.setItem("refresh_token", "12");`
|
||||
].join('\n');
|
||||
|
||||
let code = `${localStorageStatements}\n${cookieStatements};`;
|
||||
|
||||
const isAdmin = getStoreValue("isAdmin")
|
||||
let display='';
|
||||
|
||||
if (isAdmin==true){
|
||||
@@ -354,7 +400,7 @@ export async function createNewWindow(url, access_token, refresh_token,sandbox=f
|
||||
`
|
||||
}
|
||||
|
||||
code=code+`document.cookie="hs_version=${hs_version}";`
|
||||
code=code+`;document.cookie="hs_version=${hs_version}; path=/";`
|
||||
|
||||
difyfullScreenWindow.webContents.on('did-finish-load', () => {
|
||||
difyfullScreenWindow.webContents
|
||||
@@ -364,6 +410,7 @@ export async function createNewWindow(url, access_token, refresh_token,sandbox=f
|
||||
.catch((error) => {
|
||||
console.error('Error:', error)
|
||||
})
|
||||
startCookieLogger(2000)
|
||||
let times = 0
|
||||
let timer = setInterval(() => {
|
||||
if (times > 3) {
|
||||
@@ -387,12 +434,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) => {
|
||||
@@ -403,6 +454,10 @@ export async function createNewWindow(url, access_token, refresh_token,sandbox=f
|
||||
difyfullScreenWindow.on('closed', () => {
|
||||
logger.info('主窗口已关闭')
|
||||
difyfullScreenWindow = null
|
||||
if (cookieLogTimer) {
|
||||
clearInterval(cookieLogTimer)
|
||||
cookieLogTimer = null
|
||||
}
|
||||
})
|
||||
|
||||
difyfullScreenWindow.webContents.on('did-navigate', (event, url) => {
|
||||
@@ -544,6 +599,93 @@ export async function createNewWindow(url, access_token, refresh_token,sandbox=f
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取并打印全屏窗口的 Cookie 数据
|
||||
* 每次调用从当前页面会话中读取 Cookie 并输出到控制台
|
||||
*/
|
||||
export async function logDifyFullScreenCookies() {
|
||||
try {
|
||||
if (!difyfullScreenWindow || difyfullScreenWindow.isDestroyed()) {
|
||||
return
|
||||
}
|
||||
const wc = difyfullScreenWindow.webContents
|
||||
const currentURL = wc.getURL()
|
||||
const sess = wc.session
|
||||
let cookies = []
|
||||
if (currentURL && typeof currentURL === 'string' && currentURL.length > 0) {
|
||||
cookies = await sess.cookies.get({ url: currentURL })
|
||||
} else {
|
||||
cookies = await sess.cookies.get({})
|
||||
}
|
||||
const simplified = cookies.map(c => ({
|
||||
name: c.name,
|
||||
value: c.value,
|
||||
domain: c.domain,
|
||||
path: c.path,
|
||||
httpOnly: c.httpOnly,
|
||||
secure: c.secure,
|
||||
sameSite: c.sameSite
|
||||
}))
|
||||
|
||||
logger.info('difyfullScreenWindow cookies:', simplified)
|
||||
|
||||
const needSync = new Set(['access_token', 'csrf_token', 'refresh_token'])
|
||||
for (const c of cookies) {
|
||||
if (needSync.has(c.name)) {
|
||||
|
||||
if (c.name === 'access_token') {
|
||||
setStoreValue('dify_access_token', c.value)
|
||||
} else if (c.name === 'csrf_token') {
|
||||
setStoreValue('dify_csrf_token', c.value)
|
||||
} else if (c.name === 'refresh_token') {
|
||||
setStoreValue('dify_refresh_token', c.value)
|
||||
}
|
||||
await setCookieToMainWindow(c.name, c.value)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('获取 Cookie 失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动 Cookie 轮询打印
|
||||
* 以指定间隔定时获取并打印 Cookie,默认 2000ms
|
||||
* 如果已在运行则不会重复启动
|
||||
*/
|
||||
export function startCookieLogger(intervalMs = 2000) {
|
||||
if (cookieLogTimer) {
|
||||
return
|
||||
}
|
||||
cookieLogTimer = setInterval(() => {
|
||||
logDifyFullScreenCookies()
|
||||
}, intervalMs)
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定名称和值的 Cookie 写入主窗口
|
||||
*/
|
||||
async function setCookieToMainWindow(name, value) {
|
||||
try {
|
||||
if (!mainWindow || mainWindow.isDestroyed()) {
|
||||
return
|
||||
}
|
||||
const targetBase = getStoreValue('h5_client_url') || ''
|
||||
const targetUrl = targetBase ? `${targetBase}/` : (mainWindow.webContents.getURL() || 'http://localhost/')
|
||||
const msess = mainWindow.webContents.session
|
||||
await msess.cookies.set({
|
||||
url: targetUrl,
|
||||
name,
|
||||
value,
|
||||
path: '/'
|
||||
})
|
||||
await mainWindow.webContents.executeJavaScript(`document.cookie = "${name}=${value}; path=/";`)
|
||||
logger.info(`已写入主窗口 Cookie: ${name}`)
|
||||
} catch (error) {
|
||||
logger.error('写入主窗口 Cookie 失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
export function createDrageWindow() {
|
||||
logger.info('开始创建悬浮窗口')
|
||||
|
||||
@@ -564,6 +706,7 @@ export function createDrageWindow() {
|
||||
alwaysOnTop: true,
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
partition: 'persist:my-shared-session',
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true,
|
||||
nodeIntegrationInWorker: true,
|
||||
@@ -761,6 +904,7 @@ export function createConfigWindow() {
|
||||
parent: getMainWindow(),
|
||||
modal: true,
|
||||
webPreferences: {
|
||||
partition: 'persist:my-shared-session',
|
||||
contextIsolation: false,
|
||||
nodeIntegration: true,
|
||||
nodeIntegrationInWorker: true,
|
||||
|
||||
Reference in New Issue
Block a user