mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 20:03:13 +08:00
refactor(desktop): give the shared Settings pieces their own module
SETTINGS_CHECKBOX_INPUT_CLASS, SettingsCheckboxMark and isValidHttpProxyUrl are the only declarations in Settings.tsx that more than one panel uses. They move ahead of the remaining panel extractions: leaving them behind would make every extracted panel import from the file that imports it, and that cycle is the kind of fragility the split is meant to remove. Pure move — the three declarations are byte-identical apart from the `export` prefix. lint clean, 174 Settings tests pass.
This commit is contained in:
@@ -62,11 +62,11 @@ import { BrandSeal } from '../components/composite/BrandSeal'
|
||||
import { getDesktopNotificationPermission, notifyDesktop, getDesktopNotificationPlatform, openDesktopNotificationSettings, requestDesktopNotificationPermission, type DesktopNotificationPermission } from '../lib/desktopNotifications'
|
||||
import { API_KEY_JSON_PLACEHOLDER, maskSettingsJsonSecrets, restoreSettingsJsonSecrets, stripProviderSettingsJsonEnv } from '../lib/providerSettingsJson'
|
||||
import { H5AccessSettings } from './settings/H5AccessSettings'
|
||||
import { SETTINGS_CHECKBOX_INPUT_CLASS, SettingsCheckboxMark, isValidHttpProxyUrl } from './settings/shared'
|
||||
|
||||
const NETWORK_TIMEOUT_MIN_SECONDS = 30
|
||||
const NETWORK_TIMEOUT_MAX_SECONDS = 1800
|
||||
const NETWORK_TIMEOUT_STEP_SECONDS = 30
|
||||
const SETTINGS_CHECKBOX_INPUT_CLASS = 'settings-checkbox-input peer'
|
||||
const BUILT_IN_OUTPUT_STYLE_TRANSLATION_KEYS = {
|
||||
default: {
|
||||
label: 'settings.general.outputStyleBuiltin.default.label',
|
||||
@@ -2159,7 +2159,6 @@ function ProviderFormModal({ open, onClose, mode, provider, presets }: ProviderF
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// ─── General Settings ──────────────────────────────────────
|
||||
|
||||
export function GeneralSettings() {
|
||||
@@ -2294,7 +2293,6 @@ export function GeneralSettings() {
|
||||
{ value: 'kr', label: '한국어' },
|
||||
]
|
||||
|
||||
|
||||
const RESPONSE_LANGUAGES: Array<{ value: string; label: string }> = [
|
||||
{ value: '', label: t('settings.general.responseLangDefault') },
|
||||
{ value: 'english', label: 'English' },
|
||||
@@ -3560,23 +3558,6 @@ function getOutputStyleSourceLabel(
|
||||
}
|
||||
}
|
||||
|
||||
function SettingsCheckboxMark({ checked, disabled = false }: { checked: boolean; disabled?: boolean }) {
|
||||
return (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-[var(--radius-md)] border transition-all peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--color-border-focus)] ${
|
||||
checked
|
||||
? 'border-[var(--color-brand)] bg-[var(--color-brand)] text-[var(--color-on-primary)] shadow-[var(--shadow-button-primary)]'
|
||||
: 'border-[var(--color-border-focus)] bg-[var(--color-surface)] text-transparent'
|
||||
} ${disabled ? 'opacity-50' : ''}`}
|
||||
>
|
||||
<span className="material-symbols-outlined text-[16px] leading-none" style={{ fontVariationSettings: "'FILL' 1" }}>
|
||||
check
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Skill Settings ──────────────────────────────────────
|
||||
|
||||
function SkillSettings() {
|
||||
@@ -3637,15 +3618,6 @@ const SOCIAL_LINKS = [
|
||||
{ name: 'Xiaohongshu', icon: '/icons/xiaohongshu.svg', url: 'https://www.xiaohongshu.com/user/profile/5f58bd990000000001003753', label: '程序员阿江-Relakkes' },
|
||||
] as const
|
||||
|
||||
function isValidHttpProxyUrl(value: string) {
|
||||
try {
|
||||
const url = new URL(value)
|
||||
return url.protocol === 'http:' || url.protocol === 'https:'
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function AboutSettings() {
|
||||
const t = useTranslation()
|
||||
const [version, setVersion] = useState('')
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
/**
|
||||
* The few things every Settings panel needs.
|
||||
*
|
||||
* Extracted while splitting `Settings.tsx` into one module per panel. These three are
|
||||
* the only declarations more than one panel reaches for, so they get their own module
|
||||
* rather than staying behind — leaving them in Settings.tsx would make every panel
|
||||
* import from the file that imports it, and the resulting cycle is exactly the kind of
|
||||
* fragility a split is supposed to remove.
|
||||
*/
|
||||
|
||||
export const SETTINGS_CHECKBOX_INPUT_CLASS = 'settings-checkbox-input peer'
|
||||
|
||||
export function SettingsCheckboxMark({ checked, disabled = false }: { checked: boolean; disabled?: boolean }) {
|
||||
return (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={`mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-[var(--radius-md)] border transition-all peer-focus-visible:ring-2 peer-focus-visible:ring-[var(--color-border-focus)] ${
|
||||
checked
|
||||
? 'border-[var(--color-brand)] bg-[var(--color-brand)] text-[var(--color-on-primary)] shadow-[var(--shadow-button-primary)]'
|
||||
: 'border-[var(--color-border-focus)] bg-[var(--color-surface)] text-transparent'
|
||||
} ${disabled ? 'opacity-50' : ''}`}
|
||||
>
|
||||
<span className="material-symbols-outlined text-[16px] leading-none" style={{ fontVariationSettings: "'FILL' 1" }}>
|
||||
check
|
||||
</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
export function isValidHttpProxyUrl(value: string) {
|
||||
try {
|
||||
const url = new URL(value)
|
||||
return url.protocol === 'http:' || url.protocol === 'https:'
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user