feat:支持windows桌面应用
This commit is contained in:
parent
55af6bd54e
commit
861d5f35bf
@ -2,7 +2,11 @@
|
||||
|
||||

|
||||
|
||||
renamer 的开源实现版本,BS 应用,支持 arm/x86 部署使用
|
||||
已打包镜像到 dockerhub 中:[hub.docker.com/r/fleyx/open-renamer](https://hub.docker.com/r/fleyx/open-renamer)
|
||||
renamer 的开源实现版本,BS 应用,支持 arm/x86 部署使用,两种使用方式:
|
||||
|
||||
1. 部署容器到 nas
|
||||
已打包到 dockerhub 中:[hub.docker.com/r/fleyx/open-renamer](https://hub.docker.com/r/fleyx/open-renamer)
|
||||
|
||||
2. 下载桌面应用使用,目前仅支持 windows,后续计划支持 mac,linux[下载地址](https://github.com/FleyX/open-renamer/releases/latest)
|
||||
|
||||
[点击查看参考文档](https://blog.fleyx.com/blog/detail/20221130)
|
||||
|
3
electron/.gitignore
vendored
3
electron/.gitignore
vendored
@ -2,4 +2,5 @@ node_modules
|
||||
dist
|
||||
openRenamerBackend
|
||||
build
|
||||
.idea
|
||||
.idea
|
||||
*.exe
|
@ -7,6 +7,12 @@ const {spawn} = require('child_process');
|
||||
const net = require('net');
|
||||
const log = require('electron-log');
|
||||
|
||||
|
||||
const userHome = process.env.HOME || process.env.USERPROFILE;
|
||||
const dataPath = path.join(userHome, "openRenamer");
|
||||
|
||||
log.transports.file.resolvePathFn = () => path.join(dataPath, 'logs/main.log');
|
||||
|
||||
async function createWindow() {
|
||||
// 隐藏菜单栏
|
||||
Menu.setApplicationMenu(null)
|
||||
@ -28,15 +34,16 @@ async function createWindow() {
|
||||
let port = await startBackend()
|
||||
// 并且为你的应用加载index.html
|
||||
// win.loadFile('./dist/index.html')
|
||||
log.info("backend service started")
|
||||
win.loadURL(`http://localhost:` + port);
|
||||
win.webContents.openDevTools()
|
||||
// win.webContents.openDevTools()
|
||||
}
|
||||
|
||||
// Electron会在初始化完成并且准备好创建浏览器窗口时调用这个方法
|
||||
// 部分 API 在 ready 事件触发后才能使用。
|
||||
app.whenReady().then(createWindow)
|
||||
// 当所有窗口都被关闭后退出
|
||||
app.on('window-all-closed', () => {
|
||||
app.on('windows-all-closed', () => {
|
||||
// 在 macOS 上,除非用户用 Cmd + Q 确定地退出,
|
||||
// 否则绝大部分应用及其菜单栏会保持激活。
|
||||
if (process.platform !== 'darwin') {
|
||||
@ -64,8 +71,6 @@ async function startBackend() {
|
||||
}
|
||||
port = port + 1;
|
||||
}
|
||||
let userHome = process.env.HOME || process.env.USERPROFILE;
|
||||
let dataPath = path.join(userHome, "openRenamer");
|
||||
log.info("start check folder exist", __dirname, __filename)
|
||||
let exist = fs.existsSync("openRenamerBackend");
|
||||
const childProcess = spawn('node', [(exist ? '' : '../') + 'openRenamerBackend/dist/index.js'], {
|
||||
@ -86,6 +91,15 @@ async function startBackend() {
|
||||
childProcess.on('close', (code) => {
|
||||
log.info(`child process exited with code ${code}`);
|
||||
});
|
||||
log.info("check service start");
|
||||
while (true) {
|
||||
await sleep(100);
|
||||
let success = !(await checkPort(port));
|
||||
if (success) {
|
||||
log.info("service start");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
||||
@ -106,4 +120,10 @@ function checkPort(port) {
|
||||
resolve(false);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function sleep(time) {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => resolve(), time);
|
||||
})
|
||||
}
|
@ -35,17 +35,24 @@
|
||||
"oneClick": false,
|
||||
"allowElevation": true,
|
||||
"allowToChangeInstallationDirectory": true,
|
||||
"installerIcon": "../openRenamerBackend/static/favicon.ico",
|
||||
"uninstallerIcon": "../openRenamerBackend/static/favicon.ico",
|
||||
"installerHeaderIcon": "../openRenamerBackend/static/favicon.ico",
|
||||
"installerIcon": "./renamer.ico",
|
||||
"uninstallerIcon": "./renamer.ico",
|
||||
"installerHeaderIcon": "./renamer.ico",
|
||||
"createDesktopShortcut": true,
|
||||
"createStartMenuShortcut": true,
|
||||
"shortcutName": "openRenamer"
|
||||
},
|
||||
"win": {
|
||||
"icon": "./renamer.ico",
|
||||
"target": [
|
||||
"nsis",
|
||||
"zip"
|
||||
],
|
||||
"extraFiles": [
|
||||
{
|
||||
"from": "windows/node.exe",
|
||||
"to": "node.exe"
|
||||
}
|
||||
]
|
||||
},
|
||||
"mac": {
|
||||
|
1615
electron/pnpm-lock.yaml
generated
1615
electron/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
1
electron/readme.md
Normal file
1
electron/readme.md
Normal file
@ -0,0 +1 @@
|
||||
需要下载windows版的node.js压缩包,将其中的node.exe 放到windowes目录下
|
BIN
electron/renamer.ico
Normal file
BIN
electron/renamer.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
@ -10,6 +10,7 @@ import init from "./middleware/init";
|
||||
import SqliteUtil from './util/SqliteHelper';
|
||||
import log from './util/LogUtil';
|
||||
import {updateQbInfo} from './util/QbApiUtil';
|
||||
import TimeUtil from "./util/TimeUtil";
|
||||
|
||||
|
||||
console.log(config);
|
||||
|
Loading…
x
Reference in New Issue
Block a user