feat(admin): 增加启动与导航反馈并保护工作标签状态
This commit is contained in:
@@ -10,6 +10,7 @@ import useSettingStore, { 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'
|
||||
import RouteLoadNotice from './components/route-load-notice/index.vue'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const settings = useSettingStore()
|
||||
@@ -58,6 +59,7 @@ watch(
|
||||
<template>
|
||||
<el-config-provider :locale="elConfig.locale" :z-index="elConfig.zIndex">
|
||||
<router-view />
|
||||
<route-load-notice />
|
||||
<ChatNotifyToast v-if="showChatNotifyToast" />
|
||||
<!-- 复诊到期弹窗(右下角):与会话通知并列挂载,复用同一条件避免未绑企微时无意义轮询 -->
|
||||
<RevisitDueToast v-if="showChatNotifyToast" />
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<el-date-picker
|
||||
v-model="dateRangeModel"
|
||||
type="daterange"
|
||||
popper-class="list-time-filter-calendar"
|
||||
value-format="YYYY-MM-DD"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
@@ -38,6 +39,7 @@
|
||||
v-if="timeType === 'custom'"
|
||||
v-model="dateRangeModel"
|
||||
type="daterange"
|
||||
popper-class="list-time-filter-calendar"
|
||||
value-format="YYYY-MM-DD"
|
||||
range-separator="至"
|
||||
start-placeholder="开始日期"
|
||||
@@ -94,3 +96,26 @@ const emit = defineEmits<{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- The picker is teleported outside its form. Limit this override to the shared
|
||||
list filter, the new admin profile and narrow screens; keep both months reachable. -->
|
||||
<style lang="scss">
|
||||
@media (max-width: 640px) {
|
||||
:root[data-admin-ui='v2'] .list-time-filter-calendar .el-date-range-picker {
|
||||
width: min(360px, calc(100vw - 24px));
|
||||
|
||||
.el-picker-panel__body-wrapper {
|
||||
max-height: min(62vh, 480px);
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
.el-picker-panel__body { min-width: 0; }
|
||||
.el-date-range-picker__content {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
&.is-left { border-right: 0; border-bottom: 1px solid var(--el-border-color-lighter); }
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<div class="pagination">
|
||||
<div class="pagination zyt-pagination" :class="{ 'zyt-pagination--standard': effectiveLayout === standardLayout }">
|
||||
<el-pagination
|
||||
v-bind="props"
|
||||
:pager-count="5"
|
||||
v-model:currentPage="pager.page"
|
||||
v-model:pageSize="pager.size"
|
||||
:page-sizes="pageSizes"
|
||||
:layout="layout"
|
||||
:layout="effectiveLayout"
|
||||
:total="pager.count"
|
||||
:hide-on-single-page="false"
|
||||
@size-change="sizeChange"
|
||||
@@ -23,9 +23,10 @@ interface Props {
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
modelValue: () => ({}),
|
||||
pageSizes: () => [15, 20, 30, 40],
|
||||
layout: 'total, sizes, prev, pager, next, jumper'
|
||||
pageSizes: () => [15, 20, 30, 40]
|
||||
})
|
||||
const standardLayout = 'total, sizes, prev, pager, next, jumper'
|
||||
const effectiveLayout = computed(() => props.layout ?? standardLayout)
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'change'): void
|
||||
@@ -48,3 +49,37 @@ const pageChange = () => {
|
||||
emit('change')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
// A sidebar, dialog or split view can leave less room than the viewport.
|
||||
:root[data-admin-ui='v2'] .zyt-pagination {
|
||||
container: zyt-pages / inline-size;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
> .el-pagination { justify-content: flex-end; flex-wrap: wrap; }
|
||||
}
|
||||
@container zyt-pages (max-width: 740px) {
|
||||
.zyt-pagination > .el-pagination {
|
||||
--el-pagination-item-gap: 0px;
|
||||
gap: 6px;
|
||||
.el-pagination__rightwrapper, .el-pager { max-width: 100%; flex-wrap: wrap; }
|
||||
.el-pager { display: flex; justify-content: center; }
|
||||
// The classic stylesheet hides these slots on mobile. Keep only the
|
||||
// slots actually requested by this instance's layout.
|
||||
.el-pagination__sizes, .el-pagination__jump { display: inline-flex !important; }
|
||||
}
|
||||
// Only our default order gets explicit rows. Custom layouts keep their DOM order.
|
||||
.zyt-pagination--standard > .el-pagination {
|
||||
display: grid;
|
||||
grid-template-columns: 32px repeat(2, minmax(0, 1fr)) 32px;
|
||||
column-gap: 0;
|
||||
max-width: 360px;
|
||||
margin-inline-start: auto;
|
||||
.el-pagination__total, .el-pagination__sizes, .el-pager { grid-column: span 2; }
|
||||
.el-pagination__total { white-space: normal; overflow-wrap: anywhere; }
|
||||
.el-pagination__sizes { justify-self: end; max-width: 100%; }
|
||||
.el-pagination__sizes .el-select { max-width: 100%; }
|
||||
.el-pagination__jump { grid-column: 1 / -1; justify-self: end; }
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<template>
|
||||
<aside v-if="failedRoute" class="route-load-notice" aria-label="页面加载提示">
|
||||
<div role="status">
|
||||
<strong>页面未能打开</strong>
|
||||
<p>当前页面已保留。请检查网络后重试;如需刷新,请先保存正在填写的内容。</p>
|
||||
</div>
|
||||
<div class="notice-actions">
|
||||
<el-button size="small" @click="reportRouteLoad()">关闭提示</el-button>
|
||||
<el-button size="small" type="primary" @click="retry">重试打开</el-button>
|
||||
</div>
|
||||
</aside>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { useRouter } from 'vue-router'
|
||||
import { failedRoute, reportRouteLoad } from '@/utils/route-load-notice'
|
||||
|
||||
const router = useRouter()
|
||||
function retry() {
|
||||
const target = failedRoute.value
|
||||
if (target) void router.push(target).catch(() => { /* router.onError owns the feedback */ })
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.route-load-notice {
|
||||
position: fixed; z-index: 2050; inset-inline-end: 16px; bottom: max(16px, env(safe-area-inset-bottom));
|
||||
width: min(360px, calc(100vw - 32px)); padding: 16px; border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--zyt-radius, 10px); color: var(--el-text-color-primary);
|
||||
background: var(--el-bg-color-overlay); box-shadow: var(--el-box-shadow-light);
|
||||
}
|
||||
.route-load-notice p { margin: 4px 0 12px; color: var(--el-text-color-regular); font-size: 13px; }
|
||||
.notice-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
||||
.notice-actions .el-button + .el-button { margin: 0; }
|
||||
</style>
|
||||
@@ -26,17 +26,17 @@ useWatchRoute((route) => {
|
||||
.app-breadcrumb {
|
||||
:deep(.el-breadcrumb__item) {
|
||||
.el-breadcrumb__inner {
|
||||
color: #303133;
|
||||
color: var(--zyt-text, #303133);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
&:last-child .el-breadcrumb__inner {
|
||||
color: #303133;
|
||||
color: var(--zyt-ink, #303133);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-breadcrumb__separator) {
|
||||
color: #606266;
|
||||
color: var(--zyt-muted, #606266);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -6,9 +6,7 @@
|
||||
<fold />
|
||||
</div>
|
||||
<div class="navbar-item">
|
||||
<el-tooltip class="box-item" effect="dark" content="刷新" placement="bottom">
|
||||
<refresh />
|
||||
</el-tooltip>
|
||||
<refresh />
|
||||
</div>
|
||||
<div class="flex items-center px-2" v-if="!isMobile && settingStore.showCrumb">
|
||||
<breadcrumb />
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
<template>
|
||||
<div class="refresh cursor-pointer h-full flex items-center px-2" @click="refreshView">
|
||||
<button type="button" class="refresh cursor-pointer h-full flex items-center px-2"
|
||||
aria-label="刷新当前页面" title="刷新当前页面" @click="refreshView">
|
||||
<icon name="el-icon-RefreshRight" :size="18" />
|
||||
</div>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import useAppStore from '@/stores/modules/app'
|
||||
import useTabsStore from '@/stores/modules/multipleTabs'
|
||||
|
||||
const appStore = useAppStore()
|
||||
// 刷新页面
|
||||
const tabs = useTabsStore()
|
||||
const route = useRoute()
|
||||
const refreshView = () => {
|
||||
appStore.refreshView()
|
||||
if (!tabs.refreshCachedTab(route.fullPath)) appStore.refreshView()
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
<main class="main-wrap h-full bg-page">
|
||||
<el-scrollbar>
|
||||
<div class="admin-content px-2 py-4">
|
||||
<router-view v-if="isRouteShow" v-slot="{ Component, route }">
|
||||
<router-view v-slot="{ Component, route: viewRoute }">
|
||||
<keep-alive :include="includeList" :max="20">
|
||||
<component :is="Component" :key="route.fullPath" />
|
||||
<component v-if="Component && isRouteShow && currentView.shell" :is="currentView.shell" :key="currentView.id">
|
||||
<component :is="Component" :key="viewRoute.fullPath" />
|
||||
</component>
|
||||
<component v-else-if="Component && isRouteShow" :is="Component" :key="viewRoute.fullPath" />
|
||||
</keep-alive>
|
||||
</router-view>
|
||||
</div>
|
||||
@@ -13,15 +16,40 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, defineComponent, watch, type Component } from 'vue'
|
||||
|
||||
import useAppStore from '@/stores/modules/app'
|
||||
import useTabsStore from '@/stores/modules/multipleTabs'
|
||||
import useSettingStore from '@/stores/modules/setting'
|
||||
|
||||
const appStore = useAppStore()
|
||||
const tabsStore = useTabsStore()
|
||||
const settingStore = useSettingStore()
|
||||
const tabs = useTabsStore()
|
||||
const settings = useSettingStore()
|
||||
const route = useRoute()
|
||||
const isRouteShow = computed(() => appStore.isRouteShow)
|
||||
const includeList = computed(() => (settingStore.openMultipleTabs ? tabsStore.getCacheTabList : []))
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
// KeepAlive includes/excludes component names, not URLs. Give each opted-in
|
||||
// work tab its own transparent, named cache boundary so removing one page
|
||||
// cannot also evict another page backed by the same Vue component.
|
||||
const cacheName = (id: number) => 'AdminCachedView' + id
|
||||
const shells = new Map<number, Component>()
|
||||
const openIds = computed(() => tabs.tabList.flatMap(tab => tab.cacheId ? [tab.cacheId] : []))
|
||||
const includeList = computed(() => settings.openMultipleTabs ? openIds.value.map(cacheName) : [])
|
||||
watch(openIds, ids => {
|
||||
for (const id of shells.keys()) if (!ids.includes(id)) shells.delete(id)
|
||||
})
|
||||
const currentView = computed<{ path: string; id?: number; shell?: Component }>((previous) => {
|
||||
const path = route.fullPath
|
||||
const id = tabs.tabList.find(item => item.fullPath === path)?.cacheId
|
||||
// While the router is leaving a just-closed tab, don't mount a throwaway
|
||||
// copy of its business page. KeepAlive will prune it after the route commit.
|
||||
if (!id) return previous?.path === path ? previous : { path }
|
||||
if (!shells.has(id)) {
|
||||
shells.set(id, defineComponent({
|
||||
name: cacheName(id),
|
||||
setup: (_, { slots }) => () => slots.default?.()[0] ?? null
|
||||
}))
|
||||
}
|
||||
return { path, id, shell: shells.get(id) }
|
||||
})
|
||||
</script>
|
||||
|
||||
+15
-3
@@ -6,8 +6,20 @@ import { createApp } from 'vue'
|
||||
|
||||
import App from './App.vue'
|
||||
import install from './install'
|
||||
import router from './router'
|
||||
|
||||
const app = createApp(App)
|
||||
async function start() {
|
||||
const app = createApp(App)
|
||||
app.use(install)
|
||||
// The static boot panel remains in place through auth redirects and lazy route imports.
|
||||
await router.isReady()
|
||||
app.mount('#app')
|
||||
document.getElementById('admin-boot')?.remove()
|
||||
window.dispatchEvent(new Event('admin:mounted'))
|
||||
}
|
||||
|
||||
app.use(install)
|
||||
app.mount('#app')
|
||||
start().catch(error => {
|
||||
const panel = document.getElementById('admin-boot')
|
||||
if (panel) panel.dataset.state = 'error'
|
||||
console.error('管理后台启动失败:', error)
|
||||
})
|
||||
|
||||
@@ -11,6 +11,8 @@ import { INDEX_ROUTE, INDEX_ROUTE_NAME } from './router/routes'
|
||||
import useTabsStore from './stores/modules/multipleTabs'
|
||||
import useUserStore from './stores/modules/user'
|
||||
import { clearAuthInfo } from './utils/auth'
|
||||
import { installNavigationFeedback } from './utils/nav-loading'
|
||||
import { reportRouteLoad } from './utils/route-load-notice'
|
||||
import { isExternal } from './utils/validate'
|
||||
|
||||
function firstQueryString(q: LocationQueryValue | LocationQueryValue[] | undefined): string {
|
||||
@@ -82,6 +84,7 @@ const changePasswordPath = '/change-password'
|
||||
const bindWorkWechatPath = '/bind-work-wechat'
|
||||
// 免登录白名单
|
||||
const whiteList: string[] = [PageEnum.LOGIN, PageEnum.ERROR_403]
|
||||
installNavigationFeedback(router, document, reportRouteLoad)
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
document.title = to.meta.title ?? config.title
|
||||
const userStore = useUserStore()
|
||||
|
||||
@@ -13,6 +13,7 @@ import { isExternal } from '@/utils/validate'
|
||||
interface TabItem {
|
||||
name: RouteRecordName
|
||||
fullPath: string
|
||||
cacheId?: number
|
||||
path: string
|
||||
title?: string
|
||||
query?: LocationQuery
|
||||
@@ -20,9 +21,8 @@ interface TabItem {
|
||||
}
|
||||
|
||||
interface TabsSate {
|
||||
cacheTabList: Set<string>
|
||||
nextCacheId: number
|
||||
tabList: TabItem[]
|
||||
tasMap: Record<string, TabItem>
|
||||
indexRouteName: RouteRecordName
|
||||
}
|
||||
|
||||
@@ -50,52 +50,33 @@ const isCannotAddRoute = (route: RouteLocationNormalized, router: Router) => {
|
||||
return false
|
||||
}
|
||||
|
||||
const findTabsIndex = (fullPath: string, tabList: TabItem[]) => {
|
||||
return tabList.findIndex((item) => item.fullPath === fullPath)
|
||||
}
|
||||
|
||||
const getComponentName = (route: RouteLocationNormalized) => {
|
||||
return route.matched.at(-1)?.components?.default?.name
|
||||
}
|
||||
|
||||
// fullPath already includes resolved dynamic params, encoded query, and fragment.
|
||||
export const getRouteParams = (tabItem: TabItem) => tabItem.fullPath
|
||||
|
||||
const useTabsStore = defineStore({
|
||||
id: 'tabs',
|
||||
state: (): TabsSate => ({
|
||||
cacheTabList: new Set(),
|
||||
nextCacheId: 0,
|
||||
tabList: [],
|
||||
tasMap: {},
|
||||
indexRouteName: ''
|
||||
}),
|
||||
getters: {
|
||||
getTabList(): TabItem[] {
|
||||
return this.tabList
|
||||
},
|
||||
getCacheTabList(): string[] {
|
||||
return Array.from(this.cacheTabList)
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
setRouteName(name: RouteRecordName) {
|
||||
this.indexRouteName = name
|
||||
},
|
||||
addCache(componentName?: string) {
|
||||
if (componentName) this.cacheTabList.add(componentName)
|
||||
},
|
||||
removeCache(componentName?: string) {
|
||||
if (componentName && this.cacheTabList.has(componentName)) {
|
||||
this.cacheTabList.delete(componentName)
|
||||
}
|
||||
},
|
||||
clearCache() {
|
||||
this.cacheTabList.clear()
|
||||
refreshCachedTab(fullPath: string) {
|
||||
const tab = this.tabList.find(item => item.fullPath === fullPath)
|
||||
if (!tab?.cacheId) return false
|
||||
tab.cacheId = ++this.nextCacheId
|
||||
return true
|
||||
},
|
||||
resetState() {
|
||||
this.cacheTabList = new Set()
|
||||
this.tabList = []
|
||||
this.tasMap = {}
|
||||
this.indexRouteName = ''
|
||||
},
|
||||
addTab(router: Router) {
|
||||
@@ -103,23 +84,19 @@ const useTabsStore = defineStore({
|
||||
const { name, query, meta, params, fullPath, path } = route
|
||||
if (isCannotAddRoute(route, router)) return
|
||||
const hasTabIndex = getHasTabIndex(fullPath!, this.tabList)
|
||||
const componentName = getComponentName(route)
|
||||
const tabItem = {
|
||||
name: name!,
|
||||
path,
|
||||
fullPath,
|
||||
cacheId: meta.keepAlive ? (this.tabList[hasTabIndex]?.cacheId ?? ++this.nextCacheId) : undefined,
|
||||
title: meta?.title,
|
||||
query,
|
||||
params
|
||||
}
|
||||
if (meta?.keepAlive) {
|
||||
this.addCache(componentName)
|
||||
}
|
||||
|
||||
// 已存在相同 fullPath:刷新该项(标题/query 等可能变化)
|
||||
if (hasTabIndex !== -1) {
|
||||
this.tabList[hasTabIndex] = tabItem
|
||||
this.tasMap[fullPath!] = tabItem
|
||||
return
|
||||
}
|
||||
|
||||
@@ -133,54 +110,26 @@ const useTabsStore = defineStore({
|
||||
const keepIdx = dupIndices[0]
|
||||
for (let k = dupIndices.length - 1; k >= 1; k--) {
|
||||
const idx = dupIndices[k]
|
||||
delete this.tasMap[this.tabList[idx].fullPath]
|
||||
this.tabList.splice(idx, 1)
|
||||
}
|
||||
const prev = this.tabList[keepIdx]
|
||||
if (prev.fullPath !== fullPath) {
|
||||
delete this.tasMap[prev.fullPath]
|
||||
}
|
||||
this.tabList[keepIdx] = tabItem
|
||||
this.tasMap[fullPath!] = tabItem
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.tasMap[fullPath!] = tabItem
|
||||
this.tabList.push(tabItem)
|
||||
},
|
||||
removeTab(fullPath: string, router: Router) {
|
||||
const { currentRoute, push } = router
|
||||
const index = findTabsIndex(fullPath, this.tabList)
|
||||
// 移除tab
|
||||
if (this.tabList.length > 1) {
|
||||
index !== -1 && this.tabList.splice(index, 1)
|
||||
const index = getHasTabIndex(fullPath, this.tabList)
|
||||
if (index < 0 || this.tabList.length < 2) return
|
||||
this.tabList.splice(index, 1)
|
||||
if (fullPath === currentRoute.value.fullPath) {
|
||||
push(getRouteParams(this.tabList[Math.max(0, index - 1)]))
|
||||
}
|
||||
const componentName = getComponentName(currentRoute.value)
|
||||
this.removeCache(componentName)
|
||||
if (fullPath !== currentRoute.value.fullPath) {
|
||||
return
|
||||
}
|
||||
// 删除选中的tab
|
||||
let toTab: TabItem | null = null
|
||||
|
||||
if (index === 0) {
|
||||
toTab = this.tabList[index]
|
||||
} else {
|
||||
toTab = this.tabList[index - 1]
|
||||
}
|
||||
|
||||
const toRoute = getRouteParams(toTab)
|
||||
push(toRoute)
|
||||
},
|
||||
removeOtherTab(route: RouteLocationNormalized) {
|
||||
this.tabList = this.tabList.filter((item) => item.fullPath == route.fullPath)
|
||||
const componentName = getComponentName(route)
|
||||
this.cacheTabList.forEach((name) => {
|
||||
if (componentName !== name) {
|
||||
this.removeCache(name)
|
||||
}
|
||||
})
|
||||
this.tabList = this.tabList.filter(item => item.fullPath === route.fullPath)
|
||||
},
|
||||
removeAllTab(router: Router) {
|
||||
const { push, currentRoute } = router
|
||||
@@ -190,7 +139,6 @@ const useTabsStore = defineStore({
|
||||
return
|
||||
}
|
||||
this.tabList = []
|
||||
this.clearCache()
|
||||
push(PageEnum.INDEX)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
--zyt-shadow: none; // Art's default boxBorderMode.
|
||||
--zyt-primary: var(--el-color-primary);
|
||||
--zyt-accent: var(--el-color-primary);
|
||||
// Keep status indicators legible even with a near-white/black custom accent.
|
||||
--zyt-feedback-ink: var(--zyt-text);
|
||||
--zyt-loading-surface: var(--zyt-surface);
|
||||
--zyt-accent-soft: var(--el-color-primary-light-9);
|
||||
--zyt-accent-border: var(--el-color-primary-light-8);
|
||||
--zyt-nav-bg: #fff;
|
||||
@@ -72,6 +75,11 @@
|
||||
--table-header-bg-color: var(--zyt-surface-subtle);
|
||||
@include art-status-colors(#fff, #000);
|
||||
|
||||
@supports (color: color-mix(in srgb, black, white)) {
|
||||
--zyt-feedback-ink: color-mix(in srgb, var(--zyt-primary) 30%, var(--zyt-ink));
|
||||
--zyt-loading-surface: color-mix(in srgb, var(--zyt-surface) 90%, transparent);
|
||||
}
|
||||
|
||||
.side--dark, &.dark {
|
||||
--zyt-nav-bg: #191a23;
|
||||
--zyt-nav-title: #d9dadb;
|
||||
@@ -242,7 +250,40 @@
|
||||
--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; }
|
||||
// Ring the visible control, not the small or hidden input inside it.
|
||||
// An outline leaves Element's error border and checked state intact.
|
||||
:is(button, a[href], summary, [role='button'], [role='tab'], [role='menuitem'], [role='option']):focus-visible,
|
||||
.el-textarea__inner:focus-visible,
|
||||
:is(.el-input__wrapper, .el-select__wrapper, .el-checkbox__input, .el-radio__input, .el-switch):has(input:focus-visible) {
|
||||
outline: 2px solid var(--zyt-feedback-ink);
|
||||
outline-offset: var(--zyt-focus-offset, 2px);
|
||||
}
|
||||
.side, .app-tabs { --zyt-focus-offset: -2px; }
|
||||
.side--dark { --zyt-feedback-ink: var(--zyt-nav-title); }
|
||||
|
||||
// Match the surface beneath local table/panel loads, without changing a
|
||||
// full-screen lock, the original request lifecycle, or an explicit mask color.
|
||||
.el-loading-mask:not(.is-fullscreen) {
|
||||
--el-mask-color: var(--zyt-loading-surface);
|
||||
--el-loading-spinner-size: 28px;
|
||||
border-radius: inherit;
|
||||
.el-loading-spinner {
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 5px;
|
||||
margin-top: 0;
|
||||
transform: translateY(-50%);
|
||||
.path { stroke: var(--zyt-feedback-ink); stroke-width: 3.5; }
|
||||
.el-loading-text { margin: 0; color: var(--zyt-text); }
|
||||
}
|
||||
}
|
||||
// Keep the native busy icon and button label visible without the extra veil.
|
||||
.el-button.is-loading { --el-mask-color-extra-light: transparent; }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.el-loading-mask, .el-button, .el-select__wrapper { transition-duration: 0s; }
|
||||
.el-loading-spinner .circular, .el-loading-spinner .path,
|
||||
.el-button.is-loading .el-icon.is-loading { animation: none; }
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.admin-content { padding-inline: 15px; }
|
||||
.navbar, .app-header .app-tabs { padding-inline: 15px; }
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { isNavigationFailure, NavigationFailureType, type RouteLocationNormalized, type Router } from 'vue-router'
|
||||
|
||||
/**
|
||||
* Observe the navigation, never decide it. Keep one lightweight bar across redirects
|
||||
* and overlapping guards; a late failure for an older route doesn't own the bar.
|
||||
*/
|
||||
export function installNavigationFeedback(router: Router, doc: Document = document,
|
||||
notify?: (failedPath?: string) => void) {
|
||||
let owner: RouteLocationNormalized | undefined
|
||||
let timer: ReturnType<typeof setTimeout> | undefined
|
||||
let bar: HTMLElement | undefined
|
||||
|
||||
function stop() {
|
||||
clearTimeout(timer)
|
||||
timer = undefined
|
||||
owner = undefined
|
||||
bar?.remove()
|
||||
bar = undefined
|
||||
}
|
||||
|
||||
function owns(to: RouteLocationNormalized) {
|
||||
return owner === to || (to.redirectedFrom && to.redirectedFrom === (owner?.redirectedFrom ?? owner))
|
||||
}
|
||||
|
||||
router.beforeEach(to => {
|
||||
if (doc.getElementById('admin-boot')) return
|
||||
notify?.()
|
||||
owner = to
|
||||
if (timer !== undefined || bar) return
|
||||
timer = setTimeout(() => {
|
||||
timer = undefined
|
||||
bar = doc.createElement('div')
|
||||
bar.id = 'admin-route-progress'
|
||||
bar.setAttribute('role', 'progressbar')
|
||||
bar.setAttribute('aria-label', '正在打开页面')
|
||||
doc.body.appendChild(bar)
|
||||
}, 180)
|
||||
})
|
||||
router.afterEach((to, _from, failure) => {
|
||||
// Duplicates bypass beforeEach, including redirects back to the current route.
|
||||
if (owns(to) || isNavigationFailure(failure, NavigationFailureType.duplicated)) stop()
|
||||
})
|
||||
router.onError((error, to) => {
|
||||
if (owns(to)) {
|
||||
stop()
|
||||
// Page assets failed after the app started. Don't reload over an
|
||||
// unsaved form or mistake a background request for a route error.
|
||||
notify?.(to.fullPath)
|
||||
}
|
||||
console.error('路由导航失败:', error)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { shallowRef } from 'vue'
|
||||
|
||||
// Ephemeral UI state. Navigation targets are issued only by the existing router.
|
||||
export const failedRoute = shallowRef<string>()
|
||||
export function reportRouteLoad(path?: string) { failedRoute.value = path }
|
||||
Reference in New Issue
Block a user