Переглянути джерело

fix: 修复启动异常
1. 修复因为没有安装依赖的启动异常
2. 修复配置路径错误的问题

kindring 3 місяців тому
батько
коміт
80b5a009c3
8 змінених файлів з 18 додано та 7 видалено
  1. 1 1
      build/app.js
  2. 1 1
      build/app.js.map
  3. 1 1
      package.json
  4. 1 1
      src/app.ts
  5. 1 1
      src/control/imgManager.ts
  6. 1 1
      src/webRouter/imgControl.ts
  7. 1 1
      src/webRouter/pcControl.ts
  8. 11 0
      start.js

+ 1 - 1
build/app.js

@@ -11,7 +11,7 @@ var morganMiddleware_1 = __importDefault(require("./middleware/morganMiddleware"
 var apiIndex_1 = __importDefault(require("./webRouter/apiIndex"));
 main();
 function main() {
-    var serverConfig = (0, loadConfig_1.loadServerConfig)('./config/Server.json');
+    var serverConfig = (0, loadConfig_1.loadServerConfig)('config/Server.json');
     if (serverConfig === null) {
         logger_1.default.error("无法加载服务器配置文件");
         throw new Error("无法加载服务器配置文件");

+ 1 - 1
build/app.js.map

@@ -1 +1 @@
-{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;AAAA,oDAA+E;AAC/E,4DAAqC;AACrC,iDAAmD;AACnD,wDAAiC;AACjC,mFAA4D;AAE5D,kEAA4C;AAC5C,IAAI,EAAE,CAAC;AACP,SAAS,IAAI;IACT,IAAI,YAAY,GAAG,IAAA,6BAAgB,EAAC,sBAAsB,CAAC,CAAA;IAC3D,IAAG,YAAY,KAAK,IAAI,EAAC;QACrB,gBAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC;KAClC;IAED,IAAM,GAAG,GAAe,IAAA,iBAAO,GAAE,CAAC;IAClC,GAAG,CAAC,GAAG,CAAC,0BAAgB,CAAC,CAAC;IAC1B,GAAG,CAAC,GAAG,CAAC,SAAS,EAAC,iBAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/C,GAAG,CAAC,GA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AAC;IAC1B,GAAG,CAAC,GAAG,CAAC,SAAS,EAAC,iBAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/C,GAAG,CAAC,GAAG,CAAC,qBAAU,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAClE,GAAG,CAAC,GAAG,CAAC,qBAAU,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC5C,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,UAAC,GAAW,EAAE,GAAY,EAAE,IAAiB;QACtD,GAAG,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,GAAG,CAAC,MAAM,EAAC,kBAAQ,CAAC,CAAC;IACzB,GAAG,CAAC,GAAG,CAAC,UAAC,GAAG,EAAC,GAAG;QACZ,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC,CAAC,CAAA;IACF,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE;QAC7B,gBAAM,CAAC,IAAI,CAAC,oFAA2B,YAAY,CAAC,OAAO,CAAE,CAAC,CAAA;QAC9D,yEAAyE;IAC7E,CAAC,CAAC,CAAC;AACP,CAAC"}

+ 1 - 1
package.json

@@ -21,7 +21,7 @@
   },
   "scripts": {
     "tsc": "tsc",
-    "start": "node build/app.js",
+    "start": "node start.js",
     "dev": "nodemon src/app.ts",
     "build": "tsc -p .",
     "test": "echo \"Error: no test specified\" && exit 1"

+ 1 - 1
src/app.ts

@@ -7,7 +7,7 @@ import morganMiddleware from './middleware/morganMiddleware'
 import apiIndex from "./webRouter/apiIndex";
 main();
 function main():void{
-    let serverConfig = loadServerConfig('./config/Server.json')
+    let serverConfig = loadServerConfig('config/Server.json')
     if(serverConfig === null){
         logger.error("无法加载服务器配置文件");
         throw new Error("无法加载服务器配置文件");

+ 1 - 1
src/control/imgManager.ts

@@ -24,7 +24,7 @@ interface FileCount {
 
 
 
-const customConfig = loadCustomConfig("./config/Custom.json");
+const customConfig = loadCustomConfig("config/Custom.json");
 
 export function showDirs ():string[]{
     if (!customConfig){

+ 1 - 1
src/webRouter/imgControl.ts

@@ -25,7 +25,7 @@ router.get('/moveFile',(req, res)=> {
         const mvMode = mvModeValue === 'move' ? MvMode.move : MvMode.copy;
 
         if (!checkPath || !destPath || !extName)
-            return res.status(400).json({ code: -1, msg: '参数错误: src: images, dest: target, extName: xmp' });
+            return res.status(400).json({ code: -1, msg: '参数错误: src: images, dest: target, extName: xmp, move: move|copy' });
         const result = mvImgFile({
             checkPath: checkPath,
             targetPath: destPath,

+ 1 - 1
src/webRouter/pcControl.ts

@@ -6,7 +6,7 @@ import {openPc} from "../lib/wol";
 
 
 const router = Router();
-const customConfig = loadCustomConfig("./config/Custom.json");
+const customConfig = loadCustomConfig("config/Custom.json");
 router.get('/openMain',(req, res)=> {
     if (!customConfig) {
         res.json({

+ 11 - 0
start.js

@@ -0,0 +1,11 @@
+const { execSync } = require('child_process');
+const fs = require('fs');
+
+// 检查 node_modules 是否存在
+if (!fs.existsSync('node_modules')) {
+    console.log('node_modules 不存在,正在安装依赖...');
+    execSync('npm install', { stdio: 'inherit' });
+}
+
+// 启动应用
+execSync('node build/app.js', { stdio: 'inherit' });