diff --git a/.vscode/launch.json b/.vscode/launch.json index 4401f2e6..e6bbef1d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,34 +2,38 @@ "version": "0.2.0", "configurations": [ { - "name": "Electron: Main", + "name": "Debug Main Process", "type": "node", "request": "launch", - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", + "cwd": "${workspaceRoot}", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite", "windows": { - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd" + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite.cmd" }, - "preLaunchTask": "electron-debug", - "args": ["--remote-debugging-port=9223", "./dist_electron"], - "outFiles": ["${workspaceFolder}/dist_electron/**/*.js"] + "runtimeArgs": ["--sourcemap"], + "env": { + "REMOTE_DEBUGGING_PORT": "9222" + } }, { - "name": "Electron: Renderer", - "type": "chrome", + "name": "Debug Renderer Process", + "port": 9222, "request": "attach", - "port": 9223, - "urlFilter": "http://localhost:*", - "timeout": 30000, - "webRoot": "${workspaceFolder}/src", - "sourceMapPathOverrides": { - "webpack:///./src/*": "${webRoot}/*" + "type": "chrome", + "webRoot": "${workspaceFolder}/src/renderer", + "timeout": 60000, + "presentation": { + "hidden": true } } ], "compounds": [ { - "name": "Electron: All", - "configurations": ["Electron: Main", "Electron: Renderer"] + "name": "Debug All", + "configurations": ["Debug Main Process", "Debug Renderer Process"], + "presentation": { + "order": 1 + } } ] } \ No newline at end of file diff --git a/src/main/apis/app/window/constants.ts b/src/main/apis/app/window/constants.ts index e0043445..bc3dd0d2 100644 --- a/src/main/apis/app/window/constants.ts +++ b/src/main/apis/app/window/constants.ts @@ -1,10 +1,5 @@ const isDevelopment = process.env.NODE_ENV !== 'production' -export const MANUAL_WINDOW_URL = - process.env.NODE_ENV === 'development' - ? 'http://localhost:3000/documents' - : 'index.html/documents' - export const MINI_WINDOW_URL = isDevelopment ? 'http://localhost:3000/mini-page' : 'index.html/mini-page' diff --git a/src/main/apis/app/window/windowList.ts b/src/main/apis/app/window/windowList.ts index 2fddf5ab..3aa58031 100644 --- a/src/main/apis/app/window/windowList.ts +++ b/src/main/apis/app/window/windowList.ts @@ -1,3 +1,4 @@ +import path from 'node:path' import { fileURLToPath } from 'node:url' import bus from '@core/bus' @@ -13,14 +14,6 @@ import { configPaths } from '#/utils/configPaths' import { T as $t } from '~/i18n' import logo from '../../../../../resources/logo.png?asset' -import { - MANUAL_WINDOW_URL, - MINI_WINDOW_URL, - RENAME_WINDOW_URL, - SETTING_WINDOW_URL, - TOOLBOX_WINDOW_URL, - TRAY_WINDOW_URL -} from './constants' const windowList = new Map() @@ -34,6 +27,8 @@ const getDefaultWindowSizes = (): { width: number; height: number } => { height: mainWindowHeight || 800 } } + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) const preloadPath = fileURLToPath(new URL('../preload/index.mjs', import.meta.url)) const { width: defaultWindowWidth, height: defaultWindowHeight } = getDefaultWindowSizes() @@ -58,29 +53,6 @@ const trayWindowOptions = { } } -const manualWindowOptions = { - height: 800, - width: 1200, - show: false, - frame: true, - center: true, - fullscreenable: true, - resizable: true, - title: 'Manual', - vibrancy: 'ultra-dark', - transparent: false, - webPreferences: { - sandbox: false, - webviewTag: true, - backgroundThrottling: false, - preload: preloadPath, - nodeIntegration: false, - contextIsolation: true, - nodeIntegrationInWorker: true, - webSecurity: false - } -} as IBrowserWindowOptions - const settingWindowOptions = { height: defaultWindowHeight, width: defaultWindowWidth, @@ -167,7 +139,7 @@ const toolboxWindowOptions = { fullscreenable: false, resizable: false, title: `PicList ${$t('TOOLBOX')}`, - vibrancy: 'ultra-dark', + backgroundColor: '#ebeef5', icon: logo, webPreferences: { sandbox: false, @@ -191,30 +163,31 @@ windowList.set(IWindowList.TRAY_WINDOW, { multiple: false, options: () => trayWindowOptions, callback (window) { - window.loadURL(TRAY_WINDOW_URL) + if (!app.isPackaged && process.env.ELECTRON_RENDERER_URL) { + console.log('load setting window from renderer url') + window.loadURL(process.env.ELECTRON_RENDERER_URL) + } else { + window.loadFile(path.join(__dirname, '../render/index.html')) + } window.on('blur', () => { window.hide() }) } }) -windowList.set(IWindowList.MANUAL_WINDOW, { - isValid: true, - multiple: false, - options: () => manualWindowOptions, - callback (window) { - window.loadURL(MANUAL_WINDOW_URL) - window.focus() - } -}) - windowList.set(IWindowList.SETTING_WINDOW, { isValid: true, multiple: false, options: () => settingWindowOptions, callback (window, windowManager) { - window.loadURL(SETTING_WINDOW_URL) - window.webContents.openDevTools({ mode: 'detach' }) + if (!app.isPackaged && process.env.ELECTRON_RENDERER_URL) { + console.log('load setting window from renderer url') + window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#main-page/upload`) + } else { + window.loadFile(path.join(__dirname, '../render/index.html'), { + hash: 'main-page/upload' + }) + } window.on('closed', () => { bus.emit(TOGGLE_SHORTKEY_MODIFIED_MODE, false) if (process.platform === 'linux') { @@ -233,7 +206,13 @@ windowList.set(IWindowList.MINI_WINDOW, { multiple: false, options: () => miniWindowOptions, callback (window) { - window.loadURL(MINI_WINDOW_URL) + if (!app.isPackaged && process.env.ELECTRON_RENDERER_URL) { + window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#mini-page`) + } else { + window.loadFile(path.join(__dirname, '../render/index.html'), { + hash: 'mini-page' + }) + } } }) @@ -242,7 +221,14 @@ windowList.set(IWindowList.RENAME_WINDOW, { multiple: true, options: () => renameWindowOptions, async callback (window, windowManager) { - window.loadURL(RENAME_WINDOW_URL) + if (!app.isPackaged && process.env.ELECTRON_RENDERER_URL) { + console.log('load setting window from renderer url') + window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#rename-page`) + } else { + window.loadFile(path.join(__dirname, '../render/index.html'), { + hash: 'rename-page' + }) + } const currentWindow = windowManager.getAvailableWindow(true) if (currentWindow && currentWindow.isVisible()) { const { x, y, width, height } = currentWindow.getBounds() @@ -258,7 +244,14 @@ windowList.set(IWindowList.TOOLBOX_WINDOW, { multiple: false, options: () => toolboxWindowOptions, async callback (window, windowManager) { - window.loadURL(TOOLBOX_WINDOW_URL) + if (!app.isPackaged && process.env.ELECTRON_RENDERER_URL) { + console.log('load setting window from renderer url') + window.loadURL(`${process.env.ELECTRON_RENDERER_URL}#toolbox-page`) + } else { + window.loadFile(path.join(__dirname, '../render/index.html'), { + hash: 'toolbox-page' + }) + } const currentWindow = windowManager.getAvailableWindow(true) if (currentWindow && currentWindow.isVisible()) { const { x, y, width, height } = currentWindow.getBounds() diff --git a/src/main/events/rpc/routes/system/window.ts b/src/main/events/rpc/routes/system/window.ts index 6d693452..81544e86 100644 --- a/src/main/events/rpc/routes/system/window.ts +++ b/src/main/events/rpc/routes/system/window.ts @@ -29,12 +29,6 @@ export default [ } } }, - { - action: IRPCActionType.OPEN_MANUAL_WINDOW, - handler: async () => { - windowManager.get(IWindowList.MANUAL_WINDOW)!.show() - } - }, { action: IRPCActionType.OPEN_MINI_WINDOW, handler: async () => { diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 442261a0..550c170c 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -11,14 +11,12 @@ import type { IConfig } from 'piclist' import { onBeforeMount, onMounted } from 'vue' -import { useATagClick } from '@/hooks/useATagClick' import { useStore } from '@/hooks/useStore' import { getConfig } from '@/utils/dataSender' import { pageReloadCount } from '@/utils/global' import { useAppStore } from './hooks/appStore' -useATagClick() const store = useStore() const appStore = useAppStore() diff --git a/src/renderer/components/ImageProcessSetting.vue b/src/renderer/components/ImageProcessSetting.vue index f70bb4ea..2c850de4 100644 --- a/src/renderer/components/ImageProcessSetting.vue +++ b/src/renderer/components/ImageProcessSetting.vue @@ -1,277 +1,553 @@