mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-21 18:19:03 +08:00
新增禁用搜索小键盘设置
This commit is contained in:
@@ -9,6 +9,7 @@ pub struct SettingsSpec {
|
|||||||
pub log_level: String,
|
pub log_level: String,
|
||||||
pub window_zoom: f64,
|
pub window_zoom: f64,
|
||||||
pub search_keyboard_layout: String,
|
pub search_keyboard_layout: String,
|
||||||
|
pub disable_search_keyboard: bool,
|
||||||
pub themes_custom: JsonValue,
|
pub themes_custom: JsonValue,
|
||||||
pub auto_score_enabled: bool,
|
pub auto_score_enabled: bool,
|
||||||
pub auto_score_rules: JsonValue,
|
pub auto_score_rules: JsonValue,
|
||||||
@@ -24,6 +25,7 @@ impl Default for SettingsSpec {
|
|||||||
log_level: "info".to_string(),
|
log_level: "info".to_string(),
|
||||||
window_zoom: 1.0,
|
window_zoom: 1.0,
|
||||||
search_keyboard_layout: "qwerty26".to_string(),
|
search_keyboard_layout: "qwerty26".to_string(),
|
||||||
|
disable_search_keyboard: false,
|
||||||
themes_custom: JsonValue::Array(vec![]),
|
themes_custom: JsonValue::Array(vec![]),
|
||||||
auto_score_enabled: false,
|
auto_score_enabled: false,
|
||||||
auto_score_rules: JsonValue::Array(vec![]),
|
auto_score_rules: JsonValue::Array(vec![]),
|
||||||
@@ -40,6 +42,7 @@ pub enum SettingsKey {
|
|||||||
LogLevel,
|
LogLevel,
|
||||||
WindowZoom,
|
WindowZoom,
|
||||||
SearchKeyboardLayout,
|
SearchKeyboardLayout,
|
||||||
|
DisableSearchKeyboard,
|
||||||
ThemesCustom,
|
ThemesCustom,
|
||||||
AutoScoreEnabled,
|
AutoScoreEnabled,
|
||||||
AutoScoreRules,
|
AutoScoreRules,
|
||||||
@@ -55,6 +58,7 @@ impl SettingsKey {
|
|||||||
SettingsKey::LogLevel => "log_level",
|
SettingsKey::LogLevel => "log_level",
|
||||||
SettingsKey::WindowZoom => "window_zoom",
|
SettingsKey::WindowZoom => "window_zoom",
|
||||||
SettingsKey::SearchKeyboardLayout => "search_keyboard_layout",
|
SettingsKey::SearchKeyboardLayout => "search_keyboard_layout",
|
||||||
|
SettingsKey::DisableSearchKeyboard => "disable_search_keyboard",
|
||||||
SettingsKey::ThemesCustom => "themes_custom",
|
SettingsKey::ThemesCustom => "themes_custom",
|
||||||
SettingsKey::AutoScoreEnabled => "auto_score_enabled",
|
SettingsKey::AutoScoreEnabled => "auto_score_enabled",
|
||||||
SettingsKey::AutoScoreRules => "auto_score_rules",
|
SettingsKey::AutoScoreRules => "auto_score_rules",
|
||||||
@@ -70,6 +74,7 @@ impl SettingsKey {
|
|||||||
"log_level" => Some(SettingsKey::LogLevel),
|
"log_level" => Some(SettingsKey::LogLevel),
|
||||||
"window_zoom" => Some(SettingsKey::WindowZoom),
|
"window_zoom" => Some(SettingsKey::WindowZoom),
|
||||||
"search_keyboard_layout" => Some(SettingsKey::SearchKeyboardLayout),
|
"search_keyboard_layout" => Some(SettingsKey::SearchKeyboardLayout),
|
||||||
|
"disable_search_keyboard" => Some(SettingsKey::DisableSearchKeyboard),
|
||||||
"themes_custom" => Some(SettingsKey::ThemesCustom),
|
"themes_custom" => Some(SettingsKey::ThemesCustom),
|
||||||
"auto_score_enabled" => Some(SettingsKey::AutoScoreEnabled),
|
"auto_score_enabled" => Some(SettingsKey::AutoScoreEnabled),
|
||||||
"auto_score_rules" => Some(SettingsKey::AutoScoreRules),
|
"auto_score_rules" => Some(SettingsKey::AutoScoreRules),
|
||||||
@@ -291,6 +296,16 @@ impl SettingsService {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
defs.insert(
|
||||||
|
SettingsKey::DisableSearchKeyboard,
|
||||||
|
SettingDefinition {
|
||||||
|
kind: SettingValueKind::Boolean,
|
||||||
|
default_value: SettingsValue::Boolean(false),
|
||||||
|
write_permission: PermissionRequirement::Admin,
|
||||||
|
validate: None,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
defs.insert(
|
defs.insert(
|
||||||
SettingsKey::ThemesCustom,
|
SettingsKey::ThemesCustom,
|
||||||
SettingDefinition {
|
SettingDefinition {
|
||||||
@@ -459,6 +474,10 @@ impl SettingsService {
|
|||||||
SettingsValue::String(s) => s,
|
SettingsValue::String(s) => s,
|
||||||
_ => "qwerty26".to_string(),
|
_ => "qwerty26".to_string(),
|
||||||
},
|
},
|
||||||
|
disable_search_keyboard: match self.get_value(SettingsKey::DisableSearchKeyboard) {
|
||||||
|
SettingsValue::Boolean(b) => b,
|
||||||
|
_ => false,
|
||||||
|
},
|
||||||
themes_custom: match self.get_value(SettingsKey::ThemesCustom) {
|
themes_custom: match self.get_value(SettingsKey::ThemesCustom) {
|
||||||
SettingsValue::Json(j) => j,
|
SettingsValue::Json(j) => j,
|
||||||
_ => JsonValue::Array(vec![]),
|
_ => JsonValue::Array(vec![]),
|
||||||
|
|||||||
+26
-5
@@ -64,6 +64,7 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
|||||||
const [searchKeyword, setSearchKeyword] = useState("")
|
const [searchKeyword, setSearchKeyword] = useState("")
|
||||||
const [showPinyinKeyboard, setShowPinyinKeyboard] = useState(false)
|
const [showPinyinKeyboard, setShowPinyinKeyboard] = useState(false)
|
||||||
const [searchKeyboardLayout, setSearchKeyboardLayout] = useState<SearchKeyboardLayout>("qwerty26")
|
const [searchKeyboardLayout, setSearchKeyboardLayout] = useState<SearchKeyboardLayout>("qwerty26")
|
||||||
|
const [disableSearchKeyboard, setDisableSearchKeyboard] = useState(false)
|
||||||
|
|
||||||
const scrollContainerRef = useRef<HTMLDivElement>(null)
|
const scrollContainerRef = useRef<HTMLDivElement>(null)
|
||||||
const groupRefs = useRef<Record<string, HTMLDivElement | null>>({})
|
const groupRefs = useRef<Record<string, HTMLDivElement | null>>({})
|
||||||
@@ -145,12 +146,22 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
|||||||
})
|
})
|
||||||
.catch(() => void 0)
|
.catch(() => void 0)
|
||||||
|
|
||||||
|
api
|
||||||
|
.getSetting("disable_search_keyboard")
|
||||||
|
.then((res: any) => {
|
||||||
|
if (disposed) return
|
||||||
|
setDisableSearchKeyboard(Boolean(res?.data))
|
||||||
|
})
|
||||||
|
.catch(() => void 0)
|
||||||
|
|
||||||
api
|
api
|
||||||
.onSettingChanged((change: any) => {
|
.onSettingChanged((change: any) => {
|
||||||
if (change?.key !== "search_keyboard_layout") return
|
if (change?.key === "search_keyboard_layout" && (change?.value === "t9" || change?.value === "qwerty26")) {
|
||||||
if (change?.value === "t9" || change?.value === "qwerty26") {
|
|
||||||
setSearchKeyboardLayout(change.value)
|
setSearchKeyboardLayout(change.value)
|
||||||
}
|
}
|
||||||
|
if (change?.key === "disable_search_keyboard") {
|
||||||
|
setDisableSearchKeyboard(Boolean(change?.value))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then((fn: () => void) => {
|
.then((fn: () => void) => {
|
||||||
if (disposed) {
|
if (disposed) {
|
||||||
@@ -167,6 +178,12 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (disableSearchKeyboard && showPinyinKeyboard) {
|
||||||
|
setShowPinyinKeyboard(false)
|
||||||
|
}
|
||||||
|
}, [disableSearchKeyboard, showPinyinKeyboard])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onDocumentClick = (e: MouseEvent) => {
|
const onDocumentClick = (e: MouseEvent) => {
|
||||||
const target = e.target as Node | null
|
const target = e.target as Node | null
|
||||||
@@ -893,8 +910,12 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
|||||||
<Input
|
<Input
|
||||||
value={searchKeyword}
|
value={searchKeyword}
|
||||||
onChange={(e) => setSearchKeyword(e.target.value)}
|
onChange={(e) => setSearchKeyword(e.target.value)}
|
||||||
onFocus={() => setShowPinyinKeyboard(true)}
|
onFocus={() => {
|
||||||
onClick={() => setShowPinyinKeyboard(true)}
|
if (!disableSearchKeyboard) setShowPinyinKeyboard(true)
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
if (!disableSearchKeyboard) setShowPinyinKeyboard(true)
|
||||||
|
}}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === "Escape") setShowPinyinKeyboard(false)
|
if (e.key === "Escape") setShowPinyinKeyboard(false)
|
||||||
}}
|
}}
|
||||||
@@ -903,7 +924,7 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
|||||||
allowClear
|
allowClear
|
||||||
style={{ width: "220px" }}
|
style={{ width: "220px" }}
|
||||||
/>
|
/>
|
||||||
{showPinyinKeyboard && (
|
{!disableSearchKeyboard && showPinyinKeyboard && (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
import React, { useEffect, useMemo, useRef, useState } from "react"
|
import React, { useEffect, useMemo, useRef, useState } from "react"
|
||||||
import { Tabs, Card, Form, Select, Input, Button, Space, Divider, Tag, Modal, message } from "antd"
|
import {
|
||||||
|
Tabs,
|
||||||
|
Card,
|
||||||
|
Form,
|
||||||
|
Select,
|
||||||
|
Input,
|
||||||
|
Button,
|
||||||
|
Space,
|
||||||
|
Divider,
|
||||||
|
Tag,
|
||||||
|
Modal,
|
||||||
|
Switch,
|
||||||
|
message,
|
||||||
|
} from "antd"
|
||||||
import { ThemeQuickSettings } from "./ThemeQuickSettings"
|
import { ThemeQuickSettings } from "./ThemeQuickSettings"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
import { changeLanguage, getCurrentLanguage, languageOptions, AppLanguage } from "../i18n"
|
import { changeLanguage, getCurrentLanguage, languageOptions, AppLanguage } from "../i18n"
|
||||||
@@ -10,6 +23,7 @@ type appSettings = {
|
|||||||
log_level: "debug" | "info" | "warn" | "error"
|
log_level: "debug" | "info" | "warn" | "error"
|
||||||
window_zoom?: string
|
window_zoom?: string
|
||||||
search_keyboard_layout?: "t9" | "qwerty26"
|
search_keyboard_layout?: "t9" | "qwerty26"
|
||||||
|
disable_search_keyboard?: boolean
|
||||||
auto_score_enabled?: boolean
|
auto_score_enabled?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,6 +36,7 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
|||||||
log_level: "info",
|
log_level: "info",
|
||||||
window_zoom: "1.0",
|
window_zoom: "1.0",
|
||||||
search_keyboard_layout: "qwerty26",
|
search_keyboard_layout: "qwerty26",
|
||||||
|
disable_search_keyboard: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
const [securityStatus, setSecurityStatus] = useState<{
|
const [securityStatus, setSecurityStatus] = useState<{
|
||||||
@@ -112,6 +127,8 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
|||||||
if (change?.key === "window_zoom") return { ...prev, window_zoom: change.value }
|
if (change?.key === "window_zoom") return { ...prev, window_zoom: change.value }
|
||||||
if (change?.key === "search_keyboard_layout")
|
if (change?.key === "search_keyboard_layout")
|
||||||
return { ...prev, search_keyboard_layout: change.value }
|
return { ...prev, search_keyboard_layout: change.value }
|
||||||
|
if (change?.key === "disable_search_keyboard")
|
||||||
|
return { ...prev, disable_search_keyboard: Boolean(change.value) }
|
||||||
if (change?.key === "auto_score_enabled")
|
if (change?.key === "auto_score_enabled")
|
||||||
return { ...prev, auto_score_enabled: change.value }
|
return { ...prev, auto_score_enabled: change.value }
|
||||||
return prev
|
return prev
|
||||||
@@ -409,6 +426,31 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission
|
|||||||
</div>
|
</div>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item label={t("settings.searchKeyboard.disableToggle")}>
|
||||||
|
<Switch
|
||||||
|
checked={Boolean(settings.disable_search_keyboard)}
|
||||||
|
onChange={async (checked) => {
|
||||||
|
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}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
style={{ marginTop: "4px", fontSize: "12px", color: "var(--ss-text-secondary)" }}
|
||||||
|
>
|
||||||
|
{t("settings.searchKeyboard.disableHint")}
|
||||||
|
</div>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item label={t("settings.interfaceZoom")}>
|
<Form.Item label={t("settings.interfaceZoom")}>
|
||||||
<Select
|
<Select
|
||||||
value={settings.window_zoom || "1.0"}
|
value={settings.window_zoom || "1.0"}
|
||||||
|
|||||||
@@ -130,6 +130,8 @@
|
|||||||
"searchKeyboard": {
|
"searchKeyboard": {
|
||||||
"title": "Search Keyboard",
|
"title": "Search Keyboard",
|
||||||
"hint": "Choose the pop-up keyboard layout under the search box",
|
"hint": "Choose the pop-up keyboard layout under the search box",
|
||||||
|
"disableToggle": "Disable Search Keyboard",
|
||||||
|
"disableHint": "When enabled, the keyboard will no longer pop up below the search box",
|
||||||
"options": {
|
"options": {
|
||||||
"qwerty26": "26-key (QWERTY)",
|
"qwerty26": "26-key (QWERTY)",
|
||||||
"t9": "9-key (T9)"
|
"t9": "9-key (T9)"
|
||||||
|
|||||||
@@ -130,6 +130,8 @@
|
|||||||
"searchKeyboard": {
|
"searchKeyboard": {
|
||||||
"title": "搜索小键盘",
|
"title": "搜索小键盘",
|
||||||
"hint": "选择搜索框下方弹出的小键盘布局",
|
"hint": "选择搜索框下方弹出的小键盘布局",
|
||||||
|
"disableToggle": "禁用搜索小键盘",
|
||||||
|
"disableHint": "开启后,搜索框下方不再弹出小键盘",
|
||||||
"options": {
|
"options": {
|
||||||
"qwerty26": "26 键(QWERTY)",
|
"qwerty26": "26 键(QWERTY)",
|
||||||
"t9": "9 键(T9)"
|
"t9": "9 键(T9)"
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export type settingsKey =
|
|||||||
| "log_level"
|
| "log_level"
|
||||||
| "window_zoom"
|
| "window_zoom"
|
||||||
| "search_keyboard_layout"
|
| "search_keyboard_layout"
|
||||||
|
| "disable_search_keyboard"
|
||||||
| "themes_custom"
|
| "themes_custom"
|
||||||
| "auto_score_enabled"
|
| "auto_score_enabled"
|
||||||
| "auto_score_rules"
|
| "auto_score_rules"
|
||||||
@@ -34,6 +35,7 @@ export interface settingsSpec {
|
|||||||
log_level: string
|
log_level: string
|
||||||
window_zoom: number
|
window_zoom: number
|
||||||
search_keyboard_layout: "t9" | "qwerty26"
|
search_keyboard_layout: "t9" | "qwerty26"
|
||||||
|
disable_search_keyboard: boolean
|
||||||
themes_custom: themeConfig[]
|
themes_custom: themeConfig[]
|
||||||
auto_score_enabled: boolean
|
auto_score_enabled: boolean
|
||||||
auto_score_rules: any[]
|
auto_score_rules: any[]
|
||||||
|
|||||||
Reference in New Issue
Block a user