From 0b87ecae94a1a4a1bc0666c8721743653bb9419f Mon Sep 17 00:00:00 2001 From: fanxb Date: Wed, 20 Dec 2023 22:04:06 +0800 Subject: [PATCH] temp --- electron/.gitignore | 4 ++- electron/index.html | 8 ----- electron/main.js | 2 +- electron/package.json | 41 ++++++++++++++++++++++++-- openRenamerBackend/pnpm-lock.yaml | 8 ++--- openRenamerFront/src/App.vue | 8 +++-- openRenamerFront/src/utils/HttpUtil.js | 2 +- 7 files changed, 53 insertions(+), 20 deletions(-) delete mode 100644 electron/index.html diff --git a/electron/.gitignore b/electron/.gitignore index 653ad32..e7c983e 100644 --- a/electron/.gitignore +++ b/electron/.gitignore @@ -1,3 +1,5 @@ node_modules dist -openRenamerBackend \ No newline at end of file +openRenamerBackend +build +.idea \ No newline at end of file diff --git a/electron/index.html b/electron/index.html deleted file mode 100644 index 2ad88ad..0000000 --- a/electron/index.html +++ /dev/null @@ -1,8 +0,0 @@ - - - test - - -你好 - - \ No newline at end of file diff --git a/electron/main.js b/electron/main.js index 157756e..f1f7bda 100644 --- a/electron/main.js +++ b/electron/main.js @@ -26,7 +26,7 @@ async function createWindow() { let port = await startBackend() // 并且为你的应用加载index.html // win.loadFile('./dist/index.html') - win.loadURL(`file://${__dirname}/dist/index.html?port=` + port); + win.loadURL(`http://localhost:` + port); win.webContents.openDevTools() } diff --git a/electron/package.json b/electron/package.json index 50262b3..4f641ad 100644 --- a/electron/package.json +++ b/electron/package.json @@ -5,11 +5,48 @@ "main": "main.js", "scripts": { "start": "electron .", - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"Error: no test specified\" && exit 1", + "build": "electron-builder --win --x64" }, "author": "", "license": "ISC", "devDependencies": { - "electron": "^28.0.0" + "electron": "^28.0.0", + "electron-builder": "^24.9.1" + }, + "build": { + "productName": "openRenamer", + "appId": "electron.app", + "directories": { + "output": "build" + }, + "copyright": "xxxx", + "nsis": { + "oneClick": false, + "allowElevation": true, + "allowToChangeInstallationDirectory": true, + "installerIcon": "./openRenamerBackend/static/favicon.ico", + "uninstallerIcon": "./openRenamerBackend/static/favicon.ico", + "installerHeaderIcon": "./openRenamerBackend/static/favicon.ico", + "createDesktopShortcut": true, + "createStartMenuShortcut": true, + "shortcutName": "openRenamer" + }, + "win": { + "icon": "./openRenamerBackend/static/favicon.ico", + "target": [ + "nsis", + "zip" + ] + }, + "mac": { + "target": [ + "dmg", + "zip" + ] + }, + "linux": { + "icon": "build/icons" + } } } diff --git a/openRenamerBackend/pnpm-lock.yaml b/openRenamerBackend/pnpm-lock.yaml index ab718e5..eb69e4e 100644 --- a/openRenamerBackend/pnpm-lock.yaml +++ b/openRenamerBackend/pnpm-lock.yaml @@ -1,9 +1,5 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - dependencies: '@types/fs-extra': specifier: 5.0.4 @@ -1964,3 +1960,7 @@ packages: resolution: {integrity: sha512-RXRJzMiK6U2ye0BlGGZnmpwJDPgakn6aNQ0A7gHRbD4I0uvK4TW6UqkK1V0pp9jskjJBAXd3dRrbzWkqJ+6cxA==} engines: {node: '>= 4.0.0'} dev: false + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false diff --git a/openRenamerFront/src/App.vue b/openRenamerFront/src/App.vue index 5cf3e44..bf645fb 100644 --- a/openRenamerFront/src/App.vue +++ b/openRenamerFront/src/App.vue @@ -29,8 +29,8 @@    - 开源地址:open-renamer -   反馈 + 开源地址:open-renamer +   反馈 @@ -56,7 +56,9 @@ export default { queryMap[arr[0]] = arr[1]; }) if (queryMap.port) { - window.baseUrl = + window.baseUrl = "http://localhost:" + queryMap.port; + } else { + window.baseUrl = ""; } window.token = localStorage.getItem("token"); window.isWindows = await httpUtil.get("/file/isWindows"); diff --git a/openRenamerFront/src/utils/HttpUtil.js b/openRenamerFront/src/utils/HttpUtil.js index 4769a71..2b93c0b 100644 --- a/openRenamerFront/src/utils/HttpUtil.js +++ b/openRenamerFront/src/utils/HttpUtil.js @@ -14,7 +14,7 @@ import router from '../router/index'; async function request(url, method, params, body, isForm) { let options = { url, - baseURL: '/openRenamer/api', + baseURL: window.baseUrl + '/openRenamer/api', method, params, headers: {token: window.token}