refactor: Constants
This commit is contained in:
parent
242bc082dd
commit
84090b0272
|
|
@ -23,6 +23,8 @@
|
|||
import type { Component } from 'svelte';
|
||||
import { NUMERIC_FIELDS, POSITIVE_INTEGER_FIELDS } from '$lib/constants/settings-fields';
|
||||
import { SETTINGS_COLOR_MODES_CONFIG } from '$lib/constants/settings-config';
|
||||
import { SETTINGS_SECTION_TITLES } from '$lib/constants/settings-sections';
|
||||
import type { SettingsSectionTitle } from '$lib/constants/settings-sections';
|
||||
|
||||
interface Props {
|
||||
onSave?: () => void;
|
||||
|
|
@ -33,10 +35,10 @@
|
|||
const settingSections: Array<{
|
||||
fields: SettingsFieldConfig[];
|
||||
icon: Component;
|
||||
title: string;
|
||||
title: SettingsSectionTitle;
|
||||
}> = [
|
||||
{
|
||||
title: 'General',
|
||||
title: SETTINGS_SECTION_TITLES.GENERAL,
|
||||
icon: Settings,
|
||||
fields: [
|
||||
{
|
||||
|
|
@ -80,7 +82,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
title: 'Display',
|
||||
title: SETTINGS_SECTION_TITLES.DISPLAY,
|
||||
icon: Monitor,
|
||||
fields: [
|
||||
{
|
||||
|
|
@ -127,7 +129,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
title: 'Sampling',
|
||||
title: SETTINGS_SECTION_TITLES.SAMPLING,
|
||||
icon: Funnel,
|
||||
fields: [
|
||||
{
|
||||
|
|
@ -193,7 +195,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
title: 'Penalties',
|
||||
title: SETTINGS_SECTION_TITLES.PENALTIES,
|
||||
icon: AlertTriangle,
|
||||
fields: [
|
||||
{
|
||||
|
|
@ -239,12 +241,12 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
title: 'Import/Export',
|
||||
title: SETTINGS_SECTION_TITLES.IMPORT_EXPORT,
|
||||
icon: Database,
|
||||
fields: []
|
||||
},
|
||||
{
|
||||
title: 'MCP',
|
||||
title: SETTINGS_SECTION_TITLES.MCP,
|
||||
icon: McpLogo,
|
||||
fields: [
|
||||
{
|
||||
|
|
@ -265,7 +267,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
title: 'Developer',
|
||||
title: SETTINGS_SECTION_TITLES.DEVELOPER,
|
||||
icon: Code,
|
||||
fields: [
|
||||
{
|
||||
|
|
@ -300,7 +302,7 @@
|
|||
// }
|
||||
];
|
||||
|
||||
let activeSection = $state('General');
|
||||
let activeSection = $state<SettingsSectionTitle>(SETTINGS_SECTION_TITLES.GENERAL);
|
||||
let currentSection = $derived(
|
||||
settingSections.find((section) => section.title === activeSection) || settingSections[0]
|
||||
);
|
||||
|
|
@ -487,9 +489,9 @@
|
|||
<h3 class="text-lg font-semibold">{currentSection.title}</h3>
|
||||
</div>
|
||||
|
||||
{#if currentSection.title === 'Import/Export'}
|
||||
{#if currentSection.title === SETTINGS_SECTION_TITLES.IMPORT_EXPORT}
|
||||
<ChatSettingsImportExportTab />
|
||||
{:else if currentSection.title === 'MCP'}
|
||||
{:else if currentSection.title === SETTINGS_SECTION_TITLES.MCP}
|
||||
<div class="space-y-6">
|
||||
<ChatSettingsFields
|
||||
fields={currentSection.fields}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Settings section titles constants for ChatSettings component.
|
||||
*
|
||||
* These titles define the navigation sections in the settings dialog.
|
||||
* Used for both sidebar navigation and mobile horizontal scroll menu.
|
||||
*/
|
||||
export const SETTINGS_SECTION_TITLES = {
|
||||
GENERAL: 'General',
|
||||
DISPLAY: 'Display',
|
||||
SAMPLING: 'Sampling',
|
||||
PENALTIES: 'Penalties',
|
||||
IMPORT_EXPORT: 'Import/Export',
|
||||
MCP: 'MCP',
|
||||
DEVELOPER: 'Developer'
|
||||
} as const;
|
||||
|
||||
/** Type for settings section titles */
|
||||
export type SettingsSectionTitle =
|
||||
(typeof SETTINGS_SECTION_TITLES)[keyof typeof SETTINGS_SECTION_TITLES];
|
||||
Loading…
Reference in New Issue