From a22640bd2b52c7d9f34c5375aa0cc3bb8de1b540 Mon Sep 17 00:00:00 2001 From: JianMiau Date: Mon, 26 Aug 2024 17:17:41 +0800 Subject: [PATCH] =?UTF-8?q?[mod]=20=E6=8B=94=E6=8E=89=E5=88=A5=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/account/login.ts | 8 ++--- src/api/slot/ae.ts | 4 +-- src/api/slot/in.ts | 8 ++--- src/api/slot1/fgspin.ts | 10 +++---- src/api/slot1/spin.ts | 10 +++---- src/electron/main.ts | 4 +-- .../CatanEngine/NetManagerV2/NetConnector.ts | 30 +++---------------- tsconfig.json | 14 ++++----- 8 files changed, 32 insertions(+), 56 deletions(-) diff --git a/src/api/account/login.ts b/src/api/account/login.ts index 12cb0d5..fe2be0c 100644 --- a/src/api/account/login.ts +++ b/src/api/account/login.ts @@ -1,7 +1,7 @@ -import { INetRequest } from "@/script/Engine/CatanEngine/NetManagerV2/Core/INetRequest"; -import { INetResponse } from "@/script/Engine/CatanEngine/NetManagerV2/Core/INetResponse"; -import { RpcAccountLoginRequest, RpcAccountLoginResponse } from "@/shared/protocols/AccountRequest"; -import { ClientData } from "@/shared/protocols/define/interface"; +import { INetRequest } from "../../script/Engine/CatanEngine/NetManagerV2/Core/INetRequest"; +import { INetResponse } from "../../script/Engine/CatanEngine/NetManagerV2/Core/INetResponse"; +import { RpcAccountLoginRequest, RpcAccountLoginResponse } from "../../shared/protocols/AccountRequest"; +import { ClientData } from "../../shared/protocols/define/interface"; export default function* (clientData: ClientData, req: INetRequest): IterableIterator { const data: RpcAccountLoginRequest = req.Data diff --git a/src/api/slot/ae.ts b/src/api/slot/ae.ts index ca2e3dc..c7c0bbc 100644 --- a/src/api/slot/ae.ts +++ b/src/api/slot/ae.ts @@ -1,5 +1,5 @@ -import { INetRequest } from "@/script/Engine/CatanEngine/NetManagerV2/Core/INetRequest"; -import { ClientData } from "@/shared/protocols/define/interface"; +import { INetRequest } from "../../script/Engine/CatanEngine/NetManagerV2/Core/INetRequest"; +import { ClientData } from "../../shared/protocols/define/interface"; export default function* (clientData: ClientData, req: INetRequest): IterableIterator { const data = req.Data diff --git a/src/api/slot/in.ts b/src/api/slot/in.ts index 8e978af..ef4a535 100644 --- a/src/api/slot/in.ts +++ b/src/api/slot/in.ts @@ -1,7 +1,7 @@ -import { INetRequest } from "@/script/Engine/CatanEngine/NetManagerV2/Core/INetRequest"; -import { INetResponse } from "@/script/Engine/CatanEngine/NetManagerV2/Core/INetResponse"; -import { ClientData } from "@/shared/protocols/define/interface"; -import { RpcSlotInRequest, RpcSlotInResponse } from "@/shared/protocols/SlotRequest"; +import { INetRequest } from "../../script/Engine/CatanEngine/NetManagerV2/Core/INetRequest"; +import { INetResponse } from "../../script/Engine/CatanEngine/NetManagerV2/Core/INetResponse"; +import { ClientData } from "../../shared/protocols/define/interface"; +import { RpcSlotInRequest, RpcSlotInResponse } from "../../shared/protocols/SlotRequest"; export default function* (clientData: ClientData, req: INetRequest): IterableIterator { const data: RpcSlotInRequest = req.Data diff --git a/src/api/slot1/fgspin.ts b/src/api/slot1/fgspin.ts index be257a9..1662e40 100644 --- a/src/api/slot1/fgspin.ts +++ b/src/api/slot1/fgspin.ts @@ -1,8 +1,8 @@ -import { INetRequest } from "@/script/Engine/CatanEngine/NetManagerV2/Core/INetRequest"; -import { INetResponse } from "@/script/Engine/CatanEngine/NetManagerV2/Core/INetResponse"; -import { ClientData } from "@/shared/protocols/define/interface"; -import { RpcSlot1SpinRequest, RpcSlot1SpinResponse } from "@/shared/protocols/Slot1Request"; -import { RandomEx } from "@/Utils/Number/RandomEx"; +import { INetRequest } from "../../script/Engine/CatanEngine/NetManagerV2/Core/INetRequest"; +import { INetResponse } from "../../script/Engine/CatanEngine/NetManagerV2/Core/INetResponse"; +import { ClientData } from "../../shared/protocols/define/interface"; +import { RpcSlot1SpinRequest, RpcSlot1SpinResponse } from "../../shared/protocols/Slot1Request"; +import { RandomEx } from "../../Utils/Number/RandomEx"; export default function* (clientData: ClientData, req: INetRequest): IterableIterator { const data: RpcSlot1SpinRequest = req.Data diff --git a/src/api/slot1/spin.ts b/src/api/slot1/spin.ts index f2ecfa6..24a05a3 100644 --- a/src/api/slot1/spin.ts +++ b/src/api/slot1/spin.ts @@ -1,8 +1,8 @@ -import { INetRequest } from "@/script/Engine/CatanEngine/NetManagerV2/Core/INetRequest"; -import { INetResponse } from "@/script/Engine/CatanEngine/NetManagerV2/Core/INetResponse"; -import { ClientData } from "@/shared/protocols/define/interface"; -import { RpcSlot1SpinRequest, RpcSlot1SpinResponse } from "@/shared/protocols/Slot1Request"; -import { RandomEx } from "@/Utils/Number/RandomEx"; +import { INetRequest } from "../../script/Engine/CatanEngine/NetManagerV2/Core/INetRequest"; +import { INetResponse } from "../../script/Engine/CatanEngine/NetManagerV2/Core/INetResponse"; +import { ClientData } from "../../shared/protocols/define/interface"; +import { RpcSlot1SpinRequest, RpcSlot1SpinResponse } from "../../shared/protocols/Slot1Request"; +import { RandomEx } from "../../Utils/Number/RandomEx"; export default function* (clientData: ClientData, req: INetRequest): IterableIterator { const data: RpcSlot1SpinRequest = req.Data diff --git a/src/electron/main.ts b/src/electron/main.ts index ecb9eb2..d8dc520 100644 --- a/src/electron/main.ts +++ b/src/electron/main.ts @@ -5,12 +5,12 @@ import "module-alias/register"; // // 必載入 // import "../Utils/catan.ts"; -import { BaseEnumerator } from "@/CatanEngine/CoroutineV2/Core/BaseEnumerator"; -import { NetConnector } from "@/script/Engine/CatanEngine/NetManagerV2/NetConnector"; import dotenv from 'dotenv'; import { app, BrowserWindow, ipcMain } from 'electron'; import * as path from 'path'; import { WebSocketServer } from 'ws'; +import { BaseEnumerator } from "../CatanEngine/CoroutineV2/Core/BaseEnumerator"; +import { NetConnector } from "../script/Engine/CatanEngine/NetManagerV2/NetConnector"; onload(); diff --git a/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts b/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts index ee32ff2..87ba721 100644 --- a/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts +++ b/src/script/Engine/CatanEngine/NetManagerV2/NetConnector.ts @@ -1,9 +1,9 @@ -import { CoroutineV2 } from "@/CatanEngine/CoroutineV2/CoroutineV2"; -import { Encoding } from "@/CatanEngine/CSharp/System/Text/Encoding"; -import { ClientData } from "@/shared/protocols/define/interface"; import { IncomingMessage } from "http"; import { WebSocket } from "ws"; +import { CoroutineV2 } from "../../../../CatanEngine/CoroutineV2/CoroutineV2"; import { Action } from "../../../../CatanEngine/CSharp/System/Action"; +import { Encoding } from "../../../../CatanEngine/CSharp/System/Text/Encoding"; +import { ClientData } from "../../../../shared/protocols/define/interface"; import { INetRequest } from "./Core/INetRequest"; import { INetResponse } from "./Core/INetResponse"; @@ -57,7 +57,7 @@ export class NetConnector { // 动态导入处理函数 try { // 动态导入文件 - const module = await import(`@/api/${req.Method.replace(".", "/")}`); + const module = await import(`../../../../api/${req.Method.replace(".", "/")}`); // 调用导入模块中的处理函数 if (module.default) { @@ -82,28 +82,6 @@ export class NetConnector { }; NetConnector.Send(socket, response); } - - // const module = await import(`@/api/${req.Method.replace(".", "/")}`); - // if (module) { - // let AsyncFunction: () => IterableIterator = function* (): IterableIterator { - // const response: INetResponse = yield* module.default(req); - // NetConnector.Send(socket, response); - // }; - // CoroutineV2.Single(AsyncFunction()).Start(); - // } else { - // const response: INetResponse = { - // Status: -1, - // Method: req.Method, - // Data: null, - // IsValid: false - // }; - // NetConnector.Send(socket, response); - // } - - // } catch (e) { - // console.error(e); - // throw new Error(`[RPC] 無法解析Server回應: ${str}`); - // } } } diff --git a/tsconfig.json b/tsconfig.json index e70f170..e1e7add 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,25 +1,23 @@ { "compilerOptions": { - "module": "commonjs", // 使用 CommonJS 模块系统 "target": "es2015", // 编译为 ES2015 + "module": "commonjs", // 使用 CommonJS 模块系统 "moduleResolution": "node", "sourceMap": true, "strict": false, // 启用严格模式 "esModuleInterop": true, // 启用 ES 模块的兼容性 "skipLibCheck": true, // 跳过库的类型检查 "forceConsistentCasingInFileNames": true, - "baseUrl": ".", - "paths": { - "@/*": ["src/*"] - }, + // "baseUrl": ".", + // "paths": { + // "@/*": ["src/*"] + // }, "outDir": "./dist", "rootDir": "./src", }, "include": [ "src/**/*.ts" ], - "exclude": [ - "node_modules" // 排除 node_modules 目录 - ] + "exclude": ["node_modules", "dist"] } \ No newline at end of file