mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-19 19:04:23 +08:00
新增禁用搜索小键盘设置
This commit is contained in:
+26
-5
@@ -64,6 +64,7 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
||||
const [searchKeyword, setSearchKeyword] = useState("")
|
||||
const [showPinyinKeyboard, setShowPinyinKeyboard] = useState(false)
|
||||
const [searchKeyboardLayout, setSearchKeyboardLayout] = useState<SearchKeyboardLayout>("qwerty26")
|
||||
const [disableSearchKeyboard, setDisableSearchKeyboard] = useState(false)
|
||||
|
||||
const scrollContainerRef = useRef<HTMLDivElement>(null)
|
||||
const groupRefs = useRef<Record<string, HTMLDivElement | null>>({})
|
||||
@@ -145,12 +146,22 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
||||
})
|
||||
.catch(() => void 0)
|
||||
|
||||
api
|
||||
.getSetting("disable_search_keyboard")
|
||||
.then((res: any) => {
|
||||
if (disposed) return
|
||||
setDisableSearchKeyboard(Boolean(res?.data))
|
||||
})
|
||||
.catch(() => void 0)
|
||||
|
||||
api
|
||||
.onSettingChanged((change: any) => {
|
||||
if (change?.key !== "search_keyboard_layout") return
|
||||
if (change?.value === "t9" || change?.value === "qwerty26") {
|
||||
if (change?.key === "search_keyboard_layout" && (change?.value === "t9" || change?.value === "qwerty26")) {
|
||||
setSearchKeyboardLayout(change.value)
|
||||
}
|
||||
if (change?.key === "disable_search_keyboard") {
|
||||
setDisableSearchKeyboard(Boolean(change?.value))
|
||||
}
|
||||
})
|
||||
.then((fn: () => void) => {
|
||||
if (disposed) {
|
||||
@@ -167,6 +178,12 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (disableSearchKeyboard && showPinyinKeyboard) {
|
||||
setShowPinyinKeyboard(false)
|
||||
}
|
||||
}, [disableSearchKeyboard, showPinyinKeyboard])
|
||||
|
||||
useEffect(() => {
|
||||
const onDocumentClick = (e: MouseEvent) => {
|
||||
const target = e.target as Node | null
|
||||
@@ -893,8 +910,12 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
||||
<Input
|
||||
value={searchKeyword}
|
||||
onChange={(e) => setSearchKeyword(e.target.value)}
|
||||
onFocus={() => setShowPinyinKeyboard(true)}
|
||||
onClick={() => setShowPinyinKeyboard(true)}
|
||||
onFocus={() => {
|
||||
if (!disableSearchKeyboard) setShowPinyinKeyboard(true)
|
||||
}}
|
||||
onClick={() => {
|
||||
if (!disableSearchKeyboard) setShowPinyinKeyboard(true)
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Escape") setShowPinyinKeyboard(false)
|
||||
}}
|
||||
@@ -903,7 +924,7 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
||||
allowClear
|
||||
style={{ width: "220px" }}
|
||||
/>
|
||||
{showPinyinKeyboard && (
|
||||
{!disableSearchKeyboard && showPinyinKeyboard && (
|
||||
<div
|
||||
style={{
|
||||
position: "absolute",
|
||||
|
||||
Reference in New Issue
Block a user