From d083469710999ce2ec8dbc0f581ad56cb3374ed8 Mon Sep 17 00:00:00 2001 From: mohammad sedighi Date: Wed, 24 Jun 2026 11:52:09 +0330 Subject: [PATCH] fix banner and chart color --- index.html | 4 ---- src/app/bootstrap.ts | 4 ++-- src/store/settingsStore.ts | 6 +++++- src/utils/config.ts | 12 ++++++------ src/views/base/home/components/PriceChart.vue | 12 ++++++++++-- src/views/base/home/composables/useBanners.ts | 8 ++++++++ 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/index.html b/index.html index 6da9af7..d3ce1ab 100644 --- a/index.html +++ b/index.html @@ -276,10 +276,6 @@ var tenantSecondary = normalizeHex(user.secondary_color) var tenantBackground = normalizeHex(user.background_color) - if (user.name === 'boursecu') { - tenantColor = '#2178b5' - } - /** * مهم: * background_color بک‌گراند اپ است. diff --git a/src/app/bootstrap.ts b/src/app/bootstrap.ts index ad4bf81..ce88a69 100644 --- a/src/app/bootstrap.ts +++ b/src/app/bootstrap.ts @@ -5,7 +5,7 @@ import { startPwaManifest } from '@/modules/pwa/manifest' import { createVueApp } from '@/app/createApp' import { setupRouterGuards } from '@/app/setupRouter' import router from '@/router' -import { applyProjectTheme, isBoursecuProject } from '@/utils/config' +import { applyProjectTheme } from '@/utils/config' import { useSettingsStore } from '@/store/settingsStore' import { useUserStore } from '@/store/userStore' import { getToken } from '@/utils' @@ -71,7 +71,7 @@ function applyTenantThemeVars() { const secondaryColor = window.__APP_CONFIG__?.user?.secondary_color const backgroundColor = window.__APP_CONFIG__?.user?.background_color - if (color && !isBoursecuProject()) { + if (color) { document.documentElement.style.setProperty('--App-primary-color', color) } diff --git a/src/store/settingsStore.ts b/src/store/settingsStore.ts index 28cc5ad..0c72a12 100644 --- a/src/store/settingsStore.ts +++ b/src/store/settingsStore.ts @@ -29,7 +29,11 @@ export const useSettingsStore = defineStore('settings', () => { if (value == null) { return false } - return value === true || String(value).toLowerCase() === 'true' + if (value === true) { + return true + } + const normalized = String(value).trim().toLowerCase() + return normalized === 'true' || normalized === '1' || normalized === 'yes' } function mergeSettings(items?: AppSetting[] | null) { diff --git a/src/utils/config.ts b/src/utils/config.ts index 83dd66a..2008266 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -93,16 +93,17 @@ export function getProjectBrandRed() { return isBoursecuProject() ? BOURSECU_BRAND_RED : null } -/** رنگ اصلی دکمه‌ها و چارت — boursecu ثابت آبی، بقیه از تنظیمات tenant */ +/** رنگ accent تم از تنظیمات tenant — بدون override پروژه‌ای */ export function getProjectPrimaryColor() { - if (isBoursecuProject()) { - return BOURSECU_BRAND_BLUE - } - const color = getConfigApp('color') return color != null ? String(color) : undefined } +/** فقط رنگ خط/ناحیه نمودار قیمت در بورس مس */ +export function getBoursecuChartColor() { + return BOURSECU_BRAND_BLUE +} + export function resolveProjectColor(color?: string | null) { if (!color || !isBoursecuProject()) { return color @@ -266,7 +267,6 @@ export function applyProjectTheme() { } document.documentElement.classList.add('project-boursecu') - document.documentElement.style.setProperty('--App-primary-color', BOURSECU_BRAND_BLUE) document.documentElement.style.setProperty('--App-brand-nav', BOURSECU_BRAND_NAV) document.documentElement.style.setProperty('--App-brand-red', BOURSECU_BRAND_RED) document.documentElement.style.setProperty('--App-brand-red-50', '#f8ecec') diff --git a/src/views/base/home/components/PriceChart.vue b/src/views/base/home/components/PriceChart.vue index bb39546..9c3e7a6 100644 --- a/src/views/base/home/components/PriceChart.vue +++ b/src/views/base/home/components/PriceChart.vue @@ -58,7 +58,7 @@ import { computed, nextTick, onMounted, ref, watch } from 'vue' import { useConfigStore } from '@/store/configStore' import { usePrice } from '@/utils/usePrice' -import { getProjectFontFamily, getProjectPrimaryColor } from '@/utils/config' +import { getBoursecuChartColor, getProjectFontFamily } from '@/utils/config' import { computeKatodMesVisualYBounds, prepareKatodMesChartPoints, @@ -101,6 +101,14 @@ const chartInnerClass = computed(() => const showMetalSelector = computed(() => props.layout === 'boursecu') +const chartColor = computed(() => { + if (props.layout === 'boursecu') { + return getBoursecuChartColor() + } + + return config.config?.color ?? '#0A1B37' +}) + const emit = defineEmits<{ updateData: [timeline: string] 'update:selectedMetal': [metal: ChartMetalType] @@ -295,7 +303,7 @@ const chartOptions = computed(() => { }), style: { fontFamily }, }, - colors: [getProjectPrimaryColor() ?? config.config?.color ?? '#2178b5'], + colors: [chartColor.value], fill: { type: 'gradient', gradient: { diff --git a/src/views/base/home/composables/useBanners.ts b/src/views/base/home/composables/useBanners.ts index a2fda5b..40cc833 100644 --- a/src/views/base/home/composables/useBanners.ts +++ b/src/views/base/home/composables/useBanners.ts @@ -1,5 +1,6 @@ import { ref } from 'vue' import { getConstByKey } from '@/api/const' +import { useSettingsStore } from '@/store/settingsStore' function parseJsonArray(raw: unknown): unknown[] { if (raw == null || raw === '') { @@ -30,6 +31,13 @@ let bannersPromise: Promise | null = null let bannersLoaded = false async function fetchBanners(force = false) { + const settingsStore = useSettingsStore() + if (!settingsStore.isSettingTruthy('banner_enabled')) { + banners.value = [] + bannersLoaded = true + return + } + if (!force && bannersLoaded) { return }