feat: 开发采集、采集箱和商品编辑功能

This commit is contained in:
Joey
2026-08-15 22:17:26 +08:00
parent c61d1a3154
commit 36357843d0
130 changed files with 18005 additions and 12 deletions
+23
View File
@@ -0,0 +1,23 @@
// Background Service Worker - 唯一出网口(绕 CORS 取图)
export default defineBackground(() => {
console.log('Seller Helper background started');
// 点击扩展图标 → 打开 Side Panel
chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: true });
// 代理图片 fetchCORS 绕过)
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
if (msg.action === 'fetchImage') {
fetchImageAsBlob(msg.url)
.then(blob => sendResponse({ ok: true, blob }))
.catch(err => sendResponse({ ok: false, error: err.message }));
return true; // 保持异步通道
}
});
});
async function fetchImageAsBlob(url: string): Promise<Blob> {
const res = await fetch(url);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.blob();
}