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