From 9c35a574813f3990c4b0876b61afd2174632c60a Mon Sep 17 00:00:00 2001 From: JSR Date: Sat, 28 Mar 2026 09:32:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=8B=E6=9C=BA=E7=AB=AF=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E9=9A=90=E8=97=8F=E6=90=9C=E7=B4=A2=E5=B0=8F=E9=94=AE?= =?UTF-8?q?=E7=9B=98=E5=8F=8A=E7=9B=B8=E5=85=B3=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Home.tsx | 17 +++--- src/components/Settings.tsx | 106 +++++++++++++++++++----------------- 2 files changed, 64 insertions(+), 59 deletions(-) diff --git a/src/components/Home.tsx b/src/components/Home.tsx index 89fbec5..e6f6a92 100644 --- a/src/components/Home.tsx +++ b/src/components/Home.tsx @@ -113,6 +113,7 @@ export const Home: React.FC = ({ const [showPinyinKeyboard, setShowPinyinKeyboard] = useState(false) const [searchKeyboardLayout, setSearchKeyboardLayout] = useState("qwerty26") const [disableSearchKeyboard, setDisableSearchKeyboard] = useState(false) + const canShowSearchKeyboard = !isMobile && !disableSearchKeyboard const scrollContainerRef = useRef(null) const groupRefs = useRef>({}) @@ -301,10 +302,10 @@ export const Home: React.FC = ({ }, []) useEffect(() => { - if (disableSearchKeyboard && showPinyinKeyboard) { + if (!canShowSearchKeyboard && showPinyinKeyboard) { setShowPinyinKeyboard(false) } - }, [disableSearchKeyboard, showPinyinKeyboard]) + }, [canShowSearchKeyboard, showPinyinKeyboard]) useEffect(() => { const onDocumentClick = (e: MouseEvent) => { @@ -2269,10 +2270,10 @@ export const Home: React.FC = ({ value={searchKeyword} onChange={(e) => setSearchKeyword(e.target.value)} onFocus={() => { - if (!disableSearchKeyboard) setShowPinyinKeyboard(true) + if (canShowSearchKeyboard) setShowPinyinKeyboard(true) }} onClick={() => { - if (!disableSearchKeyboard) setShowPinyinKeyboard(true) + if (canShowSearchKeyboard) setShowPinyinKeyboard(true) }} onKeyDown={(e) => { if (e.key === "Escape") setShowPinyinKeyboard(false) @@ -2282,7 +2283,7 @@ export const Home: React.FC = ({ allowClear style={{ width: "100%" }} /> - {!disableSearchKeyboard && showPinyinKeyboard && ( + {canShowSearchKeyboard && showPinyinKeyboard && (
= ({ value={searchKeyword} onChange={(e) => setSearchKeyword(e.target.value)} onFocus={() => { - if (!disableSearchKeyboard) setShowPinyinKeyboard(true) + if (canShowSearchKeyboard) setShowPinyinKeyboard(true) }} onClick={() => { - if (!disableSearchKeyboard) setShowPinyinKeyboard(true) + if (canShowSearchKeyboard) setShowPinyinKeyboard(true) }} onKeyDown={(e) => { if (e.key === "Escape") setShowPinyinKeyboard(false) @@ -2606,7 +2607,7 @@ export const Home: React.FC = ({ {rewardMode ? t("rewardExchange.exitMode") : t("rewardExchange.enterMode")}
{batchToolbar}
- {!disableSearchKeyboard && showPinyinKeyboard && ( + {canShowSearchKeyboard && showPinyinKeyboard && (
- - { + if (!(window as any).api) return + const next = String(v) as "t9" | "qwerty26" + const res = await (window as any).api.setSetting("search_keyboard_layout", next) + if (res.success) { + setSettings((prev) => ({ ...prev, search_keyboard_layout: next })) + messageApi.success(t("settings.general.saved")) + } else { + messageApi.error(res.message || t("settings.general.saveFailed")) + } + }} + style={{ width: "320px" }} + disabled={!canAdmin} + options={[ + { value: "qwerty26", label: t("settings.searchKeyboard.options.qwerty26") }, + { value: "t9", label: t("settings.searchKeyboard.options.t9") }, + ]} + /> +
+ {t("settings.searchKeyboard.hint")} +
+
- - { - if (!(window as any).api) return - const res = await (window as any).api.setSetting( - "disable_search_keyboard", - checked - ) - if (res.success) { - setSettings((prev) => ({ ...prev, disable_search_keyboard: checked })) - messageApi.success(t("settings.general.saved")) - } else { - messageApi.error(res.message || t("settings.general.saveFailed")) - } - }} - disabled={!canAdmin} - /> -
- {t("settings.searchKeyboard.disableHint")} -
-
+ + { + if (!(window as any).api) return + const res = await (window as any).api.setSetting( + "disable_search_keyboard", + checked + ) + if (res.success) { + setSettings((prev) => ({ ...prev, disable_search_keyboard: checked })) + messageApi.success(t("settings.general.saved")) + } else { + messageApi.error(res.message || t("settings.general.saveFailed")) + } + }} + disabled={!canAdmin} + /> +
+ {t("settings.searchKeyboard.disableHint")} +
+
+ + )}