feat(edit): 编辑上报细节优化
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
import { getSession, login, openErp, submit } from '../lib/api.js';
|
||||
import { backgroundError } from '../lib/request-errors.js';
|
||||
export default defineBackground(() => {
|
||||
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;
|
||||
try {
|
||||
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;
|
||||
} catch (error) {
|
||||
return backgroundError(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user