feat: 根据存储键获取存储实例

This commit is contained in:
unanmed 2023-09-29 17:48:05 +08:00
parent 5338a5d6de
commit 02e2934b9a
2 changed files with 16 additions and 2 deletions

View File

@ -44,7 +44,7 @@ export interface Mota {
plugin: AncTePlugin;
game: {
hook: EventEmitter<GameEvent>;
storage: GameStorage<any>[];
storage: typeof GameStorage;
};
ui: {
main: UiController;
@ -62,7 +62,7 @@ function ready() {
plugin: {},
game: {
hook,
storage: GameStorage.list
storage: GameStorage
},
ui: {
main: mainUi,

View File

@ -55,9 +55,23 @@ export class GameStorage<T> {
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', () => {