1
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
||||
import type { CrawlTaskState } from '@/types';
|
||||
import {computed, onMounted, onUnmounted, ref} from 'vue';
|
||||
import type {CrawlTaskState} from '@/types';
|
||||
|
||||
/** 当前后台保存的爬取任务快照,用于决定是否展示右下角浮窗。 */
|
||||
const crawlState = ref<CrawlTaskState | null>(null);
|
||||
@@ -33,7 +33,7 @@ onUnmounted(() => {
|
||||
/** 从 background 获取最新爬取任务状态,并在任务结束时自动收起面板。 */
|
||||
async function refreshCrawlState() {
|
||||
/** background 返回的当前爬取任务状态响应。 */
|
||||
const response = await sendBackgroundMessage<CrawlTaskState | null>({ action: 'GET_CRAWL_STATE' });
|
||||
const response = await sendBackgroundMessage<CrawlTaskState | null>({action: 'GET_CRAWL_STATE'});
|
||||
|
||||
if (response.ok) {
|
||||
crawlState.value = response.data ?? null;
|
||||
@@ -80,7 +80,7 @@ function getStepText(status: string): string {
|
||||
/** 发送消息到 background;非扩展环境下返回空成功响应,方便本地页面不报错。 */
|
||||
function sendBackgroundMessage<T>(message: unknown): Promise<{ ok: boolean; data?: T; error?: string }> {
|
||||
if (typeof chrome === 'undefined' || !chrome.runtime?.sendMessage) {
|
||||
return Promise.resolve({ ok: true, data: null as T });
|
||||
return Promise.resolve({ok: true, data: null as T});
|
||||
}
|
||||
|
||||
return chrome.runtime.sendMessage(message);
|
||||
|
||||
Reference in New Issue
Block a user