This commit is contained in:
IndieKKY
2024-10-05 21:17:26 +08:00
parent 4f03e75b6d
commit c71e8e2eab
4 changed files with 11 additions and 4 deletions

View File

@@ -101,6 +101,9 @@ chrome.action.onClicked.addListener(async (tab) => {
tabId: tab.id!, tabId: tab.id!,
}) })
} else { } else {
chrome.sidePanel.setOptions({
enabled: false,
})
chrome.sidePanel.setPanelBehavior({ chrome.sidePanel.setPanelBehavior({
openPanelOnActionClick: false, openPanelOnActionClick: false,
}) })

View File

@@ -16,6 +16,7 @@ const Header = (props: {
const curInfo = useAppSelector(state => state.env.curInfo) const curInfo = useAppSelector(state => state.env.curInfo)
const fold = useAppSelector(state => state.env.fold) const fold = useAppSelector(state => state.env.fold)
const uploadedTranscript = useAppSelector(state => state.env.uploadedTranscript) const uploadedTranscript = useAppSelector(state => state.env.uploadedTranscript)
const envData = useAppSelector(state => state.env.envData)
const upload = useCallback(() => { const upload = useCallback(() => {
const input = document.createElement('input') const input = document.createElement('input')
@@ -76,7 +77,11 @@ const Header = (props: {
upload() upload()
}, [upload]) }, [upload])
return <div className='rounded-[6px] bg-[#f1f2f3] dark:bg-base-100 h-[44px] flex justify-between items-center cursor-pointer' onClick={foldCallback}> return <div className='rounded-[6px] bg-[#f1f2f3] dark:bg-base-100 h-[44px] flex justify-between items-center cursor-pointer' onClick={() => {
if (!envData.sidePanel) {
foldCallback()
}
}}>
<div className='shrink-0 flex items-center'> <div className='shrink-0 flex items-center'>
<span className='shrink-0 text-[15px] font-medium pl-[16px] pr-[14px]'></span> <span className='shrink-0 text-[15px] font-medium pl-[16px] pr-[14px]'></span>
<MoreBtn placement={'right-start'}/> <MoreBtn placement={'right-start'}/>
@@ -91,7 +96,7 @@ const Header = (props: {
{infos?.map((item: any) => <option key={item.id} value={item.subtitle_url}>{item.lan_doc}</option>)} {infos?.map((item: any) => <option key={item.id} value={item.subtitle_url}>{item.lan_doc}</option>)}
<option key='upload' value='upload'>(vtt/srt)</option> <option key='upload' value='upload'>(vtt/srt)</option>
</select>} </select>}
<IoIosArrowUp className={classNames('shrink-0 desc transform ease-in duration-300', fold?'rotate-180':'')}/> {!envData.sidePanel && <IoIosArrowUp className={classNames('shrink-0 desc transform ease-in duration-300', fold?'rotate-180':'')}/>}
</div> </div>
</div> </div>
} }

View File

@@ -113,7 +113,6 @@ class ExtensionMessage {
} }
broadcastMessageExact = async (tabIds: number[], target: string, method: string, params?: any) => { broadcastMessageExact = async (tabIds: number[], target: string, method: string, params?: any) => {
//遍历portIdToPort
const targetType = target === MESSAGE_TARGET_INJECT ? 'inject' : 'app' const targetType = target === MESSAGE_TARGET_INJECT ? 'inject' : 'app'
let resp: MessageResult | undefined let resp: MessageResult | undefined
for (const portContext of this.portIdToPort.values()) { for (const portContext of this.portIdToPort.values()) {

View File

@@ -22,7 +22,7 @@ function App() {
const foldCallback = useCallback(() => { const foldCallback = useCallback(() => {
dispatch(setFold(!fold)) dispatch(setFold(!fold))
sendInject(MESSAGE_TO_INJECT_FOLD, {fold: !fold}) sendInject(MESSAGE_TO_INJECT_FOLD, {fold: !fold})
}, [dispatch, fold]) }, [dispatch, fold, sendInject])
// handle event // handle event
eventBus.useSubscription((event: any) => { eventBus.useSubscription((event: any) => {