mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-23 12:50:47 +08:00
feat: activate existing conversation window by default (#222)
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
@@ -103,5 +103,6 @@
|
||||
"Max Response Token Length": "响应的最大token长度",
|
||||
"Max Conversation Length": "对话处理的最大长度",
|
||||
"Always pin the floating window": "总是固定浮动窗口",
|
||||
"Export": "导出"
|
||||
"Export": "导出",
|
||||
"Always Create New Conversation Window": "总是创建新的对话窗口"
|
||||
}
|
||||
|
||||
@@ -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": "總是創建新的對話視窗"
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ export const defaultConfig = {
|
||||
|
||||
// others
|
||||
|
||||
alwaysCreateNewConversationWindow: false,
|
||||
activeSelectionTools: ['translate', 'summary', 'polish', 'code', 'ask'],
|
||||
activeSiteAdapters: [
|
||||
'bilibili',
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
+35
-15
@@ -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')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
Browser.windows.create({
|
||||
url: Browser.runtime.getURL('IndependentPanel.html'),
|
||||
type: 'popup',
|
||||
width: 500,
|
||||
height: 650,
|
||||
})
|
||||
}}
|
||||
>
|
||||
{t('Open Conversation Window')}
|
||||
</button>
|
||||
{!isMobile() && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
Browser.windows.create({
|
||||
url: Browser.runtime.getURL('IndependentPanel.html'),
|
||||
type: 'popup',
|
||||
width: 500,
|
||||
height: 650,
|
||||
})
|
||||
}}
|
||||
>
|
||||
{t('Open Conversation Window')}
|
||||
</button>
|
||||
)}
|
||||
{!isMobile() && !isFirefox() && !isSafari() && (
|
||||
<label>
|
||||
<input
|
||||
@@ -402,10 +404,28 @@ function FeaturePages() {
|
||||
{t('Keep Conversation Window in Background')}
|
||||
</label>
|
||||
)}
|
||||
{!isMobile() && (
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={config.alwaysCreateNewConversationWindow}
|
||||
onChange={(e) => {
|
||||
const checked = e.target.checked
|
||||
updateConfig({ alwaysCreateNewConversationWindow: checked })
|
||||
}}
|
||||
/>
|
||||
{t('Always Create New Conversation Window')}
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
FeaturePages.propTypes = {
|
||||
config: PropTypes.object.isRequired,
|
||||
updateConfig: PropTypes.func.isRequired,
|
||||
}
|
||||
|
||||
function AdvancedPart({ config, updateConfig }) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
@@ -703,7 +723,7 @@ function Popup() {
|
||||
<GeneralPart config={config} updateConfig={updateConfig} />
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<FeaturePages />
|
||||
<FeaturePages config={config} updateConfig={updateConfig} />
|
||||
</TabPanel>
|
||||
<TabPanel>
|
||||
<SelectionTools config={config} updateConfig={updateConfig} />
|
||||
|
||||
Reference in New Issue
Block a user