diff --git a/src/pages/UiConfigPage.vue b/src/pages/UiConfigPage.vue index 6aa052c..13171d9 100644 --- a/src/pages/UiConfigPage.vue +++ b/src/pages/UiConfigPage.vue @@ -40,13 +40,17 @@ const config = reactive(createDefaultKhanegiUiConfig()) as ReturnType< const hasDefaultSnapshot = computed(() => Boolean(config.defaultSnapshot)) const isCustom = computed(() => selectedPreset.value === 'custom') +/** رنگ‌های همان حالتی که در پیش‌نمایش دیده می‌شود (dark/light) */ const activePreviewColors = computed(() => { const schemes = config.app.theme.schemes if (schemes?.[previewMode.value]) return schemes[previewMode.value] return config.app.theme.colors }) -const colorKeys = computed(() => Object.keys(config.app.theme.colors)) +/** فیلدهای رنگ سفارشی روی همان scheme پیش‌نمایش ویرایش می‌شوند تا نمونه زنده بماند */ +const editableColors = computed(() => activePreviewColors.value) + +const colorKeys = computed(() => Object.keys(editableColors.value)) const previewStyle = computed(() => ({ background: activePreviewColors.value.pageBg, @@ -54,6 +58,12 @@ const previewStyle = computed(() => ({ borderRadius: `${config.app.theme.borderRadius.lg}px`, })) +const primaryStyle = computed(() => ({ + background: activePreviewColors.value.primary, + color: activePreviewColors.value.onAccent, + borderRadius: `${config.app.theme.borderRadius.md}px`, +})) + const accentStyle = computed(() => ({ background: activePreviewColors.value.secondary, color: activePreviewColors.value.onAccent, @@ -64,13 +74,14 @@ function selectPreset(id: KhanegiPresetId) { selectedPreset.value = id if (id === 'custom') { config.app.theme.presetId = 'custom' - if (!config.app.theme.schemes) { - config.app.theme.schemes = { - dark: { ...config.app.theme.colors }, - light: { ...config.app.theme.colors }, - } + ensureSchemes() + // clone so custom edits never mutate shared preset objects + config.app.theme.schemes = { + dark: { ...config.app.theme.schemes!.dark }, + light: { ...config.app.theme.schemes!.light }, } - message.info('حالت سفارشی — می‌توانید جزئیات را ویرایش کنید') + syncActiveColorsFromMode(config) + message.info('حالت سفارشی — تغییرات فوراً در نمونه کارت دیده می‌شود') return } applyKhanegiPreset(config, id) @@ -82,14 +93,18 @@ function selectPreset(id: KhanegiPresetId) { function onModeChange() { syncActiveColorsFromMode(config) previewMode.value = config.app.theme.mode === 'light' ? 'light' : 'dark' - if (isCustom.value) markCustomAndSyncSchemes(config) + if (isCustom.value) { + config.app.theme.presetId = 'custom' + } } +/** بعد از هر تغییر رنگ/گوشه: سفارشی شو و colors فعال را با scheme حالت اپ هم‌تراز کن */ function onColorEdit() { - if (!isCustom.value) { - selectedPreset.value = 'custom' - } - markCustomAndSyncSchemes(config) + selectedPreset.value = 'custom' + config.app.theme.presetId = 'custom' + ensureSchemes() + const appMode = config.app.theme.mode === 'light' ? 'light' : 'dark' + Object.assign(config.app.theme.colors, config.app.theme.schemes![appMode]) } function syncAdvancedJson() { @@ -310,14 +325,18 @@ onMounted(load) - اکسنت +
surface
@@ -325,6 +344,10 @@ onMounted(load)
متن فرعی با رنگ theme
+
+ اصلی + اکسنت +
@@ -348,27 +371,30 @@ onMounted(load)

رنگ‌ها {{ isCustom ? '(سفارشی)' : '(فقط‌خواندنی تا انتخاب سفارشی)' }}

+

+ ویرایش برای حالت «{{ previewMode === 'dark' ? 'تیره' : 'روشن' }}» پیش‌نمایش است؛ با سوییچ تیره/روشن بالای کارت، هر پالت جداگانه تنظیم می‌شود. +

-