fix(admin): 按 Art Design Pro 源码校准明暗主题与默认设置
This commit is contained in:
@@ -389,18 +389,24 @@ function readChartSkin() {
|
||||
const css = getComputedStyle(root)
|
||||
const token = (key: string, fallback: string) => css.getPropertyValue('--zyt-' + key).trim() || fallback
|
||||
return {
|
||||
primary: token('primary', '#15775e'),
|
||||
text: token('muted', '#667b71'),
|
||||
primary: token('primary', '#5D87FF'),
|
||||
first: css.getPropertyValue('--el-color-primary-light-1').trim(),
|
||||
barTop: css.getPropertyValue('--el-color-primary-light-4').trim(),
|
||||
text: token('muted', '#7987a1'),
|
||||
surface: token('surface', '#ffffff'),
|
||||
border: token('border', '#dce6e1'),
|
||||
border: token('border', '#e2e8ee'),
|
||||
dark: root.classList.contains('dark')
|
||||
}
|
||||
}
|
||||
const skin = ref(readChartSkin())
|
||||
useMutationObserver(root, () => { skin.value = readChartSkin() }, {
|
||||
attributes: true, attributeFilter: ['data-admin-ui', 'class']
|
||||
attributes: true, attributeFilter: ['data-admin-ui', 'class', 'style']
|
||||
})
|
||||
const chartPrimary = computed(() => skin.value?.primary ?? settingStore.theme)
|
||||
// Art's chart series start on the adaptive Element Plus scale, not --art-primary.
|
||||
const chartPrimary = computed(() => skin.value?.first || skin.value?.primary || settingStore.theme)
|
||||
const artSeriesColors = computed(() => [
|
||||
chartPrimary.value, '#4ABEFF', '#EDF2FF', '#14DEBA', '#FFAF20', '#FA8A6C', '#FFAF20'
|
||||
])
|
||||
const chartTheme = computed(() => {
|
||||
const s = skin.value
|
||||
if (!s) return undefined
|
||||
@@ -415,7 +421,6 @@ const chartTheme = computed(() => {
|
||||
tooltip: { backgroundColor: s.surface, borderColor: s.border, textStyle: { color: s.text } }
|
||||
}
|
||||
})
|
||||
const jadePieColors = ['#168364', '#5987b0', '#d09b50', '#8779ad', '#58aa9a', '#bd7787', '#96994c', '#617282']
|
||||
const pieColors = ['#5b7cfa', '#36cfc9', '#ffc53d', '#ff7a45', '#b37feb', '#597ef7', '#73d13d', '#ff85c0']
|
||||
|
||||
function parseAmount(v: unknown): number {
|
||||
@@ -449,7 +454,7 @@ const assistantDeptPieOption = computed(() => {
|
||||
.filter((d: any) => Number(d.total) > 0)
|
||||
.map((d: any) => ({ name: d.dept_name || '—', value: Number(d.total) }))
|
||||
return {
|
||||
color: skin.value ? jadePieColors : pieColors,
|
||||
color: skin.value ? artSeriesColors.value : pieColors,
|
||||
tooltip: { trigger: 'item', formatter: '{b}<br/>{c} 单 ({d}%)' },
|
||||
legend: { type: 'scroll', bottom: 0, textStyle: { fontSize: 11 } },
|
||||
series: [
|
||||
@@ -469,14 +474,15 @@ const assistantDeptPieOption = computed(() => {
|
||||
|
||||
const assistantChartOption = computed(() => {
|
||||
const theme = chartPrimary.value
|
||||
const trend = skin.value ? artSeriesColors.value[1] : '#f0b429'
|
||||
const barSeries = (assistantStats.chart.series || []).map((s: any) => ({
|
||||
...s,
|
||||
name: s.name || '诊单数',
|
||||
type: 'bar',
|
||||
barWidth: '46%',
|
||||
itemStyle: {
|
||||
borderRadius: [8, 8, 0, 0],
|
||||
color: {
|
||||
borderRadius: skin.value ? [4, 4, 0, 0] : [8, 8, 0, 0],
|
||||
color: skin.value ? theme : {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
@@ -491,7 +497,7 @@ const assistantChartOption = computed(() => {
|
||||
}))
|
||||
const lineData = (barSeries[0] as any)?.data || []
|
||||
return {
|
||||
color: [theme, '#f0b429'],
|
||||
color: [theme, trend],
|
||||
legend: { data: ['诊单数', '趋势'], top: 4 },
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
@@ -514,8 +520,8 @@ const assistantChartOption = computed(() => {
|
||||
smooth: 0.35,
|
||||
symbol: 'circle',
|
||||
symbolSize: 7,
|
||||
lineStyle: { width: 3, color: '#f0b429' },
|
||||
itemStyle: { color: '#f0b429' },
|
||||
lineStyle: { width: 3, color: trend },
|
||||
itemStyle: { color: trend },
|
||||
data: lineData
|
||||
}
|
||||
]
|
||||
@@ -560,7 +566,7 @@ const orderDeptCountPieOption = computed(() => {
|
||||
.filter((d: any) => Number(d.total) > 0)
|
||||
.map((d: any) => ({ name: d.dept_name || '—', value: Number(d.total) }))
|
||||
return {
|
||||
color: skin.value ? jadePieColors : pieColors,
|
||||
color: skin.value ? artSeriesColors.value : pieColors,
|
||||
tooltip: { trigger: 'item', formatter: '{b}<br/>{c} 单 ({d}%)' },
|
||||
legend: { type: 'scroll', bottom: 0, textStyle: { fontSize: 11 } },
|
||||
series: [
|
||||
@@ -582,7 +588,7 @@ const orderDeptAmountPieOption = computed(() => {
|
||||
.map((d: any) => ({ name: d.dept_name || '—', value: parseAmount(d.amount) }))
|
||||
.filter((d) => d.value > 0)
|
||||
return {
|
||||
color: skin.value ? jadePieColors : pieColors,
|
||||
color: skin.value ? artSeriesColors.value : pieColors,
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: (p: any) => {
|
||||
@@ -625,14 +631,15 @@ function formatDate(d: Date) {
|
||||
|
||||
const orderChartOption = computed(() => {
|
||||
const theme = chartPrimary.value
|
||||
const trend = skin.value ? artSeriesColors.value[1] : '#fa8c16'
|
||||
const barSeries = (orderStatsData.chart?.series || []).map((s: any) => ({
|
||||
...s,
|
||||
name: s.name || '单数',
|
||||
type: 'bar',
|
||||
barWidth: '46%',
|
||||
itemStyle: {
|
||||
borderRadius: [8, 8, 0, 0],
|
||||
color: {
|
||||
borderRadius: skin.value ? [4, 4, 0, 0] : [8, 8, 0, 0],
|
||||
color: skin.value ? theme : {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
@@ -647,7 +654,7 @@ const orderChartOption = computed(() => {
|
||||
}))
|
||||
const lineData = (barSeries[0] as any)?.data || []
|
||||
return {
|
||||
color: [theme, '#fa8c16'],
|
||||
color: [theme, trend],
|
||||
legend: { data: ['单数', '趋势'], top: 4 },
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
@@ -670,8 +677,8 @@ const orderChartOption = computed(() => {
|
||||
smooth: 0.35,
|
||||
symbol: 'circle',
|
||||
symbolSize: 7,
|
||||
lineStyle: { width: 3, color: '#fa8c16' },
|
||||
itemStyle: { color: '#fa8c16' },
|
||||
lineStyle: { width: 3, color: trend },
|
||||
itemStyle: { color: trend },
|
||||
data: lineData
|
||||
}
|
||||
]
|
||||
@@ -702,12 +709,31 @@ const refreshAll = () => {
|
||||
}
|
||||
|
||||
watch(
|
||||
chartPrimary,
|
||||
[chartPrimary, () => skin.value?.dark],
|
||||
() => {
|
||||
updateColor()
|
||||
}
|
||||
)
|
||||
|
||||
function visitorAreaStops() {
|
||||
const t = chartPrimary.value
|
||||
return [
|
||||
{ offset: 0, color: skin.value ? calcColor(t, 0.2) : t },
|
||||
{ offset: 1, color: skin.value ? calcColor(t, 0.02) : t }
|
||||
]
|
||||
}
|
||||
function salesBarStops() {
|
||||
const t = chartPrimary.value
|
||||
return [
|
||||
{ offset: 0, color: skin.value ? skin.value.barTop || t : calcColor(t, 0.65) },
|
||||
{ offset: 1, color: skin.value?.primary ?? t }
|
||||
]
|
||||
}
|
||||
const lowSalesColor = computed(() => skin.value ? artSeriesColors.value[4] : {
|
||||
type: 'linear', x: 0, y: 0, x2: 0, y2: 1,
|
||||
colorStops: [{ offset: 0, color: calcColor('#ff8729', 0.7) }, { offset: 1, color: '#ff8729' }]
|
||||
})
|
||||
|
||||
const workbenchData: any = reactive({
|
||||
version: {
|
||||
version: '',
|
||||
@@ -741,12 +767,9 @@ const workbenchData: any = reactive({
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{ offset: 0, color: chartPrimary.value },
|
||||
{ offset: 1, color: chartPrimary.value }
|
||||
]
|
||||
colorStops: visitorAreaStops()
|
||||
},
|
||||
opacity: 0.12
|
||||
opacity: skin.value ? 1 : 0.12
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -772,10 +795,7 @@ const workbenchData: any = reactive({
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{ offset: 0, color: calcColor(chartPrimary.value, 0.65) },
|
||||
{ offset: 1, color: chartPrimary.value }
|
||||
]
|
||||
colorStops: salesBarStops()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -811,19 +831,7 @@ const getData = () => {
|
||||
if (item <= 50) {
|
||||
v = {
|
||||
value: item,
|
||||
itemStyle: {
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{ offset: 0, color: calcColor('#ff8729', 0.7) },
|
||||
{ offset: 1, color: '#ff8729' }
|
||||
]
|
||||
}
|
||||
}
|
||||
itemStyle: { color: lowSalesColor }
|
||||
}
|
||||
}
|
||||
workbenchData.saleOption.series[0].data.push(v)
|
||||
@@ -838,14 +846,9 @@ const updateColor = () => {
|
||||
const t = chartPrimary.value
|
||||
workbenchData.visitorOption.series[0].color = t
|
||||
workbenchData.visitorOption.series[0].lineStyle.color = t
|
||||
workbenchData.visitorOption.series[0].areaStyle.color.colorStops = [
|
||||
{ offset: 0, color: t },
|
||||
{ offset: 1, color: t }
|
||||
]
|
||||
workbenchData.saleOption.series[0].itemStyle.color.colorStops = [
|
||||
{ offset: 0, color: calcColor(t, 0.65) },
|
||||
{ offset: 1, color: t }
|
||||
]
|
||||
workbenchData.visitorOption.series[0].areaStyle.color.colorStops = visitorAreaStops()
|
||||
workbenchData.visitorOption.series[0].areaStyle.opacity = skin.value ? 1 : 0.12
|
||||
workbenchData.saleOption.series[0].itemStyle.color.colorStops = salesBarStops()
|
||||
|
||||
saleChart.value?.clear()
|
||||
visitorChart.value?.clear()
|
||||
@@ -1304,27 +1307,28 @@ html[data-admin-ui="v2"] .workbench-page {
|
||||
.wb-hero-desc { color: var(--zyt-muted); font-size: 13px; }
|
||||
.wb-refresh-btn { box-shadow: none; border-radius: 8px; }
|
||||
.wb-section {
|
||||
margin-bottom: 16px;
|
||||
border: 1px solid var(--zyt-border);
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid var(--zyt-card-border);
|
||||
border-image: none;
|
||||
border-radius: var(--zyt-radius);
|
||||
border-radius: 16px;
|
||||
background: var(--zyt-surface);
|
||||
box-shadow: var(--zyt-shadow);
|
||||
box-shadow: none;
|
||||
backdrop-filter: none;
|
||||
}
|
||||
.wb-section-head {
|
||||
padding: 14px 20px;
|
||||
padding: 20px 20px 4px;
|
||||
background: none;
|
||||
border-color: var(--zyt-border);
|
||||
border: 0;
|
||||
}
|
||||
.wb-section-title { gap: 10px; }
|
||||
.wb-section-icon {
|
||||
width: 36px; height: 36px; border-radius: 10px; font-size: 19px;
|
||||
width: 40px; height: 40px; border-radius: 8px; font-size: 20px;
|
||||
color: var(--zyt-primary); background: var(--zyt-accent-soft); box-shadow: none;
|
||||
}
|
||||
.wb-section-name, .wb-chart-title, .wb-dept-title, .wb-ranking-name,
|
||||
.wb-dept-card-head, .wb-dept-num, .wb-ranking-money { color: var(--zyt-ink); }
|
||||
.wb-section-name { font-size: 16px; }
|
||||
.wb-section-name { font-size: 18px; font-weight: 500; }
|
||||
.wb-section-sub { margin-top: 4px; font-size: 14px; }
|
||||
.wb-section-sub, .wb-chart-hint, .wb-rank-strip-label, .wb-rank-empty, .wb-kpi-hint,
|
||||
.wb-dept-total, .wb-dept-num small, .wb-dept-empty, .wb-ranking-meta,
|
||||
.wb-rank-chip--dense small { color: var(--zyt-muted); }
|
||||
@@ -1332,27 +1336,25 @@ html[data-admin-ui="v2"] .workbench-page {
|
||||
.wb-section-body { padding: 16px 20px 20px; }
|
||||
.wb-kpi-row, .wb-chart-row, .wb-trend-body > .el-row { row-gap: 12px; }
|
||||
.wb-kpi, .wb-rank-strip {
|
||||
min-height: 100px; padding: 15px 18px; border-radius: 10px;
|
||||
background: var(--zyt-surface-subtle); border: 1px solid var(--zyt-border);
|
||||
min-height: 100px; padding: 16px 20px; border-radius: 12px;
|
||||
background: var(--zyt-surface); border: 1px solid var(--zyt-border);
|
||||
}
|
||||
.wb-kpi { display: flex; flex-direction: column; justify-content: center; }
|
||||
.wb-kpi-label { color: var(--zyt-text); }
|
||||
.wb-kpi-value { color: var(--zyt-ink); font-weight: 650; overflow-wrap: anywhere; }
|
||||
.wb-kpi--amber { background: var(--zyt-accent-soft); }
|
||||
.wb-kpi--amber .wb-kpi-value { color: var(--zyt-primary); }
|
||||
.wb-kpi-value { color: var(--zyt-ink); font-size: 26px; font-weight: 500; overflow-wrap: anywhere; }
|
||||
.wb-rank-chip {
|
||||
color: var(--zyt-text); border-color: var(--zyt-border); background: var(--zyt-surface); box-shadow: none;
|
||||
em, strong { color: var(--zyt-primary); }
|
||||
}
|
||||
.wb-chart-card {
|
||||
border: 1px solid var(--zyt-border); border-radius: 10px;
|
||||
border: 1px solid var(--zyt-card-border); border-radius: 12px;
|
||||
padding: 12px 14px 6px; background: var(--zyt-surface);
|
||||
}
|
||||
.wb-chart-card-head { align-items: center; gap: 8px; margin-bottom: 8px; }
|
||||
.wb-chart-title { font-size: 14px; }
|
||||
.wb-chart-title { font-size: 16px; font-weight: 500; }
|
||||
.wb-dept-block { border-color: var(--zyt-border); }
|
||||
.wb-dept-card, .wb-ranking-item {
|
||||
background: var(--zyt-surface-subtle); border-color: var(--zyt-border); box-shadow: none;
|
||||
background: var(--zyt-surface); border-color: var(--zyt-card-border); box-shadow: none;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.wb-ranking-item { margin-bottom: 5px; padding: 7px 10px; }
|
||||
|
||||
Reference in New Issue
Block a user