diff --git a/src/_locales/en/main.json b/src/_locales/en/main.json index 1c15b63..ddefd43 100644 --- a/src/_locales/en/main.json +++ b/src/_locales/en/main.json @@ -103,5 +103,6 @@ "Max Response Token Length": "Max Response Token Length", "Max Conversation Length": "Max Conversation Length", "Always pin the floating window": "Always pin the floating window", - "Export": "Export" + "Export": "Export", + "Always Create New Conversation Window": "Always Create New Conversation Window" } diff --git a/src/_locales/zh-hans/main.json b/src/_locales/zh-hans/main.json index 5783f73..1429560 100644 --- a/src/_locales/zh-hans/main.json +++ b/src/_locales/zh-hans/main.json @@ -103,5 +103,6 @@ "Max Response Token Length": "响应的最大token长度", "Max Conversation Length": "对话处理的最大长度", "Always pin the floating window": "总是固定浮动窗口", - "Export": "导出" + "Export": "导出", + "Always Create New Conversation Window": "总是创建新的对话窗口" } diff --git a/src/_locales/zh-hant/main.json b/src/_locales/zh-hant/main.json index ef9421a..e16e10c 100644 --- a/src/_locales/zh-hant/main.json +++ b/src/_locales/zh-hant/main.json @@ -99,9 +99,10 @@ "Open Conversation Page": "開啟獨立對話頁", "Open Conversation Window": "開啟獨立對話視窗", "Store to Independent Conversation Page": "收納到獨立對話頁", - "Keep Conversation Window in Background": "保持對話窗口在後臺, 以便在任何程序中使用快捷鍵呼出", + "Keep Conversation Window in Background": "保持對話視窗在後臺, 以便在任何程序中使用快捷鍵呼出", "Max Response Token Length": "響應的最大token長度", "Max Conversation Length": "對話處理的最大長度", "Always pin the floating window": "總是固定浮動視窗", - "Export": "導出" + "Export": "導出", + "Always Create New Conversation Window": "總是創建新的對話視窗" } diff --git a/src/config/index.mjs b/src/config/index.mjs index 18eadb8..4dbf384 100644 --- a/src/config/index.mjs +++ b/src/config/index.mjs @@ -116,6 +116,7 @@ export const defaultConfig = { // others + alwaysCreateNewConversationWindow: false, activeSelectionTools: ['translate', 'summary', 'polish', 'code', 'ask'], activeSiteAdapters: [ 'bilibili', diff --git a/src/content-script/menu-tools/index.mjs b/src/content-script/menu-tools/index.mjs index 15bb84b..4bd9be0 100644 --- a/src/content-script/menu-tools/index.mjs +++ b/src/content-script/menu-tools/index.mjs @@ -1,6 +1,7 @@ import { getCoreContentText } from '../../utils/get-core-content-text' import { openUrl } from '../../utils/open-url' import Browser from 'webextension-polyfill' +import { getUserConfig } from '../../config/index.mjs' export const config = { newChat: { @@ -24,12 +25,18 @@ export const config = { openConversationWindow: { label: 'Open Conversation Window', action: async () => { - Browser.windows.create({ - url: Browser.runtime.getURL('IndependentPanel.html'), - type: 'popup', - width: 500, - height: 650, - }) + const config = await getUserConfig() + const url = Browser.runtime.getURL('IndependentPanel.html') + const tabs = await Browser.tabs.query({ url: url, windowType: 'popup' }) + if (!config.alwaysCreateNewConversationWindow && tabs.length > 0) + await Browser.windows.update(tabs[0].windowId, { focused: true }) + else + await Browser.windows.create({ + url: url, + type: 'popup', + width: 500, + height: 650, + }) }, }, } diff --git a/src/popup/Popup.jsx b/src/popup/Popup.jsx index eee368f..b8acceb 100644 --- a/src/popup/Popup.jsx +++ b/src/popup/Popup.jsx @@ -339,7 +339,7 @@ GeneralPart.propTypes = { updateConfig: PropTypes.func.isRequired, } -function FeaturePages() { +function FeaturePages({ config, updateConfig }) { const { t } = useTranslation() const [backgroundPermission, setBackgroundPermission] = useState(false) @@ -369,19 +369,21 @@ function FeaturePages() { > {t('Open Conversation Page')} - + {!isMobile() && ( + + )} {!isMobile() && !isFirefox() && !isSafari() && (