fixed dashboard in night mode

This commit is contained in:
2026-06-21 22:15:17 +03:30
parent 87da74a51b
commit c3abeeecef
4 changed files with 360 additions and 75 deletions
@@ -25,6 +25,7 @@ import { usePrice } from '@core/utils/usePrice'
import { toJalali } from '@core/utils/useDataTime'
import { isMobile } from '@core/utils/is'
import { isStoreApp } from '@/utils/config'
import { useAdminTheme } from '@core/composable/useAdminTheme'
function truncateChartLabel(label: string, maxLen: number) {
const text = String(label ?? '').trim()
@@ -66,6 +67,7 @@ function productActivityDateRange(range: ProductActivityRange) {
}
export function useDashboardPage() {
const { isDark } = useAdminTheme()
const loading = ref(true)
const flowLoading = ref(false)
const productActivityLoading = ref(false)
@@ -235,20 +237,31 @@ export function useDashboardPage() {
return direction === 1 ? 'خرید' : direction === 2 ? 'فروش' : '—'
}
function chartSurfaceOptions() {
const dark = isDark.value
const labelColor = dark ? 'rgba(255,255,255,0.55)' : 'rgba(0,0,0,0.55)'
const gridColor = dark ? 'rgba(255,255,255,0.12)' : 'rgba(0,0,0,0.08)'
return {
theme: { mode: dark ? 'dark' as const : 'light' as const },
chart: { foreColor: labelColor },
grid: { borderColor: gridColor },
xaxis: { labels: { style: { colors: labelColor } } },
yaxis: { labels: { style: { colors: labelColor } } },
legend: { labels: { colors: labelColor } },
}
}
function directionClass(direction?: number) {
return direction === 1
? 'bg-emerald-100 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-300'
: 'bg-rose-100 text-rose-700 dark:bg-rose-500/20 dark:text-rose-300'
if (direction === 1) return 'dashboard-badge dashboard-badge--buy rounded-md px-2 py-0.5 text-xs'
if (direction === 2) return 'dashboard-badge dashboard-badge--sell rounded-md px-2 py-0.5 text-xs'
return 'dashboard-badge rounded-md px-2 py-0.5 text-xs'
}
function stsClass(sts?: number) {
if (sts === 2) {
return 'bg-emerald-100 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-300'
}
if (sts === 1) {
return 'bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300'
}
return 'bg-rose-100 text-rose-700 dark:bg-rose-500/20 dark:text-rose-300'
if (sts === 2) return 'dashboard-badge dashboard-badge--ok rounded-md px-2 py-0.5 text-xs'
if (sts === 1) return 'dashboard-badge dashboard-badge--open rounded-md px-2 py-0.5 text-xs'
return 'dashboard-badge dashboard-badge--fail rounded-md px-2 py-0.5 text-xs'
}
function stsLabel(order: Order) {
@@ -262,7 +275,8 @@ export function useDashboardPage() {
const gifts = finance.value?.GiftsPrise ?? 0
return {
chart: { type: 'donut', fontFamily: 'inherit', offsetY: 4 },
...chartSurfaceOptions(),
chart: { type: 'donut', fontFamily: 'inherit', offsetY: 4, foreColor: chartSurfaceOptions().chart.foreColor },
labels: ['سود معامله', 'کارمزد طلایی', 'هدایای طلا'],
colors: ['#10b981', '#f59e0b', '#8b5cf6'],
legend: {
@@ -297,6 +311,7 @@ export function useDashboardPage() {
const flowChartOptions = computed(() => {
const mobile = isMobile.value
const surface = chartSurfaceOptions()
const points = [...flowData.value].sort((a, b) =>
String(a.date ?? '').localeCompare(String(b.date ?? '')),
)
@@ -306,12 +321,14 @@ export function useDashboardPage() {
})
return {
...surface,
chart: {
type: 'bar',
stacked: true,
toolbar: { show: false },
fontFamily: 'inherit',
redrawOnParentResize: true,
foreColor: surface.chart.foreColor,
},
plotOptions: { bar: { borderRadius: 4, columnWidth: mobile ? '48%' : '55%' } },
colors: ['#10b981', '#f43f5e'],
@@ -352,7 +369,14 @@ export function useDashboardPage() {
priceRange.value === 'DAILY' ? 'yyyy/MM/dd HH:mm' : 'yyyy/MM/dd'
return {
chart: { type: 'area', toolbar: { show: false }, fontFamily: 'inherit', zoom: { enabled: false } },
...chartSurfaceOptions(),
chart: {
type: 'area',
toolbar: { show: false },
fontFamily: 'inherit',
zoom: { enabled: false },
foreColor: chartSurfaceOptions().chart.foreColor,
},
stroke: { curve: 'smooth', width: 2 },
fill: {
type: 'gradient',
@@ -408,12 +432,14 @@ export function useDashboardPage() {
const categories = slots.map((slot) => formatPeakHourLabel(slot.hour))
return {
...chartSurfaceOptions(),
chart: {
type: 'bar',
stacked: true,
toolbar: { show: false },
fontFamily: 'inherit',
redrawOnParentResize: true,
foreColor: chartSurfaceOptions().chart.foreColor,
},
plotOptions: {
bar: {
@@ -481,11 +507,13 @@ export function useDashboardPage() {
mobile ? truncateChartLabel(String(val), 11) : String(val)
return {
...chartSurfaceOptions(),
chart: {
type: 'bar',
toolbar: { show: false },
fontFamily: 'inherit',
redrawOnParentResize: true,
foreColor: chartSurfaceOptions().chart.foreColor,
},
plotOptions: {
bar: {