From a02825b3eb3a6562f5e2e0a1449463cd5f6aea5f Mon Sep 17 00:00:00 2001 From: IndieKKY Date: Fri, 4 Oct 2024 19:47:22 +0800 Subject: [PATCH] fix --- src/biz/Ask.tsx | 7 +++---- src/biz/Body.tsx | 9 +++------ src/biz/MoreBtn.tsx | 2 +- src/biz/SegmentCard.tsx | 5 ++--- src/pages/OptionsPage.tsx | 2 +- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/biz/Ask.tsx b/src/biz/Ask.tsx index 21f27e4..425d8e8 100644 --- a/src/biz/Ask.tsx +++ b/src/biz/Ask.tsx @@ -2,7 +2,7 @@ import {AiOutlineCloseCircle, BsDashSquare, BsPlusSquare, FaQuestion} from 'reac import classNames from 'classnames' import Markdown from '../components/Markdown' 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 toast from 'react-hot-toast' import useTranslate from '../hooks/useTranslate' @@ -24,10 +24,9 @@ const Ask = (props: { addAskTask(ask.id, segments[0], ask.question).catch(console.error) } } 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(() => { dispatch(mergeAskInfo({ diff --git a/src/biz/Body.tsx b/src/biz/Body.tsx index 5e168ba..b1208e8 100644 --- a/src/biz/Body.tsx +++ b/src/biz/Body.tsx @@ -103,8 +103,7 @@ const Body = () => { const onSummarizeAll = useCallback(() => { const apiKey = envData.aiType === 'gemini'?envData.geminiApiKey:envData.apiKey if (!apiKey) { - chrome.runtime.openOptionsPage() - toast.error('需要先设置ApiKey!') + toast.error('请先在选项页面设置ApiKey!') return } const segments_ = [] @@ -147,8 +146,7 @@ const Body = () => { if (apiKey) { dispatch(setAutoTranslate(!autoTranslate)) } else { - chrome.runtime.openOptionsPage() - toast.error('需要先设置ApiKey!') + toast.error('请先在选项页面设置ApiKey!') } }, [autoTranslate, dispatch, envData.aiType, envData.apiKey, envData.geminiApiKey]) @@ -196,8 +194,7 @@ const Body = () => { })) } } else { - chrome.runtime.openOptionsPage() - toast.error('需要先设置ApiKey!') + toast.error('请先在选项页面设置ApiKey!') } } }, [addAskTask, dispatch, envData.aiType, envData.apiKey, envData.askEnabled, envData.geminiApiKey, searchText, segments]) diff --git a/src/biz/MoreBtn.tsx b/src/biz/MoreBtn.tsx index 885cba5..04751dd 100644 --- a/src/biz/MoreBtn.tsx +++ b/src/biz/MoreBtn.tsx @@ -294,7 +294,7 @@ const MoreBtn = (props: Props) => { e.stopPropagation() }}> - 设置 + 选项 diff --git a/src/biz/SegmentCard.tsx b/src/biz/SegmentCard.tsx index 7cce6df..65edf1a 100644 --- a/src/biz/SegmentCard.tsx +++ b/src/biz/SegmentCard.tsx @@ -76,10 +76,9 @@ const Summarize = (props: { if (apiKey) { addSummarizeTask(curSummaryType, segment).catch(console.error) } 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(() => { if (summary != null) { diff --git a/src/pages/OptionsPage.tsx b/src/pages/OptionsPage.tsx index 18328cb..14f8c09 100644 --- a/src/pages/OptionsPage.tsx +++ b/src/pages/OptionsPage.tsx @@ -1,5 +1,5 @@ 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 { ASK_ENABLED_DEFAULT,