feat: add option to always pin the floating window (#199)

This commit is contained in:
josc146
2023-04-12 22:30:37 +08:00
parent a5a57a09a8
commit 43fde4b709
7 changed files with 27 additions and 10 deletions
+2 -1
View File
@@ -99,5 +99,6 @@
"Open Conversation Window": "Open Conversation Window",
"Store to Independent Conversation Page": "Store to Independent Conversation Page",
"Keep Conversation Window in Background": "Keep conversation window in background, so that you can use shortcut keys to call it up in any program",
"Max Response Token Length": "Max Response Token Length"
"Max Response Token Length": "Max Response Token Length",
"Always pin the floating window": "Always pin the floating window"
}
+2 -1
View File
@@ -99,5 +99,6 @@
"Open Conversation Window": "打开独立对话窗口",
"Store to Independent Conversation Page": "收纳到独立对话页",
"Keep Conversation Window in Background": "保持对话窗口在后台, 以便在任何程序中使用快捷键呼出",
"Max Response Token Length": "响应的最大token长度"
"Max Response Token Length": "响应的最大token长度",
"Always pin the floating window": "总是固定浮动窗口"
}
+2 -1
View File
@@ -99,5 +99,6 @@
"Open Conversation Window": "開啟獨立對話視窗",
"Store to Independent Conversation Page": "收納到獨立對話頁",
"Keep Conversation Window in Background": "保持對話窗口在後臺, 以便在任何程序中使用快捷鍵呼出",
"Max Response Token Length": "響應的最大token長度"
"Max Response Token Length": "響應的最大token長度",
"Always pin the floating window": "總是固定浮動視窗"
}
+8 -4
View File
@@ -61,6 +61,13 @@ function FloatingToolbar(props) {
updatePosition() // avoid jitter
}
const onDock = () => {
props.container.className = 'chatgptbox-toolbar-container-not-queryable'
setCloseable(true)
}
if (config.alwaysPinWindow) onDock()
return (
<div data-theme={config.themeMode}>
<Draggable
@@ -83,10 +90,7 @@ function FloatingToolbar(props) {
props.container.remove()
}}
dockable={props.dockable}
onDock={() => {
props.container.className = 'chatgptbox-toolbar-container-not-queryable'
setCloseable(true)
}}
onDock={onDock}
onUpdate={() => {
updatePosition()
}}
+1
View File
@@ -67,6 +67,7 @@ export const defaultConfig = {
insertAtTop: isMobile(),
lockWhenAnswer: false,
autoRegenAfterSwitchModel: false,
alwaysPinWindow: false,
apiKey: '', // openai ApiKey
+1 -3
View File
@@ -268,6 +268,7 @@ async function prepareForRightClickMenu() {
}
async function prepareForStaticCard() {
const userConfig = await getUserConfig()
let siteRegex
if (userConfig.useSiteRegexOnly) siteRegex = userConfig.siteRegex
else
@@ -296,10 +297,7 @@ async function prepareForStaticCard() {
}
}
let userConfig
async function run() {
userConfig = await getUserConfig()
await getPreferredLanguageKey().then((lang) => {
changeLanguage(lang)
})
+11
View File
@@ -297,6 +297,17 @@ function GeneralPart({ config, updateConfig }) {
/>
{t('Regenerate the answer after switching model')}
</label>
<label>
<input
type="checkbox"
checked={config.alwaysPinWindow}
onChange={(e) => {
const checked = e.target.checked
updateConfig({ alwaysPinWindow: checked })
}}
/>
{t('Always pin the floating window')}
</label>
<br />
</>
)