fix(admin): 按 Art Design Pro 源码校准明暗主题与默认设置

This commit is contained in:
2026-12-01 16:40:54 +08:00
parent 9024e4b287
commit e1681f8d13
15 changed files with 547 additions and 363 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
<template><span class="preview-identity" title="仅使用本机生成的演示数据,不连接业务后台"><i aria-hidden="true"></i>本地只读<span>预览</span></span></template>
<style scoped>.preview-identity{display:inline-flex;align-items:center;gap:3px;font-size:12px;color:var(--el-text-color-regular);white-space:nowrap}.preview-identity i{width:7px;height:7px;background:#1b916b;border-radius:50%;margin-right:4px}@media(max-width:520px){.preview-identity span{display:none}}</style>
<style scoped>.preview-identity{display:inline-flex;align-items:center;gap:3px;font-size:12px;color:var(--el-text-color-regular);white-space:nowrap}.preview-identity i{width:7px;height:7px;background:#1b916b;border-radius:50%;margin-right:4px}html[data-admin-ui='v2'] .preview-identity i{background:var(--el-color-primary)}@media(max-width:520px){.preview-identity span{display:none}}</style>
+2
View File
@@ -15,3 +15,5 @@ node local-preview/build.mjs && node local-preview/server.mjs 5178
本机若用 macOS 会话任务启动本分支的预览,可用 `launchctl list local.zyt.theme-preview.bfc2` 查看、`launchctl remove local.zyt.theme-preview.bfc2` 停止;停止预览不影响其他应用。未安装开机启动项。
验证:`node --test local-preview/fixtures.test.mjs` 检查模拟数据;服务运行后 `node local-preview/verify-http.mjs` 复核写入、代理、跨域等均被拒绝。可选的 `browser_smoke.py` 使用 Python Playwright 和本地 Chromium,只允许本机请求。
`verify-art-parameters.py --chrome <Chromium可执行文件> --out <截图目录>` 对照固定的 Art Design Pro 默认参数,测量实际渲染的亮色、暗色和经典外观,并保存对应截图和 computed.json。该验收同样只访问回环地址。
+4 -4
View File
@@ -1,12 +1,12 @@
<template><el-config-provider :locale="zhCn"><router-view /></el-config-provider></template>
<script setup lang="ts">
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import { useDark, useWindowSize } from '@vueuse/core'
import { useWindowSize } from '@vueuse/core'
import useAppStore from '@/stores/modules/app'
import useSettingStore from '@/stores/modules/setting'
import { useAdminDark } from '@/stores/modules/setting'
import { ScreenEnum } from '@/enums/appEnums'
const app = useAppStore(), settings = useSettingStore(), dark = useDark()
const app = useAppStore()
useAdminDark()
const { width } = useWindowSize()
watch(dark, v => settings.setTheme(v), { immediate: true })
watch(width, w => { app.setMobile(w <= ScreenEnum.SM); app.toggleCollapsed(w < ScreenEnum.MD) }, { immediate: true })
</script>
+7 -4
View File
@@ -3,7 +3,7 @@ import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import '@/styles/index.scss'
import '@/install/plugins/echart'
import { createApp } from 'vue'
import { createApp, watch } from 'vue'
import ElementPlus from 'element-plus'
import installIcons from '@/install/plugins/element'
import perms from '@/install/directives/perms'
@@ -14,11 +14,14 @@ import useTabsStore from '@/stores/modules/multipleTabs'
import useSettingStore from '@/stores/modules/setting'
import Root from './Root.vue'
import router, { pages } from './router'
import logo from './preview-mark.svg'
import classicLogo from './preview-mark.svg'
import artLogo from './preview-mark-art.svg'
const app = createApp(Root)
app.use(store); app.use(ElementPlus); installIcons(app); app.directive('perms', perms)
useUserStore().$patch({ token: '', userInfo: { name: '本地预览', role_ids: [] }, perms: ['order.order/lists','order.order/detail'], routes: pages.map(({ path, name, meta }) => ({ path, name, meta })) as any })
useAppStore().$patch({ configFetchAttempted: true, config: { web_name: '甄养堂', web_logo: logo } })
useSettingStore().$patch({ showLogo: true })
const appState = useAppStore(), settings = useSettingStore()
appState.$patch({ configFetchAttempted: true, config: { web_name: '甄养堂' } })
settings.$patch({ showLogo: true })
watch(() => settings.adminUi, mode => { appState.config.web_logo = mode === 'v2' ? artLogo : classicLogo }, { immediate: true })
useTabsStore().setRouteName('preview-workbench')
app.use(router); router.isReady().then(() => app.mount('#app'))
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><rect x="1" y="1" width="38" height="38" rx="11" fill="#5D87FF"/><path d="M10 26c0-11 6-17 20-17 0 13-6 20-17 19m0-2 13-13m-8 8v-5m2 3h5" fill="none" stroke="#FFFFFF" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.9"/></svg>

After

Width:  |  Height:  |  Size: 301 B

@@ -0,0 +1,66 @@
"""Compare rendered elements, not just declared CSS tokens, to Art Design Pro f3aaf58."""
import argparse
import json
import re
from pathlib import Path
from playwright.sync_api import expect, sync_playwright
parser = argparse.ArgumentParser()
parser.add_argument('--out', type=Path, required=True)
parser.add_argument('--chrome', required=True)
parser.add_argument('--record-only', action='store_true', help='record the pre-correction build without asserting parity')
a = parser.parse_args()
a.out.mkdir(exist_ok=True, parents=True)
origin = 'http://127.0.0.1:5178/'
read_colors = """() => {
const style = (sel) => getComputedStyle(document.querySelector(sel));
const sample = (sel, key) => {
const value = style(sel)[key];
// Canvas normalises srgb color-mix / rgb / hex to the actual 8-bit pixel color.
const ctx=document.createElement('canvas').getContext('2d');ctx.fillStyle=value;ctx.fillRect(0,0,1,1);
return '#' + [...ctx.getImageData(0,0,1,1).data].slice(0,3).map(x=>x.toString(16).padStart(2,'0')).join('').toUpperCase();
};
const bg=sel=>sample(sel,'backgroundColor');
return {primaryButton:bg('.wb-refresh-btn'), page:bg('.main-wrap'),sidebar:bg('.side'),
sidebarWidth:Math.round(document.querySelector('.app-aside').getBoundingClientRect().width),
activeItem:bg('.menu .el-menu-item.is-active'),activeText:sample('.menu .el-menu-item.is-active span','color'),
card:bg('.wb-section'),cardRadius:style('.wb-section').borderTopLeftRadius,cardBorder:style('.wb-section').borderTopColor,
cardShadow:style('.wb-section').boxShadow, buttonHeight:style('.wb-refresh-btn').height,
menuItemHeight:style('.menu .el-menu-item.is-active').height,
selectedColorToken:getComputedStyle(document.documentElement).getPropertyValue('--el-color-primary-light-9').trim()};
}"""
modes = {}; external=[]; palette=[]
with sync_playwright() as pw:
browser=pw.chromium.launch(executable_path=a.chrome,args=['--disable-background-networking','--no-proxy-server','--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1'])
ctx=browser.new_context(viewport={'width':1440,'height':960},color_scheme='light',service_workers='block')
def local(route):
if route.request.url.startswith(origin): return route.continue_()
external.append(route.request.url); return route.abort()
ctx.route('**/*',local); page=ctx.new_page(); page.goto(origin+'admin/workbench',wait_until='networkidle'); expect(page.locator('.wb-refresh-btn')).to_be_visible()
for mode in ['light','dark','classic']:
if mode=='dark': page.emulate_media(color_scheme='dark'); expect(page.locator('html')).to_have_class(re.compile('dark'))
if mode=='classic':
page.emulate_media(color_scheme='light'); page.locator('[data-admin-ui-toggle]').click(); expect(page.locator('html')).to_have_attribute('data-admin-ui','legacy')
page.mouse.move(1430,950); page.wait_for_timeout(350)
modes[mode]=page.evaluate(read_colors); page.screenshot(path=str(a.out/(mode+'.png')))
if not a.record_only:
page.locator('[data-admin-ui-toggle]').click(); page.locator('.navbar .setting').click()
drawer=page.locator('.setting-drawer .el-drawer:visible, .el-drawer:visible').last
expect(drawer.get_by_role('button',name='设计菜单')).to_have_attribute('aria-pressed','true')
expect(drawer.get_by_role('spinbutton').first).to_have_value('230')
drawer.locator('.el-color-picker').click()
swatches=page.locator('.el-color-predefine__color-selector:visible'); expect(swatches).to_have_count(7)
palette=swatches.evaluate_all("els => els.map(e => {const c=getComputedStyle(e.querySelector('div')).backgroundColor.match(/\\d+/g);return '#'+c.slice(0,3).map(v=>(+v).toString(16).padStart(2,'0')).join('').toUpperCase()})")
assert palette == ['#5D87FF','#B48DF3','#1D84FF','#60C041','#38C0FC','#F9901F','#FF80C8'],palette
swatches.nth(1).click(); page.locator('.el-color-picker__panel:visible, .el-color-picker-panel:visible').last.get_by_role('button',name=re.compile('确定|确认')).click()
expect(page.locator('.wb-refresh-btn')).to_have_css('background-color','rgb(180, 141, 243)')
drawer.get_by_role('button',name='重置主题').click(); expect(page.locator('.wb-refresh-btn')).to_have_css('background-color','rgb(93, 135, 255)')
browser.close()
report={'upstream':'f3aaf58eec1a0e988f162352c33862327a484f95','actual':modes,'settings_palette':palette,'external_requests':external}
(a.out/'computed.json').write_text(json.dumps(report,indent=2,ensure_ascii=False)+'\n'); print(json.dumps(report,ensure_ascii=False)); assert not external
if not a.record_only:
expected={'light':{'primaryButton':'#5D87FF','page':'#FAFBFC','sidebar':'#FFFFFF','activeItem':'#EEF3FF','activeText':'#5D87FF','card':'#FFFFFF','menuItemHeight':'42px','buttonHeight':'36px','cardRadius':'16px','cardBorder':'rgba(0, 0, 0, 0.08)','cardShadow':'none'}, 'dark':{'primaryButton':'#5D87FF','page':'#070707','sidebar':'#161618','activeItem':'#27282D','activeText':'#5D87FF','card':'#161618'}, 'classic':{'primaryButton':'#4A5DFF','sidebar':'#1D2124'}}
for mode,checks in expected.items():
for k,v in checks.items(): assert modes[mode][k]==v,(mode,k,v,modes[mode][k])
assert modes['light']['sidebarWidth'] in (230,231),modes['light']['sidebarWidth'] # pane + optional one-pixel boundary
print('PASS: Art theme parameters match rendered controls; classic appearance preserved.')
+4 -12
View File
@@ -1,20 +1,19 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { useDark, useThrottleFn, useWindowSize } from '@vueuse/core'
import { useThrottleFn, useWindowSize } from '@vueuse/core'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import { ScreenEnum } from './enums/appEnums'
import useAppStore from './stores/modules/app'
import useSettingStore, { useAdminAppearanceStore } from './stores/modules/setting'
import { useAdminDark } from './stores/modules/setting'
import useUserStore from './stores/modules/user'
import ChatNotifyToast from './components/chat-notify-toast/index.vue'
import RevisitDueToast from './components/revisit-due-toast/index.vue'
const appStore = useAppStore()
const settingStore = useSettingStore()
// Resolve the saved appearance before the first route (including login) renders.
useAdminAppearanceStore()
// Resolve the saved appearance, system mode and palette before routes render.
useAdminDark()
const userStore = useUserStore()
const route = useRoute()
@@ -29,13 +28,6 @@ const elConfig = {
zIndex: 2000,
locale: zhCn
}
const isDark = useDark()
onMounted(async () => {
console.log('主题颜色',isDark.value)
//设置主题色
settingStore.setTheme(isDark.value)
})
const { width } = useWindowSize()
watch(
width,
@@ -10,14 +10,19 @@
<div class="h-full flex flex-col">
<div class="setting-item mb-5">
<span class="text-tx-secondary">风格设置</span>
<div class="flex mt-4 cursor-pointer">
<div v-if="settingStore.adminUi === 'v2'" class="art-menu-options" role="group" aria-label="菜单风格">
<button v-for="item in artMenuThemes" :key="item.value" type="button"
:aria-label="item.label + '菜单'" :aria-pressed="sideTheme === item.value"
@click="sideTheme = item.value">{{ item.label }}</button>
</div>
<div v-else class="flex mt-4 cursor-pointer">
<div
class="mr-4 flex relative text-primary"
v-for="item in sideThemeList"
:key="item.type"
@click="sideTheme = item.type"
>
<img :src="item.image" width="52" height="36" />
<img :src="item.image" :alt="item.type === 'dark' ? '深色菜单' : '浅色菜单'" width="52" height="36" />
<icon
v-if="sideTheme == item.type"
class="icon-select"
@@ -93,14 +98,16 @@
</template>
<script setup lang="ts">
import { useDark, useToggle } from '@vueuse/core'
import theme_dark from '@/assets/images/theme_black.png'
import theme_light from '@/assets/images/theme_white.png'
import useSettingStore from '@/stores/modules/setting'
import useSettingStore, { artMainColors, useAdminDark } from '@/stores/modules/setting'
const settingStore = useSettingStore()
const predefineColors = ref(['#409EFF', '#28C76F', '#EA5455', '#FF9F43', '#01CFE8', '#4A5DFF'])
const predefineColors = computed(() => settingStore.adminUi === 'v2' ? artMainColors :
['#409EFF', '#28C76F', '#EA5455', '#FF9F43', '#01CFE8', '#4A5DFF'])
const artMenuThemes = [
{ value: 'design', label: '设计' }, { value: 'dark', label: '深色' }, { value: 'light', label: '浅色' }
]
const sideThemeList = [
{
type: 'dark',
@@ -177,9 +184,8 @@ const theme = computed({
set(value) {
settingStore.setSetting({
key: 'theme',
value
value: value || (settingStore.adminUi === 'v2' ? artMainColors[0] : settingStore.theme)
})
themeChange()
}
})
@@ -207,19 +213,11 @@ const showCrumb = computed({
}
})
const isDark = useDark()
const themeChange = () => {
settingStore.setTheme(isDark.value)
}
const toggleDark = () => {
useToggle(isDark)()
themeChange()
}
const isDark = useAdminDark()
const toggleDark = () => { isDark.value = !isDark.value }
const resetTheme = () => {
isDark.value = false
if (settingStore.adminUi === 'legacy') isDark.value = false
settingStore.resetTheme()
themeChange()
}
</script>
@@ -1,7 +1,7 @@
<template>
<div
class="menu flex-1 min-h-0"
:class="themeClass"
:class="[themeClass, { 'menu--classic': classic }]"
:style="isCollapsed ? '' : `--aside-width: ${width}px`"
>
<el-scrollbar>
@@ -32,6 +32,7 @@ import type { RouteRecordRaw } from 'vue-router'
import MenuItem from './menu-item.vue'
const props = defineProps({
classic: { type: Boolean, default: true },
routes: {
type: Object as PropType<RouteRecordRaw[]>
},
@@ -64,7 +65,7 @@ const themeClass = computed(() => `theme-${props.theme}`)
<style lang="scss" scoped>
.menu {
&.theme-dark {
&.menu--classic.theme-dark {
.el-menu {
:deep(.el-menu-item) {
&.is-active {
@@ -78,7 +79,7 @@ const themeClass = computed(() => `theme-${props.theme}`)
}
}
}
&.theme-light {
&.menu--classic.theme-light {
:deep(.el-menu) {
.el-menu-item {
border-color: transparent;
@@ -1,5 +1,5 @@
<template>
<div class="side" :class="{ 'side--dark': sideTheme === 'dark' }" :style="sideStyle">
<div class="side" :class="'side--' + sideTheme" :style="sideStyle">
<side-logo v-if="settingStore.showLogo" :show-title="!isCollapsed" :theme="sideTheme" />
<div v-else-if="settingStore.adminUi === 'v2'" class="admin-nav-heading" aria-hidden="true">
<svg viewBox="0 0 24 24" fill="none" width="24" height="24">
@@ -15,13 +15,13 @@
:unique-opened="settingStore.isUniqueOpened"
:config="menuProp"
:theme="sideTheme"
:classic="settingStore.adminUi === 'legacy'"
@select="handleSelect"
/>
</div>
</template>
<script setup lang="ts">
import defaultSetting from '@/config/setting'
import useAppStore from '@/stores/modules/app'
import useSettingStore from '@/stores/modules/setting'
import useUserStore from '@/stores/modules/user'
@@ -44,16 +44,9 @@ const userStore = useUserStore()
const routes = computed(() => userStore.routes)
const sideStyle = computed(() => {
return sideTheme.value == 'dark'
? {
'--side-dark-color':
settingStore.adminUi === 'v2' && settingStore.sideDarkColor === defaultSetting.sideDarkColor
? 'var(--zyt-sidebar-dark)'
: settingStore.sideDarkColor
}
: ''
})
const sideStyle = computed(() => settingStore.adminUi === 'legacy' && sideTheme.value === 'dark'
? { '--side-dark-color': settingStore.sideDarkColor }
: undefined)
const menuProp = computed(() => {
// In v2 the root tokens also style the collapsed menu's teleported popup.
if (settingStore.adminUi === 'v2') return {}
+129 -76
View File
@@ -1,21 +1,34 @@
import { isObject } from '@vue/shared'
import { createSharedComposable, useDark, useStorage } from '@vueuse/core'
import { defineStore } from 'pinia'
import { computed, ref, watch } from 'vue'
import defaultSetting, {
SETTING_SCHEMA_MIGRATIONS,
SETTING_SCHEMA_VERSION
} from '@/config/setting'
import defaultSetting, { SETTING_SCHEMA_MIGRATIONS, SETTING_SCHEMA_VERSION } from '@/config/setting'
import { SETTING_KEY } from '@/enums/cacheEnums'
import cache from '@/utils/cache'
import { setTheme } from '@/utils/theme'
const storageSetting = cache.get(SETTING_KEY)
type AdminUi = 'legacy' | 'v2'
type ColorMode = 'auto' | 'dark' | 'light'
const APPEARANCE_KEY = 'admin_ui'
const ART_SETTING_KEY = 'admin_ui_v2_setting'
// Art Design Pro f3aaf58: config/index.ts and config/setting.ts.
export const artMainColors = ['#5D87FF', '#B48DF3', '#1D84FF', '#60C041', '#38C0FC', '#F9901F', '#FF80C8']
const artDefaults = {
...defaultSetting,
theme: artMainColors[0],
sideTheme: 'design',
sideDarkColor: '#191A23',
sideWidth: 230,
showLogo: true,
successTheme: '#13deb9',
warningTheme: '#ffae1f',
dangerTheme: '#ff4d4f',
errorTheme: '#fa896b',
colorMode: 'auto' as ColorMode
}
// A preview can seed <html data-admin-ui="v2"> before the first store is created.
// Its switch is local to that document; it never overwrites the normal entry's preference.
function initialAppearance() {
const root = document.documentElement
const preview = root.dataset.adminUi === 'v2'
@@ -24,7 +37,6 @@ function initialAppearance() {
return { preview, mode }
}
// Keep the new preference separate from the existing, versioned settings object.
export const useAdminAppearanceStore = defineStore('adminAppearance', {
state: initialAppearance,
actions: {
@@ -36,97 +48,138 @@ export const useAdminAppearanceStore = defineStore('adminAppearance', {
}
})
function applySettingSchemaMigrations(
state: Record<string, any>,
storedVersion: number
) {
if (storedVersion >= SETTING_SCHEMA_VERSION) return
for (let ver = storedVersion + 1; ver <= SETTING_SCHEMA_VERSION; ver++) {
const keys = SETTING_SCHEMA_MIGRATIONS[ver]
if (!keys) continue
for (const key of keys) {
state[key] = defaultSetting[key]
function loadLegacy(preview: boolean): Record<string, any> {
const stored = cache.get(SETTING_KEY)
const state: Record<string, any> = { ...defaultSetting, ...stored }
if (isObject(stored)) {
const version = Number(stored._settingSchemaVersion) || 0
for (let i = version + 1; i <= SETTING_SCHEMA_VERSION; i++) {
for (const key of SETTING_SCHEMA_MIGRATIONS[i] || []) state[key] = defaultSetting[key]
}
if (!preview && version < SETTING_SCHEMA_VERSION) {
cache.set(SETTING_KEY, { ...state, _settingSchemaVersion: SETTING_SCHEMA_VERSION })
}
}
state._settingSchemaVersion = SETTING_SCHEMA_VERSION
const { showDrawer, ...persist } = state
cache.set(SETTING_KEY, persist)
return { ...state, _settingSchemaVersion: SETTING_SCHEMA_VERSION }
}
function isHex(value: unknown): value is string {
return typeof value === 'string' && /^#[\da-f]{6}$/i.test(value)
}
function loadArt(legacy: Record<string, any>) {
const stored = cache.get(ART_SETTING_KEY)
// Only inherit an actual, non-default accent. The old dark menu / 183px width
// are classic preferences, not a selected Art menu style or sidebar size.
const inherited = isHex(legacy.theme) && legacy.theme.toLowerCase() !== defaultSetting.theme.toLowerCase()
? legacy.theme : artDefaults.theme
return { ...artDefaults, theme: inherited, ...(isObject(stored) ? stored : {}) }
}
function persistProfile(mode: AdminUi, state: Record<string, any>) {
// Only profile settings enter localStorage, never the drawer or the other profile.
const defaults = mode === 'v2' ? artDefaults : defaultSetting
const settings = Object.fromEntries(Object.keys(defaults).map(key => [key, state[key]]))
if (mode === 'legacy') settings._settingSchemaVersion = SETTING_SCHEMA_VERSION
cache.set(mode === 'v2' ? ART_SETTING_KEY : SETTING_KEY, settings)
}
// Upstream utils/ui/colors.ts floors each RGB channel. CSS color-mix and the
// classic theme helper round differently (notably light-9 and the dark ramp).
function artPalette(primary: string, isDark: boolean) {
const rgb = [1, 3, 5].map(i => parseInt(primary.slice(i, i + 2), 16))
const colorAt = (level: number, dark: boolean) => '#' + rgb.map(channel =>
Math.floor(dark ? channel * (1 - level) : (255 - channel) * level + channel)
.toString(16).padStart(2, '0')
).join('')
const vars: Record<string, string> = { '--el-color-primary': primary, '--el-color-primary-rgb': rgb.join(', ') }
for (let i = 1; i <= 9; i++) {
vars[`--el-color-primary-light-${i}`] = colorAt(i / 10, isDark)
vars[`--el-color-primary-dark-${i}`] = colorAt(i / 10, true)
}
// Preserve the upstream white on blue; avoid white-on-white for a custom near-white accent.
const luma = rgb[0] * .2126 + rgb[1] * .7152 + rgb[2] * .0722
vars['--zyt-on-primary'] = luma > 200 ? '#29343D' : '#fff'
vars['--zyt-selected-ink'] = !isDark && luma > 220 ? '#29343D' : primary
return vars
}
export const useSettingStore = defineStore({
id: 'setting',
state: () => {
const state: Record<string, any> = {
showDrawer: false,
...defaultSetting
const appearance = useAdminAppearanceStore()
const legacy = loadLegacy(appearance.preview)
const profiles: Record<AdminUi, Record<string, any>> = { legacy, v2: loadArt(legacy) }
return {
profiles, showDrawer: false, ...defaultSetting, colorMode: 'auto' as ColorMode,
...profiles[appearance.mode]
}
let storedVersion = SETTING_SCHEMA_VERSION
if (isObject(storageSetting)) {
storedVersion =
typeof (storageSetting as any)._settingSchemaVersion === 'number'
? (storageSetting as any)._settingSchemaVersion
: 0
Object.assign(state, storageSetting)
if (storedVersion < SETTING_SCHEMA_VERSION) {
applySettingSchemaMigrations(state, storedVersion)
}
}
state._settingSchemaVersion = SETTING_SCHEMA_VERSION
return state
},
getters: {
adminUi(): AdminUi {
return useAdminAppearanceStore().mode
}
adminUi(): AdminUi { return useAdminAppearanceStore().mode }
},
actions: {
toggleAdminUi() {
useAdminAppearanceStore().select(this.adminUi === 'v2' ? 'legacy' : 'v2')
const keys = Object.keys(this.adminUi === 'v2' ? artDefaults : defaultSetting) as (keyof typeof artDefaults)[]
this.profiles[this.adminUi] = Object.fromEntries(keys.map(key => [key, this.$state[key]]))
const mode = this.adminUi === 'v2' ? 'legacy' : 'v2'
this.$patch(this.profiles[mode])
useAdminAppearanceStore().select(mode)
},
// 设置布局设置
setSetting(data: Record<string, any>) {
const { key, value } = data
if (this.hasOwnProperty(key)) {
//@ts-ignore
this[key] = value
setSetting({ key, value }: { key: string; value: any }) {
if (!(key in this.$state) || key === 'profiles') return
this.$patch({ [key]: value })
if (key !== 'showDrawer' && !useAdminAppearanceStore().preview) {
persistProfile(this.adminUi, this.$state)
}
const settings: any = Object.assign({}, this.$state)
delete settings.showDrawer
settings._settingSchemaVersion = SETTING_SCHEMA_VERSION
cache.set(SETTING_KEY, settings)
},
// 设置主题色
setTheme(isDark: boolean) {
// An explicitly chosen accent is shared; the legacy default stays blue,
// while the v2 default is jade. Neither switch rewrites the color picker.
const rootStyle = document.documentElement.style
if (this.theme && this.theme !== defaultSetting.theme) {
rootStyle.setProperty('--zyt-user-primary', this.theme)
if (this.adminUi === 'v2') {
const vars = artPalette(isHex(this.theme) ? this.theme : artDefaults.theme, isDark)
// Separate, scoped sheet so leaving v2 instantly restores classic including poppers.
let style = document.getElementById('art-theme-vars')
if (!style) {
style = document.createElement('style')
style.id = 'art-theme-vars'
document.head.appendChild(style)
}
style.textContent = "html:root[data-admin-ui='v2']{" +
Object.entries(vars).map(([k,v]) => k + ':' + v).join(';') + '}'
} else {
rootStyle.removeProperty('--zyt-user-primary')
setTheme({
primary: this.theme, success: this.successTheme, warning: this.warningTheme,
danger: this.dangerTheme, error: this.errorTheme, info: this.infoTheme
}, isDark)
}
setTheme(
{
primary: this.theme,
success: this.successTheme,
warning: this.warningTheme,
danger: this.dangerTheme,
error: this.errorTheme,
info: this.infoTheme
},
isDark
)
},
resetTheme() {
for (const key in defaultSetting) {
//@ts-ignore
this[key] = defaultSetting[key]
if (this.adminUi === 'v2') {
this.$patch({ ...artDefaults })
if (!useAdminAppearanceStore().preview) persistProfile('v2', artDefaults)
} else {
this.$patch({ ...defaultSetting })
if (!useAdminAppearanceStore().preview) cache.remove(SETTING_KEY)
}
this._settingSchemaVersion = SETTING_SCHEMA_VERSION
cache.remove(SETTING_KEY)
useAdminAppearanceStore().select('legacy')
}
}
})
// A single system-dark listener / palette writer shared by the root and drawer.
// The old vueuse-color-scheme key remains the owner of the classic preference.
export const useAdminDark = createSharedComposable(() => {
const settings = useSettingStore()
const normalMode = useStorage<ColorMode>('vueuse-color-scheme', 'auto', undefined, { writeDefaults: false })
const classicMode = useAdminAppearanceStore().preview ? ref(normalMode.value) : normalMode
const storageRef = computed<ColorMode>({
get: () => settings.adminUi === 'v2' ? settings.colorMode : classicMode.value,
set(value) {
if (settings.adminUi === 'v2') settings.setSetting({ key: 'colorMode', value })
else classicMode.value = value
}
})
const dark = useDark({ storageRef })
watch([dark, () => settings.adminUi, () => settings.theme], () => settings.setTheme(dark.value), { immediate: true })
return dark
})
export default useSettingStore
+209 -154
View File
@@ -1,195 +1,250 @@
// Only the new appearance opts into these rules. Root scope also reaches
// Element Plus dialogs, selectors and collapsed menus teleported to <body>.
:root[data-admin-ui='v2'] {
--zyt-canvas: #f3f6f6;
--zyt-surface: #fff;
--zyt-surface-subtle: #f6f8f8;
--zyt-ink: #1c3037;
--zyt-text: #3f555d;
--zyt-muted: #60747b;
--zyt-border: #dce5e5;
--zyt-primary: var(--zyt-user-primary, #146e60);
--zyt-accent: var(--zyt-primary);
--zyt-accent-soft: #e5f3ef;
--zyt-accent-border: #b9dcd2;
--zyt-sidebar-dark: #193339;
--zyt-radius: 12px;
--zyt-shadow: 0 2px 5px rgba(28, 52, 57, .045);
// Scope the Art profile at the root, including Element poppers teleported to body.
// Reference: Art Design Pro f3aaf58, assets/styles/core/{tailwind,app,el-*}.
@use 'sass:color';
--el-color-primary: var(--zyt-accent);
--el-color-primary-light-3: #398c7d;
--el-color-primary-light-5: #77b1a4;
--el-color-primary-light-7: #a8cec3;
--el-color-primary-light-8: var(--zyt-accent-border);
--el-color-primary-light-9: var(--zyt-accent-soft);
--el-color-primary-dark-2: #0e594d;
@mixin art-status-colors($mix-target, $pressed-target) {
@each $name, $base in (success: #13deb9, warning: #ffae1f, danger: #ff4d4f, error: #fa896b, info: #909399) {
--el-color-#{$name}: #{$base};
--el-color-#{$name}-rgb: #{color.channel($base, "red", $space: rgb)}, #{color.channel($base, "green", $space: rgb)}, #{color.channel($base, "blue", $space: rgb)};
@each $step in 3, 5, 7, 8, 9 {
--el-color-#{$name}-light-#{$step}: #{color.mix($mix-target, $base, $step * 10%)};
}
--el-color-#{$name}-dark-2: #{color.mix($pressed-target, $base, 20%)};
}
}
:root[data-admin-ui='v2'] {
--art-gray-100: #f9fafb;
--art-gray-200: #f2f4f5;
--art-gray-300: #e6eaeb;
--art-gray-400: #dbdfe1;
--art-gray-500: #949eb7;
--art-gray-600: #7987a1;
--art-gray-700: #4d5875;
--art-gray-800: #383853;
--art-gray-900: #323251;
--zyt-canvas: #fafbfc;
--zyt-surface: #fff;
--zyt-surface-subtle: var(--art-gray-100);
--zyt-card-border: rgba(0, 0, 0, .08);
--zyt-border: #e2e8ee;
--zyt-hover: #edeff0;
--zyt-ink: var(--art-gray-900);
--zyt-text: var(--art-gray-700);
--zyt-muted: var(--art-gray-600);
--zyt-radius: .75rem;
--zyt-shadow: none; // Art's default boxBorderMode.
--zyt-primary: var(--el-color-primary);
--zyt-accent: var(--el-color-primary);
--zyt-accent-soft: var(--el-color-primary-light-9);
--zyt-accent-border: var(--el-color-primary-light-8);
--zyt-nav-bg: #fff;
--zyt-nav-title: var(--art-gray-800);
--zyt-nav-icon: #6b6b6b;
--zyt-nav-text: #29343d;
--zyt-nav-hover: var(--art-gray-200);
--zyt-nav-active: var(--el-color-primary-light-9);
--zyt-nav-selected: var(--zyt-selected-ink, var(--el-color-primary));
--zyt-nav-arrow: var(--art-gray-600);
// Runtime default/picker shades come from upstream's integer RGB algorithm.
--el-color-primary: #5d87ff;
--el-color-primary-light-9: #eef3ff;
--el-font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-family: var(--el-font-family);
--el-font-weight-primary: 400;
--el-bg-color: var(--zyt-surface);
--el-bg-color-page: var(--zyt-canvas);
--el-bg-color-overlay: var(--zyt-surface);
--el-fill-color-blank: var(--zyt-surface);
--el-fill-color-light: var(--zyt-surface-subtle);
--el-fill-color-lighter: var(--zyt-surface-subtle);
--el-text-color-primary: var(--zyt-ink);
--el-text-color-regular: var(--zyt-text);
--el-text-color-secondary: var(--zyt-muted);
--el-border-color: var(--zyt-border);
--el-border-color-light: var(--zyt-border);
--el-border-color-lighter: var(--zyt-border);
--el-border-radius-base: 7px;
--el-box-shadow-lighter: var(--zyt-shadow);
--el-component-size: 36px;
--el-border-radius-base: calc(var(--zyt-radius) / 3 + 2px);
--el-border-radius-small: calc(var(--zyt-radius) / 3 + 4px);
--el-menu-item-height: 42px;
--el-menu-sub-item-height: 42px;
--el-menu-icon-width: 20px;
--el-menu-base-level-padding: 20px;
--el-menu-level-padding: 20px;
--navbar-height: 60px;
--table-header-bg-color: var(--zyt-surface-subtle);
--navbar-height: 54px;
--el-menu-item-height: 40px;
--el-menu-sub-item-height: 36px;
--el-menu-level-padding: 15px;
@include art-status-colors(#fff, #000);
&.dark {
--zyt-canvas: #142126;
--zyt-surface: #1d2d32;
--zyt-surface-subtle: #24363b;
--zyt-ink: #e2eeee;
--zyt-text: #c5d4d7;
--zyt-muted: #a4b8bd;
--zyt-border: #3b5055;
--zyt-primary: var(--zyt-user-primary, #63bcaa);
--zyt-accent-soft: #24453f;
--zyt-accent-border: #3a6159;
--zyt-sidebar-dark: #15292e;
--zyt-shadow: 0 2px 5px rgba(0, 0, 0, .16);
--el-color-primary-light-3: #509e8e;
--el-color-primary-light-5: #478777;
--el-color-primary-light-7: #396457;
--el-color-primary-dark-2: #8acdbf;
.side--dark, &.dark {
--zyt-nav-bg: #191a23;
--zyt-nav-title: #d9dadb;
--zyt-nav-icon: #babbbd;
--zyt-nav-text: #babbbd;
--zyt-nav-hover: #0f1015;
--zyt-nav-active: #27282d;
--zyt-nav-selected: #fff;
--zyt-nav-arrow: var(--art-gray-400);
}
@supports (color: color-mix(in srgb, red, blue)) {
&, &.dark {
--zyt-accent-soft: color-mix(in srgb, var(--zyt-primary) 10%, var(--zyt-surface));
--zyt-accent-border: color-mix(in srgb, var(--zyt-primary) 25%, var(--zyt-surface));
--el-color-primary-light-3: color-mix(in srgb, var(--zyt-primary) 83%, var(--zyt-surface));
--el-color-primary-light-5: color-mix(in srgb, var(--zyt-primary) 56%, var(--zyt-surface));
--el-color-primary-light-7: color-mix(in srgb, var(--zyt-primary) 35%, var(--zyt-surface));
--el-color-primary-dark-2: color-mix(in srgb, var(--zyt-primary) 78%, var(--zyt-ink));
&.dark {
--art-gray-100: #110f0f;
--art-gray-200: #17171c;
--art-gray-300: #393946;
--art-gray-400: #505062;
--art-gray-500: #73738c;
--art-gray-600: #8f8fa3;
--art-gray-700: #ababba;
--art-gray-800: #c7c7d1;
--art-gray-900: #e3e3e8;
--zyt-canvas: #070707;
--zyt-surface: #161618;
--zyt-surface-subtle: var(--art-gray-200);
--zyt-card-border: rgba(255, 255, 255, .08);
--zyt-border: rgba(255, 255, 255, .1);
--zyt-hover: #252530;
--el-text-color-regular: rgba(255, 255, 255, .85);
@include art-status-colors(#141414, #fff);
// In system dark all three styles use darkMenuStyles, not a white panel.
&, .side--dark {
--zyt-nav-bg: var(--zyt-surface);
--zyt-nav-title: #ddd;
--zyt-nav-icon: var(--art-gray-800);
--zyt-nav-text: var(--art-gray-800);
--zyt-nav-selected: var(--zyt-selected-ink, var(--el-color-primary));
--zyt-nav-arrow: #fff;
}
}
&.dark .el-button--primary:not(.is-plain, .is-text, .is-link, .is-disabled) {
--el-button-text-color: var(--zyt-on-primary, #112823);
--el-button-active-text-color: var(--zyt-on-primary, #112823);
--el-button-hover-text-color: var(--zyt-on-primary, #112823);
.main-wrap, .layout-default, .app-header, .navbar, .app-header .app-tabs {
background-color: var(--zyt-canvas);
}
.layout-default { background: var(--zyt-canvas); }
.app-header {
position: relative;
z-index: 2;
border-bottom: 1px solid var(--zyt-border);
background: var(--zyt-surface);
}
.navbar { padding-inline: clamp(8px, 1.25vw, 22px); }
.app-header { position: relative; z-index: 2; }
.navbar { padding-inline: 20px; }
.navbar .navbar-item {
border-radius: 7px;
color: var(--zyt-text);
}
.app-header .app-breadcrumb .el-breadcrumb__item .el-breadcrumb__inner,
.app-header .app-breadcrumb .el-breadcrumb__separator { color: var(--zyt-muted); }
.app-header .app-breadcrumb .el-breadcrumb__item:last-child .el-breadcrumb__inner {
color: var(--zyt-ink);
font-weight: 600;
color: var(--art-gray-700);
border-radius: var(--el-border-radius-base);
&:hover { background: var(--zyt-hover); }
}
.app-header .app-tabs {
padding-block: 4px;
border-color: var(--zyt-border);
.el-tabs { height: 30px; --el-tabs-header-height: 30px; }
padding: 0 20px 12px;
border: 0;
.el-tabs { height: 32px; --el-tabs-header-height: 32px; }
.el-tabs__item {
height: 30px;
border-radius: 6px;
font-size: 13px;
&.is-active { background: var(--zyt-accent-soft); color: var(--zyt-primary); font-weight: 600; }
&.is-active::after { display: none; }
height: 32px;
margin-right: 6px;
border: 1px solid var(--zyt-card-border);
border-radius: calc(var(--zyt-radius) / 2.5 + 2px);
background: var(--zyt-surface);
color: var(--zyt-muted);
font-size: 12px;
&.is-active, &:hover { color: var(--zyt-primary); }
&.is-active::before, &.is-active::after { display: none; }
}
}
.admin-content { padding: clamp(12px, 1.45vw, 24px); }
.admin-nav-heading {
.admin-content { padding: 0 20px 20px; }
.navbar:last-child { margin-bottom: 12px; }
.side {
background: var(--zyt-nav-bg);
border-right-color: var(--zyt-card-border);
}
.logo, .admin-nav-heading {
flex: none;
display: flex;
align-items: center;
gap: 10px;
min-height: var(--navbar-height);
padding: 0 18px;
height: var(--navbar-height);
padding-inline: 22px;
color: var(--zyt-nav-title);
white-space: nowrap;
color: var(--zyt-ink);
font-size: 15px;
font-weight: 650;
svg { color: var(--zyt-accent); }
font-size: 18px;
.logo-title { position: static; font-size: inherit; color: inherit; }
svg { color: var(--zyt-primary); }
}
.side .logo, .side .admin-nav-heading { border-bottom: 1px solid var(--zyt-border); }
.side--dark {
border-right-color: var(--side-dark-color);
.admin-nav-heading, .logo { color: #f0f7f5; border-bottom-color: rgba(255,255,255,.12); }
.admin-nav-heading svg { color: #86ceba; }
.side .menu .el-menu {
--el-menu-bg-color: var(--zyt-nav-bg);
--el-menu-text-color: var(--zyt-nav-text);
--el-menu-active-color: var(--zyt-nav-selected);
--el-menu-hover-bg-color: var(--zyt-nav-hover);
}
.side .menu { padding-block: 8px; }
.side .menu, .el-menu--popup-container {
--zyt-nav-bg: var(--zyt-surface);
--zyt-nav-text: var(--zyt-text);
--zyt-nav-hover: var(--zyt-surface-subtle);
--zyt-nav-active: var(--zyt-accent-soft);
--zyt-nav-selected: var(--zyt-accent);
&.theme-dark {
--zyt-nav-bg: var(--side-dark-color, var(--zyt-sidebar-dark));
--zyt-nav-text: #cbdedc;
--zyt-nav-hover: rgba(255,255,255,.09);
--zyt-nav-active: #2b514e;
--zyt-nav-selected: #d2faea;
}
.el-menu {
--el-menu-bg-color: var(--zyt-nav-bg);
--el-menu-text-color: var(--zyt-nav-text);
--el-menu-hover-text-color: var(--zyt-nav-selected);
--el-menu-hover-bg-color: var(--zyt-nav-hover);
--el-menu-active-color: var(--zyt-nav-selected);
}
.side .menu {
.el-menu-item, .el-sub-menu__title {
margin: 2px 5px;
border-radius: 7px;
font-size: 13px;
&:hover { background: var(--zyt-nav-hover); color: var(--zyt-nav-selected); }
height: 42px;
line-height: 42px;
width: calc(100% - 16px);
margin: 0 8px 4px;
border-radius: 6px;
font-size: 14px;
color: var(--zyt-nav-text);
transition: background-color 0s;
}
.el-menu .el-menu-item.is-active,
.el-menu.el-menu--collapse .el-sub-menu.is-active > .el-sub-menu__title {
border-right: none;
.menu-item-icon { margin-left: -7px; color: var(--zyt-nav-icon); font-size: 20px !important; }
.el-sub-menu__icon-arrow { color: var(--zyt-nav-arrow); font-size: 13px; }
.el-sub-menu__title:hover, .el-menu-item:not(.is-active):hover {
background: var(--zyt-nav-hover);
color: var(--zyt-nav-text);
}
.el-menu .el-menu-item.is-active {
border: 0;
background: var(--zyt-nav-active);
color: var(--zyt-nav-selected);
font-weight: 650;
font-weight: 400;
.menu-item-icon { color: inherit; }
}
.el-menu--collapse { width: 64px; }
.el-menu--collapse .is-active > .el-sub-menu__title .menu-item-icon { color: var(--zyt-primary); }
}
// The LIGHT theme alone has the full-width item and 4px stripe. DESIGN is flat.
&:not(.dark) .side--light .menu {
.el-menu-item, .el-sub-menu__title { width: 100%; margin-inline: 0; border-radius: 0; }
.menu-item-icon { margin-left: 1px; }
.el-menu-item.is-active::before {
position: absolute;
inset: 0 auto 0 0;
width: 4px;
content: '';
background: var(--zyt-primary);
}
}
.el-menu--popup-container .el-menu--popup {
padding: 8px; background: var(--zyt-surface);
.el-menu-item, .el-sub-menu__title {
height: 40px; margin-bottom: 5px; border: 0; border-radius: 6px; color: var(--zyt-text);
&:hover, &.is-active { background: var(--art-gray-200); color: var(--art-gray-900); }
}
}
&.dark .el-menu--popup-container .el-menu--popup .el-menu-item.is-active { background: #292a2e; }
.art-menu-options {
display: flex; gap: 6px; margin-top: 12px;
button {
padding: 5px 12px;
background: var(--zyt-surface);
border: 1px solid var(--zyt-border);
border-radius: 6px;
color: var(--zyt-text);
&[aria-pressed='true'] { border-color: var(--zyt-primary); color: var(--zyt-primary); background: var(--zyt-accent-soft); }
}
}
.el-card {
--el-card-border-radius: var(--zyt-radius);
--el-card-border-color: var(--zyt-border);
&.is-always-shadow { box-shadow: var(--zyt-shadow); }
--el-card-border-radius: calc(var(--zyt-radius) + 4px);
--el-card-border-color: var(--zyt-card-border);
--el-card-bg-color: var(--zyt-surface);
box-shadow: none;
}
.el-table {
--el-table-header-text-color: var(--zyt-text);
--el-table-header-bg-color: var(--zyt-surface-subtle);
--el-table-row-hover-bg-color: var(--zyt-surface-subtle);
font-variant-numeric: tabular-nums;
thead th { font-weight: 600; font-size: 13px; }
.el-table { font-variant-numeric: tabular-nums; }
.el-overlay-dialog .el-dialog { border-radius: calc(var(--zyt-radius) / 1.2 + 2px); }
.el-message-box, .el-popover { border-radius: var(--el-border-radius-small); }
.el-dialog__title { font-size: 16px; }
// Our locked Element Plus ships a literal 32px base height. Map default-size
// buttons to the upstream 36px, without enlarging compact or text actions.
.el-button:not(.el-button--small, .el-button--large, .is-link, .is-text) {
height: var(--el-component-size);
&.is-circle { width: var(--el-component-size); }
}
.el-overlay-dialog .el-dialog, .el-message-box {
border-radius: var(--zyt-radius);
border: 1px solid var(--zyt-border);
}
.el-dialog__title, .el-drawer__title { font-weight: 650; }
.el-tag { border-radius: 5px; }
.el-pagination { --el-pagination-button-bg-color: var(--zyt-surface-subtle); }
:focus-visible:is(button, a, [role='button']) {
outline: 2px solid var(--zyt-accent);
outline-offset: 2px;
.el-button--primary:not(.is-plain, .is-text, .is-link, .is-disabled) {
--el-button-text-color: var(--zyt-on-primary, #fff);
--el-button-active-text-color: var(--zyt-on-primary, #fff);
--el-button-hover-text-color: var(--zyt-on-primary, #fff);
}
.el-pagination.is-background :is(.btn-next, .btn-prev, .el-pager li) { border-radius: 6px; }
:focus-visible:is(button, a, [role='button']) { outline: 2px solid var(--zyt-primary); outline-offset: 2px; }
@media (max-width: 640px) {
.admin-content { padding: 10px; }
.navbar { padding-inline: 4px; }
.admin-content { padding-inline: 15px; }
.navbar, .app-header .app-tabs { padding-inline: 15px; }
}
}
+16 -12
View File
@@ -94,7 +94,7 @@
/>
<el-button
v-perms="['order.order/create']"
type="success"
:type="appearance.adminUi === 'v2' ? 'default' : 'success'"
class="ml-2.5"
@click="handleCreate"
>
@@ -102,7 +102,7 @@
</el-button>
<el-button
v-perms="['order.order/alltongbu']"
type="warning"
:type="appearance.adminUi === 'v2' ? 'default' : 'warning'"
class="ml-2.5"
:loading="syncLoading"
@click="handleSyncWechatWork"
@@ -1747,10 +1747,15 @@ html[data-admin-ui="v2"] .order-list {
font-weight: 700; line-height: 1.25;
}
.zyt-order-heading p { margin: 0; font-size: 13px; color: var(--zyt-muted); }
> .el-card { border-radius: var(--zyt-radius); background: var(--zyt-surface); box-shadow: var(--zyt-shadow); }
> .el-card {
// These legacy cards carry Tailwind's !border-none utility.
border: 1px solid var(--zyt-card-border) !important;
border-radius: 8px; background: var(--zyt-surface); box-shadow: none;
}
> .el-card + .el-card { margin-top: 12px; }
> .el-card > .el-card__body { padding: 16px 20px; }
.zyt-order-title, .zyt-order-record-heading h2 {
margin: 0; color: var(--zyt-ink); font-size: 16px; line-height: 24px; font-weight: 600;
margin: 0; color: var(--zyt-ink); font-size: 18px; line-height: 24px; font-weight: 500;
}
.zyt-order-title { display: block; margin-bottom: 14px; }
.zyt-order-record-heading {
@@ -1780,21 +1785,20 @@ html[data-admin-ui="v2"] .order-list {
.zyt-order-association .el-tabs__header { margin: 0; }
.zyt-order-association .el-tabs__nav-wrap::after { display: none; }
.zyt-order-revenue {
flex-wrap: wrap; gap: 5px; padding: 4px 10px; border-radius: 7px;
background: var(--zyt-accent-soft); font-variant-numeric: tabular-nums;
.text-red-500 { color: var(--zyt-primary); }
.text-gray-400, .text-gray-500 { color: var(--zyt-text); }
flex-wrap: wrap; gap: 5px; padding: 4px 0; font-variant-numeric: tabular-nums;
.text-red-500 { color: var(--zyt-ink); font-weight: 500; }
.text-gray-400, .text-gray-500 { color: var(--zyt-muted); }
}
.zyt-order-records .el-table {
--el-table-header-bg-color: var(--zyt-surface-subtle);
--el-table-header-bg-color: var(--zyt-surface);
--el-table-header-text-color: var(--zyt-text);
--el-table-border-color: var(--zyt-border);
--el-table-row-hover-bg-color: var(--zyt-accent-soft);
--el-table-row-hover-bg-color: var(--zyt-hover);
.el-table__cell { padding-block: 9px; }
th.el-table__cell { font-size: 12px; font-weight: 600; }
th.el-table__cell { font-size: 14px; font-weight: 500; }
.zyt-order-id .cell, .zyt-order-amount .cell { font-variant-numeric: tabular-nums; }
td.zyt-order-id { color: var(--zyt-ink); }
.zyt-order-amount span { color: var(--zyt-primary); }
.zyt-order-amount span { color: var(--zyt-ink); font-weight: 500; }
td.zyt-order-ops .cell { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
td.zyt-order-ops .el-button { margin: 0; padding-block: 3px; }
.text-gray-400 { color: var(--zyt-muted); }
+68 -66
View File
@@ -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; }
@@ -48,3 +48,17 @@
## 实施记录 · 2026-12-01(试点)
上述首轮已在本分支实现:正式入口保留经典外观作为初始值,顶栏可选择新版;本地隔离预览默认打开新版,工作台与订单页使用真实 Vue 组件。试点没有更换业务框架或接入正式后端。[启动与停止方法](../../admin/local-preview/README.md)。后续模块仍为计划,不在本次验收结论内。
## 配色校正:以上游实际默认值为准
首版借用了分层方式,却另选了青绿主色和深青侧栏,与参考项目默认外观不符。此次的依据是上游提交 `f3aaf58eec1a0e988f162352c33862327a484f95` 的[默认设置](https://github.com/Daymychen/art-design-pro/blob/f3aaf58eec1a0e988f162352c33862327a484f95/src/config/setting.ts#L29-L85)、[菜单颜色和主色预设](https://github.com/Daymychen/art-design-pro/blob/f3aaf58eec1a0e988f162352c33862327a484f95/src/config/index.ts#L83-L128)、[侧栏样式](https://github.com/Daymychen/art-design-pro/blob/f3aaf58eec1a0e988f162352c33862327a484f95/src/components/core/layouts/art-menus/art-sidebar-menu/theme.scss#L154-L170)及[色阶计算](https://github.com/Daymychen/art-design-pro/blob/f3aaf58eec1a0e988f162352c33862327a484f95/src/utils/ui/colors.ts#L200-L273)。不是从截图取一个近似蓝色。
| 首次进入新版 | 浅色 | 系统暗色 |
| --- | --- | --- |
| 默认主色(预设第一个) | `#5D87FF` | `#5D87FF` |
| 页面画布 / 卡片 | `#FAFBFC` / `#FFFFFF` | `#070707` / `#161618` |
| 展开的左侧菜单底色 | `#FFFFFF`,Design 风格 | `#161618` |
| 当前菜单项:背景 / 实际文字 | `#EEF3FF` / `#5D87FF` | `#27282D` / `#5D87FF` |
| 普通仪表盘卡片 | 1px 半透明黑边框,16px 圆角,无阴影 | 1px 半透明白边框,16px 圆角,无阴影 |
上游展开菜单设为 230px;`0.75rem` 是基础圆角,并非所有卡片都取 12px。标准仪表盘卡和表格卡边角分别为基础值加 4px、基础值折半加 2px。新版后台保留甄养堂的名称、数据、字段和权限,不把业务成功/风险状态一律染成蓝色。实际验收使用全新浏览器上下文,读取按钮、菜单项文字和背景、卡片等 DOM 元素的计算样式,同时对照经典模式;校验脚本见[本机颜色验收](../../admin/local-preview/verify-art-parameters.py)。