分组导航改为内容顶部横向胶囊导航并随页面滚动,取消 sticky 侧栏与双列布局;滚动定位改为自动识别滚动容器并计入顶部 sticky 头部高度,点击时立即高亮并对目标分组做短暂描边,移除会与平滑滚动冲突的滚动监听高亮。
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
|
||||
<main class="settings-body" :aria-busy="loading">
|
||||
<aside class="settings-subnav" aria-label="页内分组导航">
|
||||
<nav class="settings-subnav" aria-label="页内分组导航">
|
||||
<span class="settings-subnav__label">分组导航</span>
|
||||
<button
|
||||
v-for="item in groupNavItems"
|
||||
@@ -28,7 +28,7 @@
|
||||
<span>{{ item.label }}</span>
|
||||
<em v-if="item.badge">{{ item.badge }}</em>
|
||||
</button>
|
||||
</aside>
|
||||
</nav>
|
||||
|
||||
<div class="settings-content">
|
||||
<div v-if="activeSection === 'runtime'" class="settings-groups">
|
||||
@@ -420,7 +420,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { ArrowDownOutlined, ArrowUpOutlined, CopyOutlined, DownOutlined, ExportOutlined } from '@ant-design/icons-vue'
|
||||
@@ -689,33 +689,40 @@ const groupNavItems = computed<Array<{ id: string; label: string; badge?: string
|
||||
}
|
||||
return [{ id: 'settings-group-account-info', label: '账号信息' }]
|
||||
})
|
||||
const syncActiveGroup = () => {
|
||||
const items = groupNavItems.value
|
||||
if (!items.length) {
|
||||
activeGroup.value = ''
|
||||
return
|
||||
const resolveScrollContainer = (element: HTMLElement): HTMLElement | null => {
|
||||
let parent = element.parentElement
|
||||
while (parent && parent !== document.body && parent !== document.documentElement) {
|
||||
const style = window.getComputedStyle(parent)
|
||||
if (/(auto|scroll)/.test(style.overflowY) && parent.scrollHeight > parent.clientHeight + 1) return parent
|
||||
parent = parent.parentElement
|
||||
}
|
||||
let current = items[0]?.id || ''
|
||||
items.forEach(item => {
|
||||
const element = document.getElementById(item.id)
|
||||
if (element && element.getBoundingClientRect().top <= 120) current = item.id
|
||||
})
|
||||
activeGroup.value = current
|
||||
return null
|
||||
}
|
||||
const stickyHeaderOffset = () => {
|
||||
const header = document.querySelector<HTMLElement>('.admin-layout .header') || document.querySelector<HTMLElement>('.header')
|
||||
if (!header) return 0
|
||||
const position = window.getComputedStyle(header).position
|
||||
return position === 'sticky' || position === 'fixed' ? header.getBoundingClientRect().height : 0
|
||||
}
|
||||
const scrollToGroup = (id: string) => {
|
||||
const element = document.getElementById(id)
|
||||
if (!element) return
|
||||
window.scrollTo({ top: element.getBoundingClientRect().top + window.scrollY - 16, behavior: 'smooth' })
|
||||
const offset = stickyHeaderOffset() + 12
|
||||
const container = resolveScrollContainer(element)
|
||||
if (container) {
|
||||
const top = element.getBoundingClientRect().top - container.getBoundingClientRect().top + container.scrollTop - offset
|
||||
container.scrollTo({ top: Math.max(0, top), behavior: 'smooth' })
|
||||
} else {
|
||||
const top = element.getBoundingClientRect().top + window.scrollY - offset
|
||||
window.scrollTo({ top: Math.max(0, top), behavior: 'smooth' })
|
||||
}
|
||||
activeGroup.value = id
|
||||
element.classList.add('is-located')
|
||||
window.setTimeout(() => element.classList.remove('is-located'), 1500)
|
||||
}
|
||||
let scrollFrame = 0
|
||||
const handleWindowScroll = () => {
|
||||
if (scrollFrame) return
|
||||
scrollFrame = window.requestAnimationFrame(() => {
|
||||
scrollFrame = 0
|
||||
syncActiveGroup()
|
||||
})
|
||||
}
|
||||
watch(activeSection, () => {
|
||||
activeGroup.value = groupNavItems.value[0]?.id || ''
|
||||
}, { immediate: true })
|
||||
const runProbe = async (service: string, operation: string) => {
|
||||
const key = `${service}:${operation}`
|
||||
testingProbe.value = key
|
||||
@@ -1006,20 +1013,7 @@ const saveStorageReadOrder = async () => {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load().then(() => nextTick(syncActiveGroup))
|
||||
nextTick(syncActiveGroup)
|
||||
window.addEventListener('scroll', handleWindowScroll, { passive: true })
|
||||
window.addEventListener('resize', syncActiveGroup)
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('scroll', handleWindowScroll)
|
||||
window.removeEventListener('resize', syncActiveGroup)
|
||||
})
|
||||
watch(activeSection, () => {
|
||||
nextTick(() => {
|
||||
activeGroup.value = groupNavItems.value[0]?.id || ''
|
||||
syncActiveGroup()
|
||||
})
|
||||
void load()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1034,16 +1028,22 @@ watch(activeSection, () => {
|
||||
.settings-tab.is-active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -11px; height: 2px; border-radius: 2px; background: var(--theme-primary); }
|
||||
.settings-health { display: inline-flex; align-items: center; gap: 7px; color: var(--admin-mobile-muted); font-size: 12px; white-space: nowrap; }
|
||||
.settings-health i { width: 7px; height: 7px; border-radius: 50%; background: var(--theme-primary); }
|
||||
.settings-body { display: grid; grid-template-columns: 194px minmax(0, 1fr); gap: 18px; align-items: start; }
|
||||
.settings-subnav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; padding: 8px; border: 1px solid var(--admin-mobile-border); border-radius: 12px; background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent); }
|
||||
.settings-subnav__label { padding: 6px 8px 8px; color: var(--admin-mobile-muted); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
|
||||
.settings-subnav__item { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; padding: 7px 9px; border: 0; border-radius: 7px; background: none; color: var(--admin-mobile-muted); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
|
||||
.settings-subnav__item:hover { background: color-mix(in srgb, var(--theme-primary) 6%, transparent); color: var(--theme-primary-action); }
|
||||
.settings-subnav__item.is-active { background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-weight: 700; }
|
||||
.settings-body { display: block; }
|
||||
.settings-subnav { display: flex; max-width: 100%; align-items: center; gap: 6px; margin-bottom: 12px; padding: 7px; overflow-x: auto; border: 1px solid var(--admin-mobile-border); border-radius: 10px; background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent); scrollbar-width: none; }
|
||||
.settings-subnav::-webkit-scrollbar { display: none; }
|
||||
.settings-subnav__label { display: none; }
|
||||
.settings-subnav__item { display: flex; flex: none; width: auto; align-items: center; justify-content: space-between; gap: 6px; min-height: 30px; padding: 5px 11px; border: 1px solid transparent; border-radius: 999px; background: color-mix(in srgb, var(--theme-primary) 4%, transparent); color: var(--admin-mobile-muted); font: inherit; font-size: 12px; text-align: left; white-space: nowrap; cursor: pointer; }
|
||||
.settings-subnav__item:hover { border-color: color-mix(in srgb, var(--theme-primary) 35%, var(--admin-mobile-border)); background: color-mix(in srgb, var(--theme-primary) 7%, transparent); color: var(--theme-primary-action); }
|
||||
.settings-subnav__item.is-active { border-color: color-mix(in srgb, var(--theme-primary) 35%, var(--admin-mobile-border)); background: var(--admin-mobile-accent-soft); color: var(--theme-primary-action); font-weight: 700; }
|
||||
.settings-subnav__item em { flex: none; min-width: 18px; height: 18px; padding: 0 5px; border: 1px solid var(--admin-mobile-border); border-radius: 9px; background: var(--theme-card-bg); color: var(--admin-mobile-muted); font-size: 10px; font-style: normal; line-height: 16px; text-align: center; }
|
||||
.settings-content { min-width: 0; }
|
||||
.settings-groups { display: flex; flex-direction: column; gap: 14px; }
|
||||
.settings-group { min-width: 0; scroll-margin-top: 16px; border: 1px solid var(--admin-mobile-border); border-radius: 14px; background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent); box-shadow: 0 1px 2px rgba(23, 33, 31, .03); }
|
||||
.settings-group.is-located { animation: settings-locate 1.5s ease-out; }
|
||||
@keyframes settings-locate {
|
||||
0% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-primary) 42%, transparent); border-color: color-mix(in srgb, var(--theme-primary) 55%, var(--admin-mobile-border)); }
|
||||
100% { box-shadow: 0 1px 2px rgba(23, 33, 31, .03); }
|
||||
}
|
||||
.settings-group__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 15px 18px 12px; border-bottom: 1px solid var(--admin-mobile-border); }
|
||||
.settings-group__head-main { min-width: 0; }
|
||||
.settings-group__title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||
@@ -1152,13 +1152,6 @@ watch(activeSection, () => {
|
||||
.field-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.field--wide { grid-column: auto; }
|
||||
}
|
||||
@media (max-width: 1180px) {
|
||||
.settings-body { grid-template-columns: 1fr; gap: 12px; }
|
||||
.settings-subnav { position: static; flex-direction: row; align-items: center; gap: 4px; padding: 7px; overflow-x: auto; scrollbar-width: none; }
|
||||
.settings-subnav::-webkit-scrollbar { display: none; }
|
||||
.settings-subnav__label { display: none; }
|
||||
.settings-subnav__item { width: auto; flex: none; min-height: 30px; padding: 5px 10px; white-space: nowrap; }
|
||||
}
|
||||
@media (max-width: 960px) {
|
||||
.field-grid.cols-2, .field-grid.cols-3 { grid-template-columns: 1fr; }
|
||||
.field__desc { min-height: 0; }
|
||||
|
||||
Reference in New Issue
Block a user