From fa5c7add7a111ef17ce62ce965507a7c6a07f2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Mon, 1 Jul 2024 18:45:48 +0800 Subject: [PATCH] refactor: new core --- src/newcore/index.ts | 2 ++ src/newcore/main.ts | 29 ++++++++++++++++++++++++ src/newcore/platform/liteloader/index.ts | 1 + src/newcore/platform/node/index.ts | 1 + src/newcore/util/proxyWrapper.ts | 1 + 5 files changed, 34 insertions(+) create mode 100644 src/newcore/index.ts create mode 100644 src/newcore/main.ts create mode 100644 src/newcore/platform/liteloader/index.ts create mode 100644 src/newcore/platform/node/index.ts create mode 100644 src/newcore/util/proxyWrapper.ts diff --git a/src/newcore/index.ts b/src/newcore/index.ts new file mode 100644 index 0000000..89b9370 --- /dev/null +++ b/src/newcore/index.ts @@ -0,0 +1,2 @@ +//统一到处入口 +export * from './main'; \ No newline at end of file diff --git a/src/newcore/main.ts b/src/newcore/main.ts new file mode 100644 index 0000000..38c417c --- /dev/null +++ b/src/newcore/main.ts @@ -0,0 +1,29 @@ +enum NapCatCorePlatform { + Node = 'Node',//命令行模式加载 + LiteLoader = 'LiteLoader',//LL插件模式加载 +} +class NewNapCatCore { + platform: NapCatCorePlatform; // 平台 + constructor(platform: NapCatCorePlatform) { + this.platform = platform; + } +} +export class NapCatCoreManger { + static core: NewNapCatCore | undefined = undefined; + static defaultPlatform: NapCatCorePlatform = NapCatCorePlatform.Node; + static SetDefaultCore(platform: NapCatCorePlatform) { + if (this.core !== undefined) { + return; + } + this.defaultPlatform = platform; + } + static GetPlatform(): NapCatCorePlatform { + return NapCatCoreManger.defaultPlatform; + } + static GetInstance(): NewNapCatCore { + if (this.core === undefined) { + this.core = new NewNapCatCore(NapCatCoreManger.defaultPlatform); + } + return this.core; + } +} \ No newline at end of file diff --git a/src/newcore/platform/liteloader/index.ts b/src/newcore/platform/liteloader/index.ts new file mode 100644 index 0000000..7f2ec82 --- /dev/null +++ b/src/newcore/platform/liteloader/index.ts @@ -0,0 +1 @@ +//拦截proxy到会话 \ No newline at end of file diff --git a/src/newcore/platform/node/index.ts b/src/newcore/platform/node/index.ts new file mode 100644 index 0000000..6040b8d --- /dev/null +++ b/src/newcore/platform/node/index.ts @@ -0,0 +1 @@ +//初始化跟之前一样 \ No newline at end of file diff --git a/src/newcore/util/proxyWrapper.ts b/src/newcore/util/proxyWrapper.ts new file mode 100644 index 0000000..0fea8f6 --- /dev/null +++ b/src/newcore/util/proxyWrapper.ts @@ -0,0 +1 @@ +//proxy封装工具类 \ No newline at end of file