优化提示

This commit is contained in:
IndieKKY
2024-10-05 09:53:58 +08:00
parent e025723d9f
commit a2655710e5
5 changed files with 35 additions and 8 deletions

View File

@@ -1,8 +1,23 @@
import {v4} from 'uuid'
import {handleTask, initTaskService, tasksMap} from './taskService'
import {MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ADD_TASK, MESSAGE_TO_EXTENSION_GET_TASK, MESSAGE_TO_INJECT_TOGGLE_DISPLAY} from '@/const'
import {MESSAGE_TARGET_INJECT, MESSAGE_TO_EXTENSION_ADD_TASK, MESSAGE_TO_EXTENSION_GET_TASK, MESSAGE_TO_EXTENSION_SHOW_FLAG, MESSAGE_TO_INJECT_TOGGLE_DISPLAY} from '@/const'
import ExtensionMessage from '@/messaging/ExtensionMessage'
const setBadgeOk = async (tabId: number, ok: boolean) => {
await chrome.action.setBadgeText({
text: ok ? '✓' : '',
tabId,
})
await chrome.action.setBadgeBackgroundColor({
color: '#3245e8',
tabId,
})
await chrome.action.setBadgeTextColor({
color: '#ffffff',
tabId,
})
}
const methods: {
[key: string]: (params: any, context: MethodContext) => Promise<any>
} = {
@@ -42,6 +57,9 @@ const methods: {
task,
}
},
[MESSAGE_TO_EXTENSION_SHOW_FLAG]: async (params, context) => {
await setBadgeOk(context.sender?.tab?.id!, params.show)
},
}
// 初始化backgroundMessage
const extensionMessage = new ExtensionMessage()