feat(extension): 采集插件功能开发
This commit is contained in:
@@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user