feat: add basic joox support

(cherry picked from commit 699333ca06526d747a7eb4a188e896de81e9f014)
This commit is contained in:
鲁树人
2021-12-19 23:03:46 +00:00
parent 9add76c060
commit 1e7116a3a9
13 changed files with 207 additions and 16 deletions

View 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 });
}
}