mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-03-01 01:57:05 +08:00
feat: 根据存储键获取存储实例
This commit is contained in:
parent
5338a5d6de
commit
02e2934b9a
@ -44,7 +44,7 @@ export interface Mota {
|
|||||||
plugin: AncTePlugin;
|
plugin: AncTePlugin;
|
||||||
game: {
|
game: {
|
||||||
hook: EventEmitter<GameEvent>;
|
hook: EventEmitter<GameEvent>;
|
||||||
storage: GameStorage<any>[];
|
storage: typeof GameStorage;
|
||||||
};
|
};
|
||||||
ui: {
|
ui: {
|
||||||
main: UiController;
|
main: UiController;
|
||||||
@ -62,7 +62,7 @@ function ready() {
|
|||||||
plugin: {},
|
plugin: {},
|
||||||
game: {
|
game: {
|
||||||
hook,
|
hook,
|
||||||
storage: GameStorage.list
|
storage: GameStorage
|
||||||
},
|
},
|
||||||
ui: {
|
ui: {
|
||||||
main: mainUi,
|
main: mainUi,
|
||||||
|
@ -55,9 +55,23 @@ export class GameStorage<T> {
|
|||||||
return `HumanBreak_${key}`;
|
return `HumanBreak_${key}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取与作者相关联的存储键
|
||||||
|
* @param author 作者名称
|
||||||
|
* @param key 存储名称
|
||||||
|
*/
|
||||||
static fromAuthor(author: string, key: string) {
|
static fromAuthor(author: string, key: string) {
|
||||||
return `${author}@${key}`;
|
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', () => {
|
window.addEventListener('unload', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user