diff --git a/src/components/common/test.tsx b/src/components/common/test.tsx index 667349e17506a93d933a4b8a0f5a4e55faca69f5..ae0806c4940c89ba173402855245c317eb636b69 100644 --- a/src/components/common/test.tsx +++ b/src/components/common/test.tsx @@ -79,6 +79,18 @@ type RKey = { tt: Date } +/** 文本类输入中不打断按键测试;type=range 不拦截(与 AP 页 Slider.mouseOnlyRail 松手 blur 配合) */ +function shouldIgnoreKeyTestEvent(evt: KeyboardEvent): boolean { + const el = evt.target as HTMLElement | null + if (!el) return false + if (el.isContentEditable) return true + if (el.tagName === 'TEXTAREA') return true + if (el.tagName === 'INPUT') { + return (el as HTMLInputElement).type.toLowerCase() !== 'range' + } + return false +} + export const Test = () => { const timer2 = useRef>() @@ -89,11 +101,7 @@ export const Test = () => { const [releasedKeys, setReleasedKeys] = useState([]) const downHandler = (evt: KeyboardEvent) => { - const isInputFocused = - (evt.target as HTMLElement).tagName === 'INPUT' || - (evt.target as HTMLElement).tagName === 'TEXTAREA' || - (evt.target as HTMLElement).isContentEditable - if (isInputFocused) return + if (shouldIgnoreKeyTestEvent(evt)) return if (evt.key !== 'F12') { evt.preventDefault() } @@ -114,11 +122,7 @@ export const Test = () => { } const upHandler = (evt: KeyboardEvent) => { - const isInputFocused = - (evt.target as HTMLElement).tagName === 'INPUT' || - (evt.target as HTMLElement).tagName === 'TEXTAREA' || - (evt.target as HTMLElement).isContentEditable - if (isInputFocused) return + if (shouldIgnoreKeyTestEvent(evt)) return if (evt.key !== 'F12') { evt.preventDefault() } @@ -179,7 +183,7 @@ export const Test = () => { window.removeEventListener('keyup', upHandler) window.removeEventListener('blur', blurHandler) - clearInterval(timer2.current) + clearTimeout(timer2.current) pressedKeysRef.current = [] setPressedKeys([]) } @@ -189,13 +193,13 @@ export const Test = () => { {t('Key Test')} - {releasedKeys.map((k, i) => ( - + {releasedKeys.map(k => ( + {k.k} ))} - {pressedKeys.map((k, i) => ( - + {pressedKeys.map(k => ( + {k.k} ))} diff --git a/src/components/configure/adv-key/common/aprt.tsx b/src/components/configure/adv-key/common/aprt.tsx index 7b22d6f7f90c31b70262bcd0d9702ae9914ab38c..94537522e0eaffdabd5c3d720dd499499767f5fb 100644 --- a/src/components/configure/adv-key/common/aprt.tsx +++ b/src/components/configure/adv-key/common/aprt.tsx @@ -1,4 +1,4 @@ -import {useMemo, useState, useEffect} from 'react' +import {useMemo, useState, useEffect, useRef} from 'react' import {useTranslation} from 'react-i18next' import {Slider} from 'src/components/form/slider' import { @@ -14,7 +14,7 @@ import { } from 'src/store/actuationSlice' import {useAppDispatch, useAppSelector} from 'src/store/hook' import {getSelectedKeys} from 'src/store/keymapSlice' -import {APData, RTData} from 'src/types/types' +import {AK, APData, RTData} from 'src/types/types' import styled from 'styled-components' import {Switch} from 'src/components/form/switch' import {getSelectedAdvKey} from 'src/store/advkeySlice' @@ -136,6 +136,21 @@ const AP = () => { dispatch(updatePerKeyActuation(selectedKeys, data)) } + const rsSocdApSig = useRef('') + useEffect(() => { + const t = advKey?.type + if (t !== AK.RS && t !== AK.SOCD) { + rsSocdApSig.current = '' + return + } + if (!selectedKeys?.length) return + const sig = `${t}-${selectedKeys.join(',')}` + if (rsSocdApSig.current === sig) return + rsSocdApSig.current = sig + setAPData(ap) + dispatch(updatePerKeyActuation(selectedKeys, ap)) + }, [advKey?.type, selectedKeys, ap, dispatch]) + useEffect(() => { setAPData(ap) }, [selectedKeys, actuationMap]) @@ -206,6 +221,21 @@ export const RT = () => { dispatch(updatePerKeyRT(selectedKeys, rtData)) } + const rsSocdRtSig = useRef('') + useEffect(() => { + const t = advKey?.type + if (t !== AK.RS && t !== AK.SOCD) { + rsSocdRtSig.current = '' + return + } + if (!selectedKeys?.length) return + const sig = `${t}-${selectedKeys.join(',')}` + if (rsSocdRtSig.current === sig) return + rsSocdRtSig.current = sig + setRTData(rt) + dispatch(updatePerKeyRT(selectedKeys, rt)) + }, [advKey?.type, selectedKeys, rt, dispatch]) + useEffect(() => { setRTData(rt) }, [selectedKeys, actuationMap]) diff --git a/src/components/configure/calibration/calibration.tsx b/src/components/configure/calibration/calibration.tsx index 29506db9f4f249b5b884c2154c239e83f1990624..19a2d5cd2a2a12994b46c2efc489d8b623675547 100644 --- a/src/components/configure/calibration/calibration.tsx +++ b/src/components/configure/calibration/calibration.tsx @@ -27,6 +27,8 @@ import {BasePanel, BaseTitle} from 'src/components/common/layout' import {KeySelector} from 'src/components/common/key-selector' const AUTO_DURATION = 5 +/** 设为 true 可恢复「设置按键行程」入口按钮 */ +const SHOW_SET_SWITCH_TRAVEL_BUTTON = false const Container = styled.div` width: 100%; @@ -309,7 +311,9 @@ export const Calibration = () => { <> {caliTips ? ( {caliTips} - ) : switchRule && deviceMode !== 'edit' ? ( + ) : SHOW_SET_SWITCH_TRAVEL_BUTTON && + switchRule && + deviceMode !== 'edit' ? ( dispatch(setAxCfg(true))}> {t('Set Switch Travel')} diff --git a/src/components/configure/firmware/FirmwareUpdate.tsx b/src/components/configure/firmware/FirmwareUpdate.tsx index e26a9264957da328be522bbe043980993de3a928..cccd85665b350827aee383615796b875353ed3b9 100644 --- a/src/components/configure/firmware/FirmwareUpdate.tsx +++ b/src/components/configure/firmware/FirmwareUpdate.tsx @@ -181,11 +181,11 @@ const LogLine = styled.div` } `; -const FileName = styled.span` +/* const FileName = styled.span` color: var(--color-primary); font-size: 14px; font-weight: 500; -`; +`; */ const InfoRow = styled.div` display: flex; diff --git a/src/components/configure/keyboard/profile.tsx b/src/components/configure/keyboard/profile.tsx index 6e746db2c3f126dacbb0ce892cf1299c5e7821c4..8b3d73c0a5f9910bc3b00530bce8af47be7fc732 100644 --- a/src/components/configure/keyboard/profile.tsx +++ b/src/components/configure/keyboard/profile.tsx @@ -893,7 +893,7 @@ const EditDialog = (props: { spellCheck={false} value={decodeProfileName(name)} placeholder={t('Please enter the profile name')} - maxLength={20} + maxLength={15} /> @@ -1081,7 +1081,7 @@ const NewProfileDialog = (props: { spellCheck={false} value={name} placeholder={t('Please enter the profile name')} - maxLength={20} + maxLength={15} /> diff --git a/src/components/configure/keyboard/save-load.tsx b/src/components/configure/keyboard/save-load.tsx index 789649165da35ca776fe0e9f6e9710c4dec6fd4d..9cc2ee8082fadcd297c1c8e46b27e02314f04380 100644 --- a/src/components/configure/keyboard/save-load.tsx +++ b/src/components/configure/keyboard/save-load.tsx @@ -300,7 +300,7 @@ export function ProfileImportForm(props: ProfileImportFormProps) { placeholder={t( 'The profile name will be filled in automatically' )} - maxLength={20} + maxLength={15} /> diff --git a/src/components/configure/performance/ap.tsx b/src/components/configure/performance/ap.tsx index 9b5a89babb550c0d90d691e82419d7db40a4d44a..cecd7a4aeb9afd4fb35fe802804c04b1633a1854 100644 --- a/src/components/configure/performance/ap.tsx +++ b/src/components/configure/performance/ap.tsx @@ -228,6 +228,7 @@ export const AP = () => { value={apData.ap} labelPosition="top" showLabelInput + mouseOnlyRail disabled={!selectedKeys?.length} onChange={handleAPChange} wait={100} @@ -271,6 +272,7 @@ export const AP = () => { step={AP_SLIDER_STEP} value={dzData.dzt} labelPosition="top" + mouseOnlyRail disabled={!selectedKeys?.length || !dzData.dz} onChange={handleDZTChange} wait={100} @@ -289,6 +291,7 @@ export const AP = () => { step={AP_SLIDER_STEP} value={dzData.dzb} labelPosition="top" + mouseOnlyRail disabled={!selectedKeys?.length || !dzData.dz} onChange={handleDZBChange} wait={100} diff --git a/src/components/configure/side/Lang.tsx b/src/components/configure/side/Lang.tsx index dcc4f4cb7664354a40180f5520edaf53bd6c477a..43361f28c7fdd1deb11cccd6dd0167b4c860faef 100644 --- a/src/components/configure/side/Lang.tsx +++ b/src/components/configure/side/Lang.tsx @@ -1,6 +1,7 @@ import React, {useMemo} from 'react' import {useTranslation} from 'react-i18next' import styled from 'styled-components' +import {Select} from 'src/components/form/select' const Container = styled.div<{$nobg?: boolean}>` width: 100%; @@ -21,8 +22,10 @@ const langs = [ {value: 'ja', label: '日本語'}, ] +const LANG_TRIGGER_WIDTH = 91 + const LangButton = styled.div` - width: 91px; + width: ${LANG_TRIGGER_WIDTH}px; height: 36px; border-radius: 36px; font-size: 14px; @@ -53,7 +56,13 @@ export const Lang = (props: { : i18n.languages[i18n.languages.length - 1] }, [i18n.resolvedLanguage, i18n.languages]) - return ( + const selectValue = useMemo(() => { + const code = selectLang ?? '' + return langs.find(l => code === l.value || code.startsWith(`${l.value}-`)) + ?.value ?? 'en' + }, [selectLang]) + + return ( <> - { - const currentIndex = langs.findIndex(lang => lang.value === selectLang) - const nextIndex = (currentIndex + 1) % langs.length - changeLanguage(langs[nextIndex].value) - }} - > - {(() => { - const currentLang = langs.find(lang => lang.value === selectLang) - return currentLang ? currentLang.label : 'English' - })()} - - {/* setSliding(true)} onTouchStart={() => setSliding(true)} onKeyDown={e => { + if (mouseOnlyRail) { + const block = + e.key === 'ArrowLeft' || + e.key === 'ArrowRight' || + e.key === 'ArrowUp' || + e.key === 'ArrowDown' || + e.key === 'Home' || + e.key === 'End' || + e.key === 'PageUp' || + e.key === 'PageDown' || + e.key === ' ' + if (block) e.preventDefault() + return + } if ( e.key === 'ArrowLeft' || e.key === 'ArrowRight' || diff --git a/src/index.css b/src/index.css index d34dbfe3b16bab5998f46394a212df1bfe0a4340..c6324a5be088a0553977bd2dc1287de665a1428e 100644 --- a/src/index.css +++ b/src/index.css @@ -39,7 +39,7 @@ } html { - --radius-default: 12px; + --radius-default: 24px; --font-menu-1: 900 16px var(--font); --font-menu-2: 700 20px var(--font);