You've already forked bilibili-subtitle
优化提示
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user