Files
RSSHub-Radar/src/lib/storage.ts
T
DIYgod ec2f091235 feat: migrate extension from Plasmo to WXT (#1172)
* feat: migrate extension framework to wxt

- Replace Plasmo entrypoints, messaging, and storage usage with WXT-compatible implementations

- Update workflows, build scripts, and locale paths for WXT outputs

- Switch store submission to wxt submit with optional dry-run input

* fix(ci): fallback to vars for submit credentials

- Resolve missing required config in submit workflow when values are stored in GitHub Variables instead of Secrets

- Keep existing secrets first and add vars fallback for Chrome, Firefox, and Edge credentials
2026-02-11 15:33:09 +08:00

31 lines
689 B
TypeScript

export function getLocalStorage<T = any>(key: string) {
return new Promise<T>((resolve, reject) => {
chrome.storage.local.get(key, (result) => {
if (chrome.runtime.lastError) {
reject(new Error(chrome.runtime.lastError.message))
return
}
resolve(result[key] as T)
})
})
}
export function setLocalStorage<T = any>(key: string, value: T) {
return new Promise<void>((resolve, reject) => {
chrome.storage.local.set(
{
[key]: value,
},
() => {
if (chrome.runtime.lastError) {
reject(new Error(chrome.runtime.lastError.message))
return
}
resolve()
},
)
})
}