feat(extension): 采集插件功能开发

This commit is contained in:
2026-09-06 22:32:39 +08:00
parent 87db74fb89
commit 4c0f3a4a79
35 changed files with 790 additions and 20 deletions
+8 -1
View File
@@ -1,3 +1,10 @@
import { getSession, login, openErp, submit } from '../lib/api.js';
export default defineBackground(() => {
console.info('Atlas collector background started.');
browser.runtime.onMessage.addListener(async (message: { type?: string; payload?: unknown; path?: string }) => {
if (message?.type === 'atlas.session') return { session: await getSession() };
if (message?.type === 'atlas.login') return { session: await login() };
if (message?.type === 'atlas.collect') return { result: await submit(message.payload as import('@atlas/contracts').CollectedProductPayload) };
if (message?.type === 'atlas.open') { await openErp(message.path); return { ok: true }; }
return undefined;
});
});