This commit is contained in:
IndieKKY
2024-10-04 19:47:22 +08:00
parent cf737b9976
commit a02825b3eb
5 changed files with 10 additions and 15 deletions

View File

@@ -2,7 +2,7 @@ import {AiOutlineCloseCircle, BsDashSquare, BsPlusSquare, FaQuestion} from 'reac
import classNames from 'classnames' import classNames from 'classnames'
import Markdown from '../components/Markdown' import Markdown from '../components/Markdown'
import React, {useCallback} from 'react' import React, {useCallback} from 'react'
import {delAskInfo, mergeAskInfo} from '../redux/envReducer' import {delAskInfo, mergeAskInfo, setTempData} from '../redux/envReducer'
import {useAppDispatch, useAppSelector} from '../hooks/redux' import {useAppDispatch, useAppSelector} from '../hooks/redux'
import toast from 'react-hot-toast' import toast from 'react-hot-toast'
import useTranslate from '../hooks/useTranslate' import useTranslate from '../hooks/useTranslate'
@@ -24,10 +24,9 @@ const Ask = (props: {
addAskTask(ask.id, segments[0], ask.question).catch(console.error) addAskTask(ask.id, segments[0], ask.question).catch(console.error)
} }
} else { } else {
chrome.runtime.openOptionsPage() toast.error('请先在选项页面设置ApiKey!')
toast.error('需要先设置ApiKey!')
} }
}, [addAskTask, ask.id, ask.question, dispatch, envData.aiType, envData.apiKey, envData.geminiApiKey, segments]) }, [addAskTask, ask.id, ask.question, envData.aiType, envData.apiKey, envData.geminiApiKey, segments])
const onAskFold = useCallback(() => { const onAskFold = useCallback(() => {
dispatch(mergeAskInfo({ dispatch(mergeAskInfo({

View File

@@ -103,8 +103,7 @@ const Body = () => {
const onSummarizeAll = useCallback(() => { const onSummarizeAll = useCallback(() => {
const apiKey = envData.aiType === 'gemini'?envData.geminiApiKey:envData.apiKey const apiKey = envData.aiType === 'gemini'?envData.geminiApiKey:envData.apiKey
if (!apiKey) { if (!apiKey) {
chrome.runtime.openOptionsPage() toast.error('请先在选项页面设置ApiKey!')
toast.error('需要先设置ApiKey!')
return return
} }
const segments_ = [] const segments_ = []
@@ -147,8 +146,7 @@ const Body = () => {
if (apiKey) { if (apiKey) {
dispatch(setAutoTranslate(!autoTranslate)) dispatch(setAutoTranslate(!autoTranslate))
} else { } else {
chrome.runtime.openOptionsPage() toast.error('请先在选项页面设置ApiKey!')
toast.error('需要先设置ApiKey!')
} }
}, [autoTranslate, dispatch, envData.aiType, envData.apiKey, envData.geminiApiKey]) }, [autoTranslate, dispatch, envData.aiType, envData.apiKey, envData.geminiApiKey])
@@ -196,8 +194,7 @@ const Body = () => {
})) }))
} }
} else { } else {
chrome.runtime.openOptionsPage() toast.error('请先在选项页面设置ApiKey!')
toast.error('需要先设置ApiKey!')
} }
} }
}, [addAskTask, dispatch, envData.aiType, envData.apiKey, envData.askEnabled, envData.geminiApiKey, searchText, segments]) }, [addAskTask, dispatch, envData.aiType, envData.apiKey, envData.askEnabled, envData.geminiApiKey, searchText, segments])

View File

@@ -294,7 +294,7 @@ const MoreBtn = (props: Props) => {
e.stopPropagation() e.stopPropagation()
}}> }}>
<IoMdSettings className='w-[20px] h-[20px] text-primary/75 bg-white rounded-sm p-0.5'/> <IoMdSettings className='w-[20px] h-[20px] text-primary/75 bg-white rounded-sm p-0.5'/>
</a> </a>
</li> </li>
</ul> </ul>

View File

@@ -76,10 +76,9 @@ const Summarize = (props: {
if (apiKey) { if (apiKey) {
addSummarizeTask(curSummaryType, segment).catch(console.error) addSummarizeTask(curSummaryType, segment).catch(console.error)
} else { } else {
chrome.runtime.openOptionsPage() toast.error('请先在选项页面设置ApiKey!')
toast.error('需要先设置ApiKey!')
} }
}, [addSummarizeTask, curSummaryType, dispatch, envData.aiType, envData.apiKey, envData.geminiApiKey, segment]) }, [addSummarizeTask, curSummaryType, envData.aiType, envData.apiKey, envData.geminiApiKey, segment])
const onCopy = useCallback(() => { const onCopy = useCallback(() => {
if (summary != null) { if (summary != null) {

View File

@@ -1,5 +1,5 @@
import React, {PropsWithChildren, useCallback, useEffect, useMemo, useState} from 'react' import React, {PropsWithChildren, useCallback, useEffect, useMemo, useState} from 'react'
import {setEnvData} from '../redux/envReducer' import {setEnvData, setTempData} from '../redux/envReducer'
import {useAppDispatch, useAppSelector} from '../hooks/redux' import {useAppDispatch, useAppSelector} from '../hooks/redux'
import { import {
ASK_ENABLED_DEFAULT, ASK_ENABLED_DEFAULT,