更换使用wxt框架搭建testing tool

This commit is contained in:
雨霖铃
2026-01-27 23:09:57 +08:00
parent 9c84b7adc0
commit b33194bd2d
54 changed files with 4146 additions and 16436 deletions
+30
View File
@@ -0,0 +1,30 @@
// 判断当前是否处于 Chrome 插件环境
const isExtension = typeof chrome !== 'undefined' && chrome.storage && chrome.storage.local;
const storageAdapter = {
// 获取数据
get: async (key) => {
if (isExtension) {
const result = await chrome.storage.local.get([key]);
return result[key];
} else {
const item = localStorage.getItem(key);
try {
return JSON.parse(item); // 保持与插件版一致的对象处理
} catch {
return item;
}
}
},
// 设置数据
set: async (key, value) => {
if (isExtension) {
await chrome.storage.local.set({[key]: value});
} else {
localStorage.setItem(key, JSON.stringify(value));
}
}
};
export default storageAdapter;