From 9b07f1568cf17546d2016b2c84bd34f80cb3cd22 Mon Sep 17 00:00:00 2001 From: unitwk Date: Mon, 15 Jan 2024 14:41:51 +0800 Subject: [PATCH] Fix: auto open page & npm command --- daemon/package.json | 3 +-- npm-dev-macos.sh | 2 +- npm-dev-windows.bat | 6 +++--- package.json | 6 +++--- panel/package.json | 2 +- panel/src/app.ts | 8 ++++++-- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/daemon/package.json b/daemon/package.json index 8d550d1f..999f1498 100644 --- a/daemon/package.json +++ b/daemon/package.json @@ -21,7 +21,6 @@ "@koa/router": "^10.0.0", "archiver": "^5.3.1", "axios": "^1.1.3", - "common": "file:../common", "compressing": "^1.5.1", "crypto": "^1.0.1", "dockerode": "3.1.0", @@ -32,7 +31,6 @@ "koa-body": "^4.2.0", "koa-send": "^5.0.1", "log4js": "^6.4.0", - "mcsmanager-common": "file:../common/dist", "module-alias": "^2.2.3", "node-disk-info": "^1.3.0", "node-schedule": "^2.0.0", @@ -46,6 +44,7 @@ "yaml": "^1.10.2" }, "devDependencies": { + "common": "file:../common", "@types/archiver": "^5.3.1", "@types/axios": "^0.14.0", "@types/dockerode": "^3.2.7", diff --git a/npm-dev-macos.sh b/npm-dev-macos.sh index 86ffb4d1..db98857f 100755 --- a/npm-dev-macos.sh +++ b/npm-dev-macos.sh @@ -3,7 +3,7 @@ currentPath="$(pwd)" for action in "daemon" "panel" "frontend" do - terminalCmd="tell app \"Terminal\" to do script \"cd $currentPath && npm run start-$action\"" + terminalCmd="tell app \"Terminal\" to do script \"cd $currentPath && npm run $action\"" echo "Run: $terminalCmd" osascript -e "$terminalCmd" done diff --git a/npm-dev-windows.bat b/npm-dev-windows.bat index 894a71da..252fed3b 100644 --- a/npm-dev-windows.bat +++ b/npm-dev-windows.bat @@ -1,5 +1,5 @@ -start npm run start-daemon -start npm run start-panel -start npm run start-frontend +start npm run daemon +start npm run panel +start npm run frontend diff --git a/package.json b/package.json index 03f05316..fb6f67fe 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ "scripts": { "i18n": "i18next-scanner --config i18-scanner.config.js", "preview-build": "cd common && npm install && npm run build", - "start-daemon": "cd daemon && npm run dev", - "start-frontend": "cd frontend && npm run dev", - "start-panel": "cd panel && npm run dev" + "daemon": "cd daemon && npm run dev", + "frontend": "cd frontend && npm run dev", + "panel": "cd panel && npm run dev" }, "dependencies": { "crc": "^4.3.2", diff --git a/panel/package.json b/panel/package.json index 2eac42eb..d850751f 100644 --- a/panel/package.json +++ b/panel/package.json @@ -21,7 +21,6 @@ "@koa/router": "^10.0.0", "axios": "^1.6.2", "bcryptjs": "^2.4.3", - "common": "file:../common", "crypto": "^1.0.1", "i18n": "^0.15.0", "i18next": "^21.8.14", @@ -42,6 +41,7 @@ "uuid": "^8.3.2" }, "devDependencies": { + "common": "file:../common", "@types/bcryptjs": "^2.4.2", "@types/fs-extra": "^9.0.11", "@types/koa": "^2.13.1", diff --git a/panel/src/app.ts b/panel/src/app.ts index d77fdb6a..4be70c6f 100755 --- a/panel/src/app.ts +++ b/panel/src/app.ts @@ -20,6 +20,10 @@ import { middleware as protocolMiddleware } from "./app/middleware/protocol"; import { mountRouters } from "./app/index"; import versionAdapter from "./app/service/version_adapter"; +function hasParams(name: string) { + return process.argv.includes(name); +} + function setupHttp(koaApp: Koa, port: number, host?: string) { const httpServer = http.createServer(koaApp.callback()); @@ -38,8 +42,8 @@ function setupHttp(koaApp: Koa, port: number, host?: string) { logger.info($t("TXT_CODE_app.exitTip", { port })); logger.info("=================================="); - if (os.platform() == "win32") { - open(`http://localhost:${port}/`).then(() => {}); + if (os.platform() == "win32" && hasParams("--open")) { + open(`http://localhost:${port}/`); } }