fix消息通信

This commit is contained in:
IndieKKY
2025-02-24 09:13:25 +08:00
parent 5bcedf0c9d
commit ae60303a15
25 changed files with 140 additions and 135 deletions

View File

@@ -1,14 +1,14 @@
import React from 'react';
import { useAppSelector } from '../hooks/redux';
import { openOptionsPage } from '../utils/chromeUtils';
import React from 'react'
import { useAppSelector } from '../hooks/redux'
import { openOptionsPage } from '../utils/chromeUtils'
const ApiKeyReminder: React.FC = () => {
const apiKey = useAppSelector(state => state.env.envData.apiKey);
const geminiApiKey = useAppSelector(state => state.env.envData.geminiApiKey);
const aiType = useAppSelector(state => state.env.envData.aiType);
const apiKey = useAppSelector(state => state.env.envData.apiKey)
const geminiApiKey = useAppSelector(state => state.env.envData.geminiApiKey)
const aiType = useAppSelector(state => state.env.envData.aiType)
if ((aiType === 'gemini' && geminiApiKey) || (aiType !== 'gemini' && apiKey)) {
return null;
return null
}
return (
@@ -21,7 +21,7 @@ const ApiKeyReminder: React.FC = () => {
</button>
</div>
);
};
)
}
export default ApiKeyReminder;
export default ApiKeyReminder

View File

@@ -127,7 +127,7 @@ const Body = () => {
}
toast.success(`已添加${segments_.length}个总结任务!`)
}
}, [addSummarizeTask, curSummaryType, dispatch, envData.aiType, envData.apiKey, envData.geminiApiKey, segments])
}, [addSummarizeTask, curSummaryType, envData.aiType, envData.apiKey, envData.geminiApiKey, segments])
const onFoldAll = useCallback(() => {
dispatch(setFoldAll(!foldAll))

View File

@@ -1,8 +1,8 @@
import { useAppSelector } from '@/hooks/redux';
import React from 'react';
import { useAppSelector } from '@/hooks/redux'
import React from 'react'
const DebateChat: React.FC<DebateProps> = ({ messages }) => {
const fontSize = useAppSelector(state => state.env.envData.fontSize)
const fontSize = useAppSelector(state => state.env.envData.fontSize)
return (
<div className="flex flex-col h-full">
@@ -37,7 +37,7 @@ const DebateChat: React.FC<DebateProps> = ({ messages }) => {
))}
</div>
</div>
);
};
)
}
export default DebateChat;
export default DebateChat

View File

@@ -11,12 +11,12 @@ import {Placement} from '@popperjs/core/lib/enums'
import {useAppDispatch, useAppSelector} from '../hooks/redux'
import {setEnvData, setTempData} from '../redux/envReducer'
import {EventBusContext} from '../Router'
import {DEFAULT_USE_PORT, EVENT_EXPAND} from '../consts/const'
import {EVENT_EXPAND} from '../consts/const'
import {formatSrtTime, formatTime, formatVttTime} from '../utils/util'
import {downloadText, openUrl} from '@kky002/kky-util'
import toast from 'react-hot-toast'
import {getSummarize} from '../utils/bizUtil'
import dayjs from 'dayjs';
import dayjs from 'dayjs'
import { useMessage } from '@/hooks/useMessageService'
interface Props {
@@ -68,7 +68,7 @@ const MoreBtn = (props: Props) => {
const segments = useAppSelector(state => state.env.segments)
const url = useAppSelector(state => state.env.url)
const title = useAppSelector(state => state.env.title)
const ctime = useAppSelector(state => state.env.ctime) //时间戳单位s
const ctime = useAppSelector(state => state.env.ctime) // 时间戳单位s
const author = useAppSelector(state => state.env.author)
const curSummaryType = useAppSelector(state => state.env.tempData.curSummaryType)
@@ -81,7 +81,7 @@ const MoreBtn = (props: Props) => {
let fileName = title
let s, suffix
let time = ctime ? dayjs(ctime * 1000).format('YYYY-MM-DD HH:mm:ss') : '' // 2024-05-01 12:00:00
const time = ctime ? dayjs(ctime * 1000).format('YYYY-MM-DD HH:mm:ss') : '' // 2024-05-01 12:00:00
if (!downloadType || downloadType === 'text') {
s = `${title??'无标题'}\n${url??'无链接'}\n${author??'无作者'} ${time}\n\n`
for (const item of data.body) {
@@ -162,11 +162,11 @@ const MoreBtn = (props: Props) => {
}).catch(console.error)
}
setMoreVisible(false)
}, [curSummaryType, data, downloadType, segments, title, url])
}, [author, ctime, curSummaryType, data, downloadType, segments, title, url])
const downloadAudioCallback = useCallback(() => {
sendInject(null, 'DOWNLOAD_AUDIO', {})
}, [])
}, [sendInject])
const selectCallback = useCallback((e: any) => {
dispatch(setTempData({

View File

@@ -1,14 +1,14 @@
import React, { useState } from 'react';
import { FaStar } from 'react-icons/fa';
import { IoMdClose } from 'react-icons/io';
import { setTempData } from '../redux/envReducer';
import { useAppDispatch, useAppSelector } from '../hooks/redux';
import { openUrl } from '@kky002/kky-util';
import { isEdgeBrowser } from '../utils/util';
import React, { useState } from 'react'
import { FaStar } from 'react-icons/fa'
import { IoMdClose } from 'react-icons/io'
import { setTempData } from '../redux/envReducer'
import { useAppDispatch, useAppSelector } from '../hooks/redux'
import { openUrl } from '@kky002/kky-util'
import { isEdgeBrowser } from '../utils/util'
const RateExtension: React.FC = () => {
const dispatch = useAppDispatch()
const [isHovered, setIsHovered] = useState(false);
const [isHovered, setIsHovered] = useState(false)
const reviewed = useAppSelector(state => state.env.tempData.reviewed)
const handleRateClick = () => {
@@ -21,9 +21,9 @@ const RateExtension: React.FC = () => {
} else {
openUrl('https://chromewebstore.google.com/webstore/detail/bciglihaegkdhoogebcdblfhppoilclp/reviews')
}
};
}
if (reviewed === true || reviewed === undefined) return null;
if (reviewed === true || reviewed === undefined) return null
return (
<div className="relative bg-gradient-to-r from-primary to-secondary text-primary-content p-4 rounded-lg shadow-lg text-sm transition-all duration-300 ease-in-out hover:shadow-xl">
@@ -52,7 +52,7 @@ const RateExtension: React.FC = () => {
</span>
</button>
</div>
);
};
)
}
export default RateExtension;
export default RateExtension