lefengyang
2026-08-20 d01a28cb030b2cb0ff1d42273c877a0f728519a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import {AutoCloseTabKey, IBgContentService, IBidTaskResult} from "/src-com";
import {StorageLocal} from "gs-br-ext";
 
export const commitBidBg: IBgContentService['commitBidBg'] = async (result: IBidTaskResult, sender?: chrome.runtime.MessageSender): Promise<boolean> => {
    console.log('出价任务回调:', result)
    try {
        const data = {...result, results: JSON.stringify(result.results)}
        const resp = await fetch('https://adminapi.wakuwaku.asia/api/task/callbackBid', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(data)
        }).then(r => r.json())
 
        const tabId = sender?.tab.id;
        console.log(tabId && !!(await StorageLocal.getValue(AutoCloseTabKey)), await StorageLocal.getValue(AutoCloseTabKey))
        if (tabId && !!(await StorageLocal.getValue(AutoCloseTabKey))) {
            await chrome.tabs.remove(tabId);
        }
 
        return resp;
    } catch (e: any) {
        console.error('回调失败:', e)
        return false
    }
}