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', () => {