style: update api key input field formatting and validation
This commit is contained in:
parent
f5d37a4e53
commit
a4d1bcffd9
@ -138,7 +138,6 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
|
|||||||
// shortcuts
|
// shortcuts
|
||||||
ipcMain.handle('shortcuts:update', (_, shortcuts: Shortcut[]) => {
|
ipcMain.handle('shortcuts:update', (_, shortcuts: Shortcut[]) => {
|
||||||
configManager.setShortcuts(shortcuts)
|
configManager.setShortcuts(shortcuts)
|
||||||
log.info('[ipc] shortcuts updated', shortcuts)
|
|
||||||
// Refresh shortcuts registration
|
// Refresh shortcuts registration
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
unregisterAllShortcuts()
|
unregisterAllShortcuts()
|
||||||
|
|||||||
@ -55,7 +55,7 @@ export function registerShortcuts(window: BrowserWindow) {
|
|||||||
if (!shortcuts) return
|
if (!shortcuts) return
|
||||||
|
|
||||||
shortcuts.forEach((shortcut) => {
|
shortcuts.forEach((shortcut) => {
|
||||||
if (!shortcut.enabled || shortcut.shortcut.length === 0) {
|
if (shortcut.shortcut.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,20 +74,22 @@ export function registerShortcuts(window: BrowserWindow) {
|
|||||||
if (shortcut.key.includes('zoom')) {
|
if (shortcut.key.includes('zoom')) {
|
||||||
switch (shortcut.key) {
|
switch (shortcut.key) {
|
||||||
case 'zoom_in':
|
case 'zoom_in':
|
||||||
globalShortcut.register('CommandOrControl+=', () => handler(window))
|
globalShortcut.register('CommandOrControl+=', () => shortcut.enabled && handler(window))
|
||||||
globalShortcut.register('CommandOrControl+numadd', () => handler(window))
|
globalShortcut.register('CommandOrControl+numadd', () => shortcut.enabled && handler(window))
|
||||||
return
|
return
|
||||||
case 'zoom_out':
|
case 'zoom_out':
|
||||||
globalShortcut.register('CommandOrControl+-', () => handler(window))
|
globalShortcut.register('CommandOrControl+-', () => shortcut.enabled && handler(window))
|
||||||
globalShortcut.register('CommandOrControl+numsub', () => handler(window))
|
globalShortcut.register('CommandOrControl+numsub', () => shortcut.enabled && handler(window))
|
||||||
return
|
return
|
||||||
case 'zoom_reset':
|
case 'zoom_reset':
|
||||||
globalShortcut.register('CommandOrControl+0', () => handler(window))
|
globalShortcut.register('CommandOrControl+0', () => shortcut.enabled && handler(window))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
globalShortcut.register(accelerator, () => handler(window))
|
if (shortcut.enabled) {
|
||||||
|
globalShortcut.register(accelerator, () => handler(window))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -169,6 +169,10 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const formatApiKeys = (value: string) => {
|
||||||
|
return value.replaceAll(',', ',').replaceAll(' ', ',').replaceAll(' ', '').replaceAll('\n', ',')
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingContainer theme={theme}>
|
<SettingContainer theme={theme}>
|
||||||
<SettingTitle>
|
<SettingTitle>
|
||||||
@ -192,7 +196,7 @@ const ProviderSetting: FC<Props> = ({ provider: _provider }) => {
|
|||||||
<Input.Password
|
<Input.Password
|
||||||
value={apiKey}
|
value={apiKey}
|
||||||
placeholder={t('settings.provider.api_key')}
|
placeholder={t('settings.provider.api_key')}
|
||||||
onChange={(e) => setApiKey(e.target.value.replaceAll(',', ',').replaceAll(' ', ''))}
|
onChange={(e) => setApiKey(formatApiKeys(e.target.value))}
|
||||||
onBlur={onUpdateApiKey}
|
onBlur={onUpdateApiKey}
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
type="password"
|
type="password"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user