fix(admin): 校正侧栏箭头与折叠标志并整理子菜单
This commit is contained in:
@@ -0,0 +1 @@
|
||||
__pycache__/
|
||||
@@ -17,3 +17,5 @@ node live-native/build.mjs && node live-native/server.mjs
|
||||
构建输出仅在本工作树 `admin/node_modules/.zyt-live-native/dist`。本机会话任务为 `local.zyt.live-native.bfc2`,可用 `launchctl remove local.zyt.live-native.bfc2` 停止,不设开机启动项。可选 `server.mjs --qa` 使用 5181 供隔离验收。
|
||||
|
||||
黑盒检查:`python3 live-native/browser_contract.py --host 127.0.0.1:5179 --chrome <Chromium路径> --out <本地截图目录>`。测试拦截所有非本机请求,仅用虚构登录/统计数据检查真实组件;不验证真实用户凭据或线上写入。
|
||||
|
||||
分批 UI 验收:`node live-native/build.mjs v1-example` 只写入本机候选目录;`node live-native/server.mjs --qa v1-example` 在本机 5181 查看它。验收通过后运行 `node live-native/promote-local.mjs apply v1-example`;如需切回上版且当前仍是此构建,运行 `node live-native/promote-local.mjs restore v1-example`。每次应用使用唯一候选名。5179 的旧哈希资源继续可用,不涉及正式发布目录。
|
||||
|
||||
@@ -0,0 +1,281 @@
|
||||
"""Offline native sidebar geometry and navigation; requires the prebuilt loopback static server."""
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from playwright.sync_api import expect, sync_playwright
|
||||
|
||||
from browser_contract import ACCOUNT, BRAND, LOGIN, PASS, SELF, USER, Fixture, loopback, menu
|
||||
|
||||
|
||||
ROOT = "数据统计"
|
||||
NESTED = "自录数据统计与跨部门综合分析报表导航"
|
||||
LEAF = "账户消耗录入与跨部门财务对账明细"
|
||||
OTHER = "运营管理与跨部门协作流程工作中心"
|
||||
TOP_LEAF = "独立账户消耗录入"
|
||||
TITLE = ".el-sub-menu__title"
|
||||
POP = ".el-menu--popup:visible"
|
||||
|
||||
|
||||
def setup_menu(fixture):
|
||||
roots = fixture.reads[SELF]["menu"]
|
||||
root, = roots
|
||||
nested, = root["children"]
|
||||
root["icon"] = "el-icon-Setting"
|
||||
nested.update(name=NESTED, icon="el-icon-Folder")
|
||||
nested["children"][1].update(name=LEAF, icon="el-icon-Document")
|
||||
roots.append(menu(410, OTHER, "operations", children=[
|
||||
menu(411, "运营明细", "details", component="stats/self_input/account_cost")]))
|
||||
roots.append(dict(menu(420, TOP_LEAF, "solo", component="stats/self_input/account_cost"),
|
||||
icon="local-icon-dingdan"))
|
||||
|
||||
|
||||
def settle(element):
|
||||
# Vue starts CSS transitions on the next animation frames. Don't measure halfway through.
|
||||
element.evaluate("""async el => {
|
||||
const frame = () => new Promise(resolve => requestAnimationFrame(resolve));
|
||||
await frame(); await frame();
|
||||
const anims = el.getAnimations({subtree: true}).filter(a =>
|
||||
a.effect?.getComputedTiming().endTime < Infinity);
|
||||
await Promise.allSettled(anims.map(a => a.finished)); await frame();
|
||||
}""")
|
||||
|
||||
|
||||
def title(parent, name):
|
||||
return parent.locator(TITLE).filter(has=parent.page.get_by_text(name, exact=True))
|
||||
|
||||
|
||||
def toggle(group_title, opened):
|
||||
item = group_title.locator("..")
|
||||
if item.get_attribute("aria-expanded") != str(opened).lower():
|
||||
group_title.click()
|
||||
expect(item).to_have_attribute("aria-expanded", str(opened).lower())
|
||||
settle(item)
|
||||
|
||||
|
||||
def label_metrics(row, name):
|
||||
return row.get_by_text(name, exact=True).evaluate("""el => {
|
||||
const range = document.createRange(); range.selectNodeContents(el);
|
||||
const text = range.getBoundingClientRect(), box = el.getBoundingClientRect();
|
||||
// Text can extend beyond its range of painted pixels when an ancestor clips it.
|
||||
let right = text.right, ellipsis = false;
|
||||
const row = el.closest('.el-menu-item,.el-sub-menu__title');
|
||||
for (let p = el; p && p !== row; p = p.parentElement) {
|
||||
const s = getComputedStyle(p);
|
||||
if (s.overflowX !== 'visible') {
|
||||
right = Math.min(right, p.getBoundingClientRect().right);
|
||||
ellipsis ||= s.textOverflow === 'ellipsis';
|
||||
}
|
||||
}
|
||||
return {left: text.left, right, textRight: text.right, ellipsis, height: box.height}
|
||||
}""")
|
||||
|
||||
|
||||
def arrow_metrics(row, name):
|
||||
label = label_metrics(row, name)
|
||||
arrow = row.locator(".el-sub-menu__icon-arrow svg")
|
||||
expect(arrow).to_be_visible()
|
||||
result = arrow.evaluate(r"""svg => {
|
||||
const r = svg.getBoundingClientRect();
|
||||
const row = svg.closest('.el-sub-menu__title'), b = row.getBoundingClientRect();
|
||||
const x = r.x + r.width / 2, y = r.y + r.height / 2;
|
||||
// A zero-sized path, transparent paint, clipped SVG or covered row isn't a visible arrow.
|
||||
const painted = Array.from(svg.querySelectorAll('path,polygon,polyline,line,use')).some(p => {
|
||||
const ink = getComputedStyle(p), bounds = p.getBoundingClientRect();
|
||||
return bounds.width > 1 && bounds.height > 1 && ink.visibility === 'visible' &&
|
||||
ink.display !== 'none' && [ink.fill, ink.stroke].some(c =>
|
||||
c && c !== 'none' && c !== 'transparent' && !/rgba\(.*?,\s*0\)$/.test(c));
|
||||
});
|
||||
let opacity = 1; for (let p = svg; p; p = p.parentElement) opacity *= +getComputedStyle(p).opacity;
|
||||
return {left:r.left, right:r.right, end:b.right, width:r.width, painted, opacity,
|
||||
hit:row.contains(document.elementFromPoint(x,y))};
|
||||
}""")
|
||||
assert result["painted"] and result["hit"] and result["opacity"] > .5, (name, result)
|
||||
assert result["width"] >= 8 and -1 <= result["end"] - result["right"] <= 28, (name, result)
|
||||
assert label["height"] > 0 and label["left"] < label["right"] <= result["left"] - 1, (name, label, result)
|
||||
assert label["textRight"] <= label["right"] + 1 or label["ellipsis"], (name, label)
|
||||
return result["right"]
|
||||
|
||||
|
||||
def expanded(menu_el):
|
||||
r, n, o = (title(menu_el, name) for name in (ROOT, NESTED, OTHER))
|
||||
toggle(r, True)
|
||||
toggle(n, True)
|
||||
leaf = menu_el.get_by_role("menuitem", name=LEAF, exact=True)
|
||||
expect(leaf).to_be_visible()
|
||||
rights = [arrow_metrics(row, name) for row, name in [(r, ROOT), (n, NESTED), (o, OTHER)]]
|
||||
assert max(rights) - min(rights) <= 1.5, ("arrow right track", rights)
|
||||
levels = [label_metrics(row, name)["left"] for row, name in [(r, ROOT), (n, NESTED), (leaf, LEAF)]]
|
||||
assert levels[0] + 4 < levels[1] and levels[1] + 4 < levels[2], ("label indentation", levels)
|
||||
return dict(arrow_right=rights, label_left=levels)
|
||||
|
||||
|
||||
def center(rail, target, name):
|
||||
expect(target).to_be_visible()
|
||||
a, b = rail.bounding_box(), target.bounding_box()
|
||||
expected, actual = a["x"] + a["width"] / 2, b["x"] + b["width"] / 2
|
||||
assert abs(expected - actual) <= 1.5, (name, "rail center", expected, "element center", actual)
|
||||
return round(actual, 2)
|
||||
|
||||
|
||||
def screenshot(page, out, name):
|
||||
if out:
|
||||
page.screenshot(path=str(out / f"sidebar-{name}.png"), animations="disabled")
|
||||
|
||||
|
||||
def settings(page):
|
||||
page.locator(".app-header .setting").click()
|
||||
drawer = page.get_by_role("dialog", name="主题设置")
|
||||
expect(drawer.get_by_text("菜单栏宽度", exact=True)).to_be_visible()
|
||||
return drawer
|
||||
|
||||
|
||||
def close_settings(page, drawer):
|
||||
page.keyboard.press("Escape")
|
||||
expect(drawer).to_be_hidden()
|
||||
|
||||
|
||||
def check(page, fixture, out):
|
||||
page.goto(fixture.base + "/admin/login")
|
||||
page.get_by_placeholder("请输入账号").fill(ACCOUNT)
|
||||
page.get_by_placeholder("请输入密码").fill(PASS)
|
||||
page.get_by_role("button", name="登录", exact=True).click()
|
||||
expect(page.locator(".app-header").get_by_text(USER, exact=True)).to_be_visible(timeout=15000)
|
||||
expect(page.locator("html")).to_have_attribute("data-admin-ui", "v2")
|
||||
|
||||
side = page.locator(".side:visible")
|
||||
rail = side.locator(".menu")
|
||||
r, n = title(rail, ROOT), title(rail, NESTED)
|
||||
toggle(r, True)
|
||||
toggle(n, False)
|
||||
leaf = rail.get_by_text(LEAF, exact=True)
|
||||
expect(leaf).to_be_hidden()
|
||||
arrow = n.locator(".el-sub-menu__icon-arrow")
|
||||
orientation = "(el) => [getComputedStyle(el).transform, el.innerHTML].join(' ')"
|
||||
closed_state = arrow.evaluate(orientation)
|
||||
toggle(n, True)
|
||||
assert arrow.evaluate(orientation) != closed_state, "nested arrow did not indicate its new state"
|
||||
expect(leaf).to_be_visible()
|
||||
toggle(r, False)
|
||||
expect(n).to_be_hidden()
|
||||
other = title(rail, OTHER)
|
||||
toggle(other, True)
|
||||
expect(rail.get_by_text("运营明细", exact=True)).to_be_visible()
|
||||
toggle(other, False)
|
||||
expect(rail.get_by_text("运营明细", exact=True)).to_be_hidden()
|
||||
|
||||
report = {"expanded": expanded(rail)}
|
||||
screenshot(page, out, "expanded")
|
||||
# Move by Tab from its known preceding leaf, then activate the actual router link.
|
||||
previous = rail.get_by_role("link", name="自录转化统计", exact=True)
|
||||
previous.focus()
|
||||
page.keyboard.press("Tab")
|
||||
expect(rail.get_by_role("link", name=LEAF, exact=True)).to_be_focused()
|
||||
page.keyboard.press("Enter")
|
||||
expect(page.locator("main .personal-account-cost-page")).to_be_visible()
|
||||
|
||||
fold = page.locator(".app-header .fold")
|
||||
expect(fold).to_have_attribute("aria-expanded", "true")
|
||||
fold.focus()
|
||||
page.keyboard.press("Enter")
|
||||
expect(fold).to_have_attribute("aria-expanded", "false")
|
||||
expect(rail.locator(".el-menu--collapse")).to_be_visible()
|
||||
settle(side)
|
||||
logo = side.locator(".logo img")
|
||||
expect(logo).to_have_attribute("src", BRAND)
|
||||
assert logo.evaluate("img => img.complete && img.naturalWidth > 0")
|
||||
report["collapsed_centers"] = {
|
||||
"logo": center(rail, logo, "brand image"),
|
||||
"group": center(rail, r.locator(".menu-item-icon svg"), "root group icon"),
|
||||
"no_icon_group": center(rail, other.locator(".menu-item-icon"), "root initial"),
|
||||
"leaf": center(rail, rail.locator("a[href$='/solo'] .menu-item-icon svg"), "root leaf icon")
|
||||
}
|
||||
|
||||
initial = other.locator(".menu-item-icon")
|
||||
assert initial.evaluate("""el => {
|
||||
const s = getComputedStyle(el, '::before');
|
||||
return el.textContent.trim() || (s.content !== 'none' && s.content !== 'normal' &&
|
||||
s.content !== '""' && s.display !== 'none' && s.visibility === 'visible');
|
||||
}"""), "an iconless root must retain a visible identifier in the collapsed rail"
|
||||
|
||||
# Element Plus teleports the submenu outside .side when collapsed.
|
||||
r.hover()
|
||||
popup_n = title(page.locator(POP), NESTED)
|
||||
expect(popup_n).to_be_visible()
|
||||
settle(popup_n.locator("xpath=ancestor::*[contains(concat(' ',normalize-space(@class),' '),' el-popper ')][1]"))
|
||||
arrow_metrics(popup_n, NESTED)
|
||||
popup_n.hover()
|
||||
popup_leaf = page.locator(POP).get_by_text(LEAF, exact=True)
|
||||
expect(popup_leaf).to_be_visible()
|
||||
screenshot(page, out, "popup")
|
||||
fold.hover()
|
||||
expect(popup_leaf).to_be_hidden()
|
||||
|
||||
drawer = settings(page)
|
||||
# Element Plus exposes a visually-hidden checkbox and a separate painted track.
|
||||
logo_item = drawer.locator(".setting-item").filter(has_text="显示LOGO")
|
||||
logo_item.locator(".el-switch__core").click()
|
||||
expect(logo_item.get_by_role("switch")).not_to_be_checked()
|
||||
drawer.get_by_role("button", name="深色菜单").click()
|
||||
width = drawer.get_by_role("spinbutton")
|
||||
width.fill("180")
|
||||
width.press("Enter")
|
||||
close_settings(page, drawer)
|
||||
expect(logo).to_be_hidden()
|
||||
report["collapsed_centers"]["fallback"] = center(rail, side.locator(".admin-nav-heading svg"), "no-logo icon")
|
||||
fold.press("Enter")
|
||||
expect(fold).to_have_attribute("aria-expanded", "true")
|
||||
expect(rail).to_have_class(re.compile(r"\btheme-dark\b"))
|
||||
settle(side)
|
||||
assert abs(rail.bounding_box()["width"] - 180) <= 1, rail.bounding_box()
|
||||
report["dark_180px"] = expanded(rail)
|
||||
screenshot(page, out, "dark-180")
|
||||
|
||||
page.set_viewport_size({"width": 390, "height": 844})
|
||||
expect(rail).to_be_hidden()
|
||||
fold.click()
|
||||
mobile = page.locator(".el-drawer:visible .side")
|
||||
expect(mobile).to_be_visible()
|
||||
settle(mobile.locator("xpath=ancestor::*[contains(@class, 'el-overlay')][1]"))
|
||||
report["mobile_drawer"] = expanded(mobile.locator(".menu"))
|
||||
screenshot(page, out, "mobile")
|
||||
mobile.get_by_role("link", name="自录转化统计", exact=True).click()
|
||||
expect(mobile).to_be_hidden()
|
||||
expect(page.locator("main .self-input-stats-page")).to_be_visible()
|
||||
return report
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--host", type=loopback, default="127.0.0.1:5179")
|
||||
parser.add_argument("--chrome", required=True)
|
||||
parser.add_argument("--out", type=Path, help="Optional local screenshots directory")
|
||||
args = parser.parse_args()
|
||||
if args.out:
|
||||
args.out.mkdir(parents=True, exist_ok=True)
|
||||
fixture = Fixture(args.host, False, False)
|
||||
setup_menu(fixture)
|
||||
with sync_playwright() as pw, pw.chromium.launch(executable_path=args.chrome, args=[
|
||||
"--disable-background-networking", "--disable-quic", "--no-proxy-server",
|
||||
"--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1"]) as browser:
|
||||
with browser.new_context(service_workers="block", viewport={"width": 1440, "height": 960},
|
||||
color_scheme="light") as ctx:
|
||||
ctx.set_default_timeout(8000)
|
||||
ctx.route("**/*", fixture.route)
|
||||
ctx.route_web_socket("**/*", lambda ws: (fixture.errors.append("unexpected WebSocket"), ws.close()))
|
||||
ctx.on("page", lambda p: p.on("pageerror", lambda e: fixture.errors.append(str(e))))
|
||||
page = ctx.new_page()
|
||||
try:
|
||||
report = check(page, fixture, args.out)
|
||||
assert [p for method, p in fixture.calls if method == "POST"] == [LOGIN], fixture.calls
|
||||
assert not fixture.errors, fixture.errors
|
||||
except Exception:
|
||||
screenshot(page, args.out, "failure")
|
||||
print("mocked:", fixture.calls, "errors:", fixture.errors, flush=True)
|
||||
raise
|
||||
print(json.dumps({"sidebar": "PASS", "real_api_calls": 0, **report}, ensure_ascii=False))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -5,8 +5,11 @@ import path from 'node:path'
|
||||
import {fileURLToPath} from 'node:url'
|
||||
const here=path.dirname(fileURLToPath(import.meta.url)), root=path.dirname(here)
|
||||
process.chdir(root)
|
||||
const name=process.argv[2]
|
||||
if(name && !/^[a-z][a-z0-9-]{1,48}$/.test(name))throw Error('Use a short lowercase candidate name')
|
||||
const target=path.join(root,'node_modules/.zyt-live-native',...(name?['candidates',name]:['dist']))
|
||||
await build({root,mode:'live-native',configFile:path.join(root,'vite.config.ts'),envFile:false,
|
||||
define:{'import.meta.env.VITE_APP_BASE_URL':JSON.stringify('https://admin.zhenyangtang.com.cn')},
|
||||
cacheDir:path.join(root,'node_modules/.zyt-live-native/cache'),
|
||||
build:{outDir:path.join(root,'node_modules/.zyt-live-native/dist'),emptyOutDir:true,sourcemap:false,reportCompressedSize:false,
|
||||
build:{outDir:target,emptyOutDir:true,sourcemap:false,reportCompressedSize:false,
|
||||
rollupOptions:{input:path.join(here,'index.html')}}})
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Publish a tested static build to the *loopback* service. Retain older hashed
|
||||
// chunks for already-open tabs; atomically change HTML only after all copies finish.
|
||||
import path from 'node:path'
|
||||
import {fileURLToPath} from 'node:url'
|
||||
import {copyFile, mkdir, readFile, readdir, rename, writeFile} from 'node:fs/promises'
|
||||
import {randomUUID} from 'node:crypto'
|
||||
const root=fileURLToPath(new URL('../node_modules/.zyt-live-native/',import.meta.url))
|
||||
const [action,name]=process.argv.slice(2)
|
||||
if(!['apply','restore'].includes(action)||!/^[a-z][a-z0-9-]{1,48}$/.test(name??'')) throw Error('Usage: promote-local.mjs apply|restore <candidate>')
|
||||
const candidate=path.join(root,'candidates',name), live=path.join(root,'dist'), entry='live-native/index.html', old=path.join(root,'checkpoints',name+'.html')
|
||||
async function atomic(dst,bytes){const temp=dst+'.'+randomUUID()+'.tmp';await writeFile(temp,bytes);await rename(temp,dst)}
|
||||
async function sync(dir,relative=''){
|
||||
for (const item of await readdir(dir,{withFileTypes:true})){
|
||||
const rel=path.join(relative,item.name),dst=path.join(live,rel)
|
||||
if(item.isDirectory()){await mkdir(dst,{recursive:true});await sync(path.join(dir,item.name),rel)}
|
||||
else if(item.isFile() && rel!==entry){const temp=dst+'.'+randomUUID()+'.tmp';await copyFile(path.join(dir,item.name),temp);await rename(temp,dst)}
|
||||
}
|
||||
}
|
||||
const next=await readFile(path.join(candidate,entry),'utf8');const assets=[...next.matchAll(/(?:src|href)="\/admin\/(assets\/[^"?]+)"/g)].map(m=>m[1]);if(!assets.length)throw Error('No build assets referenced')
|
||||
if(action==='apply'){
|
||||
for(const a of assets) await readFile(path.join(candidate,a))
|
||||
await mkdir(path.dirname(old),{recursive:true});await writeFile(old,await readFile(path.join(live,entry)),{flag:'wx'})
|
||||
await sync(candidate);await atomic(path.join(live,entry),next)
|
||||
}else{
|
||||
if(await readFile(path.join(live,entry),'utf8')!==next)throw Error('The active version changed; refusing to overwrite it')
|
||||
await atomic(path.join(live,entry),await readFile(old));
|
||||
}
|
||||
console.log(`local ${action}: ${name}`)
|
||||
@@ -4,7 +4,10 @@ import path from 'node:path'
|
||||
import {fileURLToPath} from 'node:url'
|
||||
import {readFile} from 'node:fs/promises'
|
||||
const host='127.0.0.1',port=process.argv[2]==='--qa'?5181:5179,self=`http://${host}:${port}`,official='https://admin.zhenyangtang.com.cn'
|
||||
const dist=fileURLToPath(new URL('../node_modules/.zyt-live-native/dist/',import.meta.url)), entry=path.join(dist,'live-native/index.html')
|
||||
const candidate=port===5181 ? process.argv[3] : undefined
|
||||
if(candidate && !/^[a-z][a-z0-9-]{1,48}$/.test(candidate))throw Error('Invalid candidate')
|
||||
const base=fileURLToPath(new URL('../node_modules/.zyt-live-native/',import.meta.url))
|
||||
const dist=candidate?path.join(base,'candidates',candidate):path.join(base,'dist'),entry=path.join(dist,'live-native/index.html')
|
||||
const types={js:'text/javascript',css:'text/css',svg:'image/svg+xml',png:'image/png',jpg:'image/jpeg',jpeg:'image/jpeg',webp:'image/webp',gif:'image/gif',ico:'image/x-icon',woff:'font/woff',woff2:'font/woff2',ttf:'font/ttf',otf:'font/otf',mp3:'audio/mpeg',mp4:'video/mp4',json:'application/json',wasm:'application/wasm'}
|
||||
// Same-origin program assets. API authorization, including write permissions, belongs to the official backend.
|
||||
// Media may be served by the storage provider configured by the business; never proxy it through localhost.
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
<template>
|
||||
<div class="fold h-full cursor-pointer flex items-center px-2" @click="toggleCollapsed">
|
||||
<button
|
||||
type="button"
|
||||
class="fold h-full cursor-pointer flex items-center px-2"
|
||||
:aria-label="isCollapsed ? '展开菜单' : '收起菜单'"
|
||||
:title="isCollapsed ? '展开菜单' : '收起菜单'"
|
||||
:aria-expanded="!isCollapsed"
|
||||
@click="toggleCollapsed"
|
||||
>
|
||||
<icon :name="`local-icon-${isCollapsed ? 'expand' : 'collapse'}`" :size="18" />
|
||||
</div>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -9,8 +16,5 @@ import useAppStore from '@/stores/modules/app'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const isCollapsed = computed(() => appStore.isCollapsed)
|
||||
// 折叠展开菜单
|
||||
const toggleCollapsed = () => {
|
||||
appStore.toggleCollapsed()
|
||||
}
|
||||
const toggleCollapsed = () => appStore.toggleCollapsed()
|
||||
</script>
|
||||
|
||||
@@ -3,14 +3,7 @@
|
||||
<div class="navbar">
|
||||
<div class="flex-1 flex">
|
||||
<div class="navbar-item">
|
||||
<el-tooltip
|
||||
class="box-item"
|
||||
effect="dark"
|
||||
:content="isCollapsed ? '展开菜单' : '收起菜单'"
|
||||
placement="bottom"
|
||||
>
|
||||
<fold />
|
||||
</el-tooltip>
|
||||
<fold />
|
||||
</div>
|
||||
<div class="navbar-item">
|
||||
<el-tooltip class="box-item" effect="dark" content="刷新" placement="bottom">
|
||||
@@ -84,7 +77,6 @@ import UserDropDown from './user-drop-down.vue'
|
||||
const liveNative = import.meta.env.MODE === 'live-native'
|
||||
const appStore = useAppStore()
|
||||
const isMobile = computed(() => appStore.isMobile)
|
||||
const isCollapsed = computed(() => appStore.isCollapsed)
|
||||
const settingStore = useSettingStore()
|
||||
const { isFullscreen } = useFullscreen()
|
||||
</script>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<div class="logo" @click="handleClick">
|
||||
<image-contain :width="szie" :height="szie" :src="config.web_logo" />
|
||||
<image-contain class="logo-mark" :width="size" :height="size" :src="config.web_logo" />
|
||||
<transition name="title-width">
|
||||
<div
|
||||
v-show="showTitle"
|
||||
class="logo-title overflow-hidden whitespace-nowrap"
|
||||
:class="{ 'text-white': theme == ThemeEnum.DARK }"
|
||||
:style="{ left: `${szie + 16}px` }"
|
||||
:style="{ left: `${size + 16}px` }"
|
||||
>
|
||||
<overflow-tooltip
|
||||
:content="title || config.web_name"
|
||||
@@ -25,7 +25,7 @@ import { ThemeEnum } from '@/enums/appEnums'
|
||||
import useAppStore from '@/stores/modules/app'
|
||||
|
||||
defineProps({
|
||||
szie: { type: Number, default: 34 },
|
||||
size: { type: Number, default: 34 },
|
||||
title: { type: String },
|
||||
theme: { type: String },
|
||||
showTitle: { type: Boolean, default: true }
|
||||
@@ -66,4 +66,17 @@ const handleClick = () => {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
:root[data-admin-ui='v2'] .logo {
|
||||
// Let the menu, not the intrinsic width of the configured name, size the sidebar.
|
||||
contain: inline-size;
|
||||
.logo-mark {
|
||||
flex: none;
|
||||
:deep(.el-image__inner) { object-fit: contain; }
|
||||
}
|
||||
.logo-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,27 +1,32 @@
|
||||
<template>
|
||||
<template v-if="!route.meta?.hidden">
|
||||
<app-link v-if="!hasShowChild" :to="menuTarget">
|
||||
<el-menu-item :index="routePath">
|
||||
<app-link v-if="!hasShowChild" :to="menuTarget" :class="{ 'admin-nav-link': art }">
|
||||
<el-menu-item :index="routePath" :aria-label="art ? routeMeta?.title : undefined">
|
||||
<icon
|
||||
class="menu-item-icon"
|
||||
:size="16"
|
||||
:size="art ? 20 : 16"
|
||||
v-if="routeMeta?.icon"
|
||||
:name="routeMeta?.icon"
|
||||
/>
|
||||
<i v-else-if="art" class="menu-item-icon admin-nav-icon--empty" aria-hidden="true"
|
||||
:data-initial="titleInitial" />
|
||||
<template #title>
|
||||
<span>{{ routeMeta?.title }}</span>
|
||||
<span class="menu-name" :title="art ? routeMeta?.title : undefined">{{ routeMeta?.title }}</span>
|
||||
</template>
|
||||
</el-menu-item>
|
||||
</app-link>
|
||||
<el-sub-menu v-else :index="routePath" :popper-class="popperClass">
|
||||
<el-sub-menu v-else :index="routePath" :popper-class="popperClass"
|
||||
:aria-label="art ? routeMeta?.title : undefined">
|
||||
<template #title>
|
||||
<icon
|
||||
class="menu-item-icon"
|
||||
:size="16"
|
||||
:size="art ? 20 : 16"
|
||||
v-if="routeMeta?.icon"
|
||||
:name="routeMeta?.icon"
|
||||
/>
|
||||
<span>{{ routeMeta?.title }}</span>
|
||||
<i v-else-if="art" class="menu-item-icon admin-nav-icon--empty" aria-hidden="true"
|
||||
:data-initial="titleInitial" />
|
||||
<span class="menu-name" :title="art ? routeMeta?.title : undefined">{{ routeMeta?.title }}</span>
|
||||
</template>
|
||||
<menu-item
|
||||
v-for="item in route?.children"
|
||||
@@ -29,6 +34,7 @@
|
||||
:route="item"
|
||||
:route-path="resolvePath(item.path)"
|
||||
:popper-class="popperClass"
|
||||
:art="art"
|
||||
/>
|
||||
</el-sub-menu>
|
||||
</template>
|
||||
@@ -44,6 +50,7 @@ interface Props {
|
||||
route: RouteRecordRaw
|
||||
routePath: string
|
||||
popperClass: string
|
||||
art?: boolean
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
@@ -56,6 +63,7 @@ const hasShowChild = computed(() => {
|
||||
const routeMeta = computed(() => {
|
||||
return props.route.meta
|
||||
})
|
||||
const titleInitial = computed(() => Array.from(String(routeMeta.value?.title || '').trim())[0])
|
||||
|
||||
const resolvePath = (path: string) => {
|
||||
// The online preview uses generated absolute item IDs to preserve arbitrary
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div
|
||||
class="menu flex-1 min-h-0"
|
||||
:class="[themeClass, { 'menu--classic': classic }]"
|
||||
:class="[themeClass, classic ? 'menu--classic' : 'admin-nav-tree']"
|
||||
:style="isCollapsed ? '' : `--aside-width: ${width}px`"
|
||||
>
|
||||
<el-scrollbar>
|
||||
@@ -18,7 +18,8 @@
|
||||
:key="route.path"
|
||||
:route="route"
|
||||
:route-path="route.path"
|
||||
:popper-class="themeClass"
|
||||
:art="!classic"
|
||||
:popper-class="popperClass"
|
||||
/>
|
||||
</el-menu>
|
||||
</el-scrollbar>
|
||||
@@ -61,6 +62,10 @@ defineEmits(['select'])
|
||||
const route = useRoute()
|
||||
const activeMenu = computed<string>(() => route.meta?.activeMenu || route.path)
|
||||
const themeClass = computed(() => `theme-${props.theme}`)
|
||||
// Teleported flyouts do not inherit the palette from .side.
|
||||
const popperClass = computed(() =>
|
||||
props.classic ? themeClass.value : `admin-nav-popper side--${props.theme}`
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="side" :class="'side--' + sideTheme" :style="sideStyle">
|
||||
<div class="side" :class="['side--' + sideTheme, { 'side--collapsed': isCollapsed }]" :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">
|
||||
@@ -70,4 +70,18 @@ const handleSelect = () => {
|
||||
@apply border-r border-br-light h-full flex flex-col;
|
||||
background-color: var(--side-dark-color, var(--el-bg-color));
|
||||
}
|
||||
|
||||
// The menu sets the rail width. Center either mark within that same content
|
||||
// box (excluding the sidebar border), without the expanded header's 22px inset.
|
||||
:root[data-admin-ui='v2'] .side--collapsed {
|
||||
> :is(.logo, .admin-nav-heading) {
|
||||
justify-content: center;
|
||||
padding-inline: 0;
|
||||
gap: 0;
|
||||
}
|
||||
// v-show keeps the name mounted during its leave transition.
|
||||
:deep(.logo-title) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
// SidebarSubmenu.vue / theme.scss (Art Design Pro f3aaf58): inline and flyout
|
||||
// rows share the label/icon geometry, but not the indent or selection style.
|
||||
:root[data-admin-ui='v2'] {
|
||||
:is(.side .admin-nav-tree, .admin-nav-popper.el-menu--popup-container) {
|
||||
--nav-arrow-width: 13px;
|
||||
--nav-arrow-gap: 8px;
|
||||
--nav-row-end: var(--el-menu-base-level-padding);
|
||||
|
||||
.admin-nav-link { display: block; }
|
||||
.menu-name {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.menu-item-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: none;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-right: 8px;
|
||||
&.admin-nav-icon--empty { width: 0; }
|
||||
}
|
||||
.el-sub-menu > .el-sub-menu__title {
|
||||
padding-right: calc(var(--nav-row-end) + var(--nav-arrow-width) + var(--nav-arrow-gap));
|
||||
|
||||
// Element's width: inherit otherwise copies the *row* width onto
|
||||
// this absolutely positioned icon. Leave its native rotation intact.
|
||||
> .el-sub-menu__icon-arrow {
|
||||
position: absolute;
|
||||
right: var(--nav-row-end);
|
||||
top: 50%;
|
||||
width: var(--nav-arrow-width);
|
||||
height: var(--nav-arrow-width);
|
||||
margin: calc(var(--nav-arrow-width) / -2) 0 0;
|
||||
font-size: var(--nav-arrow-width);
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.side .menu.admin-nav-tree {
|
||||
// Element supplies --el-menu-level at each actual submenu; text-only
|
||||
// rows keep Art's empty icon wrapper margin, not an invented glyph.
|
||||
.el-menu--vertical:not(.el-menu--collapse) {
|
||||
--el-menu-base-level-padding: 20px;
|
||||
--el-menu-level-padding: 20px;
|
||||
}
|
||||
.el-menu--collapse {
|
||||
> .el-sub-menu > .el-sub-menu__title,
|
||||
> .admin-nav-link > .el-menu-item > .el-menu-tooltip__trigger {
|
||||
padding: 0;
|
||||
justify-content: center;
|
||||
|
||||
> .menu-item-icon { margin: 0; }
|
||||
// Keep even a custom top-level route without an icon identifiable.
|
||||
> .admin-nav-icon--empty {
|
||||
width: 20px;
|
||||
font: 500 14px/1 var(--el-font-family);
|
||||
&::before { content: attr(data-initial); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The first flyout lives under body; deeper flyouts may live in that popper.
|
||||
// Space the direct entries, not the li inside each router-link.
|
||||
.admin-nav-popper.el-menu--popup-container > .el-menu--popup {
|
||||
width: max-content;
|
||||
min-width: min(200px, calc(100vw - 32px));
|
||||
max-width: min(320px, calc(100vw - 32px));
|
||||
padding: 8px;
|
||||
background: var(--zyt-nav-bg);
|
||||
|
||||
> :not(:last-child) { margin-bottom: 5px; }
|
||||
.el-menu-item, .el-sub-menu__title {
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
color: var(--zyt-nav-text);
|
||||
}
|
||||
.menu-item-icon { margin: 0 5px 0 0; color: var(--zyt-nav-icon); }
|
||||
.el-menu-item:hover, .el-sub-menu__title:hover, .el-menu-item.is-active {
|
||||
color: var(--art-gray-900);
|
||||
background: var(--art-gray-200);
|
||||
}
|
||||
}
|
||||
&.dark .admin-nav-popper.el-menu--popup-container > .el-menu--popup .el-menu-item.is-active {
|
||||
background: #292a2e;
|
||||
}
|
||||
}
|
||||
@@ -4,3 +4,4 @@
|
||||
@import 'tailwind.css';
|
||||
@import 'public.scss';
|
||||
@import 'admin-v2.scss';
|
||||
@import 'admin-nav-tree.scss';
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# 甄养堂管理后台:本地分批 UI 优化
|
||||
|
||||
范围是本分支的新版界面。参考 Art Design Pro [f3aaf58](https://github.com/Daymychen/art-design-pro/tree/f3aaf58eec1a0e988f162352c33862327a484f95),保留业务密度和原本的路由、角色权限、按钮动作及统计口径。此计划不包含部署、数据迁移、真实交易或操作线上账号。
|
||||
|
||||
| 批次 | 工作及边界 | 通过条件 |
|
||||
| --- | --- | --- |
|
||||
| V1 导航 | 修复目录箭头、折叠品牌对齐,整理递归子菜单与浮层。保留现有 Element Plus 导航事件。 | 短/长标题不叠箭头,目录展开指示正确;64px 轨道的 Logo、备用标记、图标居中;可进入三级叶项。 |
|
||||
| V2 标签与交互 | V1 复审后,针对多标签、当前页辨识、窄屏或键盘操作中实测的问题,限定到显示与交互。 | 激活、关闭、返回及菜单导航保持一致,长标题不挤掉关键动作。 |
|
||||
| V3 卡片与信息层级 | V2 复审后,以真实高密度统计/列表为样板复核指标、状态、筛选和表格,优先处理最影响使用的一组差异。 | 正常数值、空数据、明暗主题及手机均可读;相同条件下原 API、字段、权限和查询结果不变。 |
|
||||
|
||||
每版采用「记录现状 → 对照上游源码 → 限定改动 → 本地浏览器验收 → 复审并决定下一版」。使用全新浏览器配置,正式 API 域名由离线测试桩拦截。每版保留 Git 提交、实测结果与截图,验收通过才切换本机静态资源;失败保留上一版。没有足够证据的全站风格改动不混入本版。
|
||||
|
||||
## 分版记录
|
||||
|
||||
### V1:侧栏
|
||||
|
||||
- 上游对照:`art-sidebar-menu/widget/SidebarSubmenu.vue` 与 `theme.scss`。保留 Element Plus 原有展开、浮层、旋转和路由,只固定箭头图形宽度,为标题预留空间,折叠时以整条菜单轨道居中。
|
||||
- 离线 Chrome:214px 菜单行的箭头宽由 198px 回到 13px;“医生管理”文字到箭头的间距由 -101px 到 84px。品牌、备用标记、目录及叶项图标在 64px 轨道的中心均为 x=32;180px 深色、230px 常规、390px 抽屉均能打开三级叶项,标签起点依次为 49/69/89px。全屏壳和登录/路由夹具回归通过,无正式接口请求。
|
||||
- 复审决定:390px 窗口里,原工作标签的长标题占 457px,而轨道只有 280px;操作入口没有可访问名称。V2 限定修这两处及标签切换时的地址保留,不更换页面缓存或标签管理机制。
|
||||
Reference in New Issue
Block a user