feat: add basic joox support
This commit is contained in:
21
src/utils/storage/ChromeExtensionStorage.ts
Normal file
21
src/utils/storage/ChromeExtensionStorage.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import BaseStorage from './BaseStorage';
|
||||
|
||||
declare var chrome: any;
|
||||
|
||||
export default class ChromeExtensionStorage extends BaseStorage {
|
||||
static get works(): boolean {
|
||||
return Boolean(chrome?.storage?.local?.set);
|
||||
}
|
||||
|
||||
protected async load<T>(name: string, defaultValue: T): Promise<T> {
|
||||
const result = await chrome.storage.local.get({ [name]: defaultValue });
|
||||
if (Object.prototype.hasOwnProperty.call(result, name)) {
|
||||
return result[name];
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
protected async save<T>(name: string, value: T): Promise<void> {
|
||||
return chrome.storage.local.set({ [name]: value });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user