From 02e2934b9a5f4e8dbc22035bce5d06ff1c1ec3a1 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Fri, 29 Sep 2023 17:48:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=A0=B9=E6=8D=AE=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E9=94=AE=E8=8E=B7=E5=8F=96=E5=AD=98=E5=82=A8=E5=AE=9E=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/index.ts | 4 ++-- src/core/main/storage.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/core/index.ts b/src/core/index.ts index 24b0d77..2c411bf 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -44,7 +44,7 @@ export interface Mota { plugin: AncTePlugin; game: { hook: EventEmitter; - storage: GameStorage[]; + storage: typeof GameStorage; }; ui: { main: UiController; @@ -62,7 +62,7 @@ function ready() { plugin: {}, game: { hook, - storage: GameStorage.list + storage: GameStorage }, ui: { main: mainUi, diff --git a/src/core/main/storage.ts b/src/core/main/storage.ts index 227191f..3be1650 100644 --- a/src/core/main/storage.ts +++ b/src/core/main/storage.ts @@ -55,9 +55,23 @@ export class GameStorage { return `HumanBreak_${key}`; } + /** + * 获取与作者相关联的存储键 + * @param author 作者名称 + * @param key 存储名称 + */ static fromAuthor(author: string, key: string) { return `${author}@${key}`; } + + /** + * 根据存储键获取对应的存储实例 + * @param key 存储键 + * @example Storage.get(Storage.fromAuthor('AncTe', 'setting')); + */ + static get(key: string) { + return this.list.find(v => v.key === key); + } } window.addEventListener('unload', () => {