mirror of
https://github.com/DIYgod/RSSHub-Radar.git
synced 2026-09-01 14:51:13 +08:00
ec2f091235
* 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
31 lines
689 B
TypeScript
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()
|
|
},
|
|
)
|
|
})
|
|
}
|