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")} +
+
+ + )}