feat(ui): improve admin and docs navigation

This commit is contained in:
XiaoDaiGua-Ray 2026-12-03 10:17:41 +08:00
parent c3458eef4c
commit 5c01d29c50
No known key found for this signature in database
13 changed files with 478 additions and 287 deletions

View File

@ -31,12 +31,18 @@ const menu = (
const setupDashboard = async () => {
const router = createRouter({
history: createMemoryHistory(),
routes: ['/dashboard', '/template-hooks', '/layout-demo', '/svg-icons'].map(
(path) => ({
path,
component: { render: () => null },
}),
),
routes: [
'/dashboard',
'/curd/projects',
'/tables/remote',
'/doc/doc-inside',
'/template-hooks',
'/layout-demo',
'/svg-icons',
].map((path) => ({
path,
component: { render: () => null },
})),
})
await router.push('/dashboard')
@ -53,18 +59,24 @@ it('shows declared destinations below visible menu groups and navigates to the c
menu('/layout-demo'),
menu('/resources', [menu('/svg-icons')]),
]),
menu('/curd', [menu('/curd/projects')]),
menu('/tables', [menu('/tables/remote')]),
menu('/doc/doc-inside'),
]
const { router, wrapper, links } = await setupDashboard()
try {
expect(links().map((link) => link.attributes('href'))).toEqual([
'/curd/projects',
'/tables/remote',
'/doc/doc-inside',
'/template-hooks',
'/layout-demo',
'/svg-icons',
])
await links()[2].trigger('click')
await links()[0].trigger('click')
await flushPromises()
expect(router.currentRoute.value.path).toBe('/svg-icons')
expect(router.currentRoute.value.path).toBe('/curd/projects')
} finally {
wrapper.unmount()
}

View File

@ -126,6 +126,32 @@ it('ranks current visible menu entries by recent visits without opening a page',
}
})
it('offers a shortcut from each menu group before repeating a group', async () => {
menus.value = [
menu('/system', {
children: [
menu('/reports'),
menu('/maintenance', { children: [menu('/restricted')] }),
],
}),
menu('/people', { children: [menu('/users')] }),
]
const router = await createPageRouter()
const wrapper = mount(Welcome, { global: { plugins: [router] } })
const links = () =>
wrapper.findAll('.r-welcome__link').map((link) => link.attributes('href'))
try {
expect(links()).toEqual(['/reports', '/users', '/restricted'])
recentPaths.value = ['/restricted']
await nextTick()
expect(links()).toEqual(['/restricted', '/users', '/reports'])
} finally {
wrapper.unmount()
}
})
it('shows an honest no-access state and updates its language', async () => {
const router = await createPageRouter()
const wrapper = mount(Welcome, { global: { plugins: [router] } })

View File

@ -1,8 +1,14 @@
{
"title": "Your workspace is ready.",
"description": "Explore the components, layouts and tools that help you focus on building your application.",
"stateManagement": "Reactive state management",
"explore": "Explore the template",
"title": "Ray Admin workspace",
"description": "Open business examples, layout tools, and developer documentation.",
"stack": "Stack versions",
"explore": "Examples and docs",
"projects": "Projects",
"projectsDescription": "Filter projects, view details, and open the editor",
"tables": "TablePro remote queries",
"tablesDescription": "Try filtering, pagination, and retrying failed requests",
"docs": "Developer docs",
"docsDescription": "Read guides and API references in the workspace",
"hooks": "Template Hooks",
"hooksDescription": "Interactive composable examples",
"layout": "Layout playground",

View File

@ -2,11 +2,10 @@
"welcome": {
"eyebrow": "Your workspace",
"title": "Ready for your next task",
"description": "Choose a starting point below, or use the navigation menu to begin your next task.",
"shortcuts": "Choose a page",
"description": "Open a page available to your account, or browse the main menu.",
"shortcuts": "Page shortcuts",
"recent": "Recently visited",
"openPage": "Open page",
"navigationHint": "Only available pages appear here, with your recent visits first.",
"navigationHint": "Recently visited pages appear first.",
"noPagesTitle": "No starting points are available yet",
"noPagesDescription": "There are no navigation entries to show. Ask an administrator to check the page configuration or your access."
},

View File

@ -1,8 +1,14 @@
{
"title": "工作空间,准备就绪。",
"description": "从常用能力开始,探索组件、布局与工具,让业务开发更从容。",
"stateManagement": "响应式状态管理",
"explore": "探索模板能力",
"title": "Ray Admin 工作台",
"description": "从这里打开业务示例、布局工具和开发文档。",
"stack": "技术栈版本",
"explore": "模板示例与文档",
"projects": "项目管理",
"projectsDescription": "筛选项目、查看详情或编辑项目",
"tables": "TablePro 远端查询",
"tablesDescription": "体验查询、分页和请求失败恢复",
"docs": "开发文档",
"docsDescription": "在工作台中阅读指南和 API 参考",
"hooks": "模板 Hooks",
"hooksDescription": "交互示例与组合式能力",
"layout": "布局实验室",

View File

@ -2,11 +2,10 @@
"welcome": {
"eyebrow": "你的工作区",
"title": "工作区已就绪",
"description": "选择一个入口,或从导航菜单打开页面,开始下一项工作。",
"shortcuts": "选择一个页面",
"description": "从当前账号可用的页面开始,也可以浏览主导航。",
"shortcuts": "快捷入口",
"recent": "最近访问",
"openPage": "打开页面",
"navigationHint": "这里展示当前可用的入口,最近访问的页面会优先出现。",
"navigationHint": "最近访问的页面会排在前面。",
"noPagesTitle": "暂时没有可用的入口",
"noPagesDescription": "当前没有可显示的导航入口。请联系管理员确认页面配置或访问权限。"
},

View File

@ -2,13 +2,13 @@
container-type: inline-size;
display: flex;
flex-direction: column;
gap: 24px;
gap: clamp(16px, var(--layout-content-gutter, 20px), 24px);
inline-size: 100%;
max-inline-size: 1360px;
margin-inline: auto;
padding-block: 8px 20px;
&__header {
&__header.r-page-header {
padding: 28px 32px;
border: 1px solid var(--r-line);
border-radius: var(--r-radius);
@ -45,47 +45,51 @@
.r-dashboard-stack {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16px;
gap: 8px 16px;
margin: 0;
padding: 12px 20px;
border: 1px solid var(--r-line);
border-radius: var(--r-radius);
background: var(--r-surface);
&__item {
display: flex;
flex-direction: column;
gap: 10px;
padding: 20px 24px;
border: 1px solid var(--r-line);
border-radius: var(--r-radius);
background: var(--r-surface);
flex-wrap: wrap;
align-items: baseline;
gap: 2px 10px;
min-inline-size: 0;
}
span {
dt {
color: var(--r-text-secondary);
font-size: 12px;
font-size: 13px;
}
strong {
dd {
margin: 0;
color: var(--r-text);
font-family: var(--r-font-mono);
font-size: 21px;
font-size: 14px;
font-weight: 600;
letter-spacing: -0.03em;
overflow-wrap: anywhere;
}
small {
color: var(--r-text-muted);
font-size: 11px;
}
}
.r-dashboard-shortcuts {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 14px;
gap: 10px;
margin: 0;
padding: 0;
list-style: none;
}
.r-dashboard-shortcut {
box-sizing: border-box;
display: flex;
align-items: center;
gap: 14px;
padding: 18px;
gap: 12px;
min-block-size: 72px;
block-size: 100%;
padding: 12px 16px;
border: 1px solid var(--r-line);
border-radius: var(--r-control-radius);
color: var(--r-text);
@ -95,7 +99,7 @@
border-color 0.18s ease,
background-color 0.18s ease;
&:hover {
&:is(:hover, :focus-visible) {
border-color: var(--r-primary-text);
background: var(--r-surface-muted);
}
@ -189,18 +193,17 @@
}
}
@container (480px <= width < 760px) {
.r-dashboard-shortcuts {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@container (max-width: 600px) {
.r-dashboard__header {
.r-dashboard__header.r-page-header {
padding: 20px;
}
.r-dashboard-stack {
gap: 12px;
}
.r-dashboard-stack__item {
gap: 8px;
padding: 16px;
}
.r-dashboard__brand {
.r-dashboard__header .r-page-header__actions {
display: none;
}
}

View File

@ -17,20 +17,30 @@ export default defineComponent({
const shortcutsTitle = useId()
const { dependencies, devDependencies } = __APP_CFG__.pkg
const stack = [
{ name: 'Vue', version: dependencies.vue, detail: 'Composition API' },
{ name: 'Vite', version: devDependencies.vite, detail: 'Rolldown' },
{
name: 'TypeScript',
version: devDependencies.typescript,
detail: 'TSX',
},
{
name: 'Pinia',
version: dependencies.pinia,
detail: text('stateManagement'),
},
{ name: 'Vue', version: dependencies.vue },
{ name: 'Vite', version: devDependencies.vite },
{ name: 'TypeScript', version: devDependencies.typescript },
{ name: 'Pinia', version: dependencies.pinia },
]
const destinations = [
{
path: '/curd/projects',
icon: 'navigation/form',
title: 'projects',
description: 'projectsDescription',
},
{
path: '/tables/remote',
icon: 'navigation/table',
title: 'tables',
description: 'tablesDescription',
},
{
path: '/doc/doc-inside',
icon: 'navigation/document',
title: 'docs',
description: 'docsDescription',
},
{
path: '/template-hooks',
icon: 'action/setting',
@ -81,45 +91,44 @@ export default defineComponent({
</span>
</AppPageHeader>
{shortcuts.value.length ? (
<section aria-labelledby={shortcutsTitle}>
<nav aria-labelledby={shortcutsTitle}>
<h2 id={shortcutsTitle} class="r-dashboard__section-title">
{text('explore')}
</h2>
<nav class="r-dashboard-shortcuts" aria-labelledby={shortcutsTitle}>
<ul class="r-dashboard-shortcuts" role="list">
{shortcuts.value.map((item) => (
<RouterLink
key={item.path}
to={item.path}
class="r-dashboard-shortcut"
>
<span class="r-dashboard-shortcut__icon" aria-hidden="true">
<RIcon name={item.icon} size={20} />
</span>
<span class="r-dashboard-shortcut__copy">
<strong>{text(item.title)}</strong>
<small>{text(item.description)}</small>
</span>
<RIcon
class="r-dashboard-shortcut__arrow"
name="directional/right_arrow"
size={14}
/>
</RouterLink>
<li key={item.path}>
<RouterLink to={item.path} class="r-dashboard-shortcut">
<span class="r-dashboard-shortcut__icon" aria-hidden="true">
<RIcon name={item.icon} size={20} />
</span>
<span class="r-dashboard-shortcut__copy">
<strong>{text(item.title)}</strong>
<small>{text(item.description)}</small>
</span>
<RIcon
class="r-dashboard-shortcut__arrow"
name="directional/right_arrow"
size={14}
aria-hidden="true"
/>
</RouterLink>
</li>
))}
</nav>
</section>
</ul>
</nav>
) : null}
<div class="r-dashboard-stack">
{stack.map((item) => (
<article key={item.name} class="r-dashboard-stack__item">
<span>{item.name}</span>
<strong>{item.version}</strong>
<small>
{item.name === 'Pinia' ? text('stateManagement') : item.detail}
</small>
</article>
))}
</div>
<section>
<h2 class="r-dashboard__section-title">{text('stack')}</h2>
<dl class="r-dashboard-stack">
{stack.map((item) => (
<div key={item.name} class="r-dashboard-stack__item">
<dt>{item.name}</dt>
<dd>{item.version}</dd>
</div>
))}
</dl>
</section>
<div class="r-dashboard-info">
<NCard title={text('project')}>
<p class="r-dashboard-info__intro">{text('projectDescription')}</p>

View File

@ -2,8 +2,7 @@
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
gap: 48px;
gap: clamp(16px, var(--layout-content-gutter, 20px), 24px);
min-block-size: max(
480px,
calc(
@ -11,33 +10,26 @@
var(--layout-content-gutter, 20px)
)
);
max-inline-size: 920px;
max-inline-size: 1024px;
margin-inline: auto;
padding: clamp(24px, 5cqi, 64px) clamp(0px, 2cqi, 24px);
padding-block: 8px 24px;
&__intro {
display: flex;
flex-direction: column;
align-items: center;
gap: 24px;
text-align: center;
.r-page-header {
justify-content: center;
padding: 0;
}
.r-page-header__description {
max-inline-size: 48ch;
margin-inline: auto;
}
&__intro.r-page-header {
padding: clamp(20px, 4cqi, 32px);
border: 1px solid var(--r-line);
border-radius: var(--r-radius);
background: color-mix(
in srgb,
var(--r-theme-primary-color) 5%,
var(--r-surface)
);
}
&__mark {
display: grid;
place-items: center;
inline-size: 80px;
block-size: 80px;
inline-size: 56px;
block-size: 56px;
border: 1px solid var(--r-line);
border-radius: var(--r-radius);
color: var(--r-primary-text);
@ -46,15 +38,15 @@
}
&__destinations h2 {
margin-block-end: 16px;
color: var(--r-text-secondary);
font-size: 13px;
font-weight: 500;
margin-block-end: 12px;
color: var(--r-text);
font-size: 15px;
font-weight: 600;
}
&__grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
grid-template-columns: minmax(0, 1fr);
gap: 12px;
}
@ -63,9 +55,10 @@
align-items: center;
gap: 14px;
min-inline-size: 0;
min-block-size: 88px;
min-block-size: 72px;
block-size: 100%;
box-sizing: border-box;
padding: 18px 20px;
padding: 14px 16px;
border: 1px solid var(--r-line);
border-radius: var(--r-radius);
color: var(--r-text);
@ -75,8 +68,8 @@
border-color 160ms ease,
background-color 160ms ease;
&:hover {
border-color: var(--r-control-border);
&:is(:hover, :focus-visible) {
border-color: var(--r-primary-text);
background: var(--r-surface-muted);
}
@ -92,8 +85,12 @@
inline-size: 40px;
block-size: 40px;
border-radius: var(--r-control-radius);
background: var(--r-surface-muted);
color: var(--r-text-secondary);
background: color-mix(
in srgb,
var(--r-theme-primary-color) 9%,
var(--r-surface)
);
color: var(--r-primary-text);
}
&__link-copy {
@ -115,9 +112,9 @@
}
&__arrow {
flex-shrink: 0;
margin-inline-start: auto;
color: var(--r-text-muted);
font-size: 18px;
}
&__hint {
@ -125,7 +122,6 @@
color: var(--r-text-muted);
font-size: 12px;
line-height: 1.7;
text-align: center;
}
&__empty {
@ -148,18 +144,20 @@
}
}
@container (max-width: 600px) {
.r-welcome {
gap: 32px;
padding-block: 32px;
&__grid {
grid-template-columns: minmax(0, 1fr);
}
&__mark {
inline-size: 64px;
block-size: 64px;
}
@container (min-width: 560px) {
.r-welcome__grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@container (min-width: 760px) {
.r-welcome__grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
@container (max-width: 480px) {
.r-welcome__intro .r-page-header__actions {
display: none;
}
}

View File

@ -21,8 +21,16 @@ export default defineComponent({
option.meta.noLocalTitle ?? option.breadcrumbLabel ?? option.name,
)
const shortcuts = computed(() => {
const leaves: { option: AppMenuOption; parent?: AppMenuOption }[] = []
const collect = (items: AppMenuOption[], parent?: AppMenuOption) => {
const leaves: {
option: AppMenuOption
parent?: AppMenuOption
group: string
}[] = []
const collect = (
items: AppMenuOption[],
parent?: AppMenuOption,
group?: string,
) => {
for (const option of items) {
if (
option.show === false ||
@ -31,9 +39,11 @@ export default defineComponent({
)
continue
if (option.children?.length) collect(option.children, option)
const root = group ?? option.fullPath
if (option.children?.length) collect(option.children, option, root)
else if (!option.meta.windowOpen && !option.fullPath.includes(':'))
leaves.push({ option, parent })
leaves.push({ option, parent, group: root })
}
}
@ -48,11 +58,22 @@ export default defineComponent({
return entry ? [entry] : []
})
const recentSet = new Set(recent.map(({ option }) => option.fullPath))
const groups = new Set(recent.map(({ group }) => group))
const firstInGroup: typeof leaves = []
const remaining: typeof leaves = []
return [
...recent,
...leaves.filter(({ option }) => !recentSet.has(option.fullPath)),
]
for (const entry of leaves) {
if (recentSet.has(entry.option.fullPath)) continue
if (groups.has(entry.group)) {
remaining.push(entry)
} else {
groups.add(entry.group)
firstInGroup.push(entry)
}
}
return [...recent, ...firstInGroup, ...remaining]
.slice(0, 6)
.map((entry) => ({
...entry,
@ -62,49 +83,53 @@ export default defineComponent({
return () => (
<section class="r-welcome">
<div class="r-welcome__intro">
<AppPageHeader
class="r-welcome__intro"
eyebrow={t('welcome.eyebrow')}
title={t('welcome.title')}
description={t('welcome.description')}
>
<div class="r-welcome__mark" aria-hidden="true">
<RIcon name="navigation/window" size={36} />
<RIcon name="navigation/dashboard" size={28} />
</div>
<AppPageHeader
eyebrow={t('welcome.eyebrow')}
title={t('welcome.title')}
description={t('welcome.description')}
/>
</div>
</AppPageHeader>
{shortcuts.value.length ? (
<nav class="r-welcome__destinations" aria-labelledby={shortcutsTitle}>
<h2 id={shortcutsTitle}>{t('welcome.shortcuts')}</h2>
<ul class="r-welcome__grid" role="list">
{shortcuts.value.map(({ option, parent, recent }) => (
<li key={option.fullPath}>
<RouterLink to={option.fullPath} class="r-welcome__link">
<span class="r-welcome__icon" aria-hidden="true">
<RIcon
name={
typeof option.meta.icon === 'string'
? option.meta.icon
: 'navigation/window'
}
size={22}
/>
</span>
<span class="r-welcome__link-copy">
<strong>{label(option)}</strong>
<span>
{recent
? t('welcome.recent')
: parent
? label(parent)
: t('welcome.openPage')}
{shortcuts.value.map(({ option, parent, recent }) => {
const icon = option.meta.icon ?? parent?.meta.icon
const context = recent
? t('welcome.recent')
: parent && label(parent)
return (
<li key={option.fullPath}>
<RouterLink to={option.fullPath} class="r-welcome__link">
<span class="r-welcome__icon" aria-hidden="true">
<RIcon
name={
typeof icon === 'string'
? icon
: 'navigation/window'
}
size={22}
/>
</span>
</span>
<span class="r-welcome__arrow" aria-hidden="true">
→
</span>
</RouterLink>
</li>
))}
<span class="r-welcome__link-copy">
<strong>{label(option)}</strong>
{context ? <span>{context}</span> : null}
</span>
<RIcon
class="r-welcome__arrow"
name="directional/right_arrow"
size={14}
aria-hidden="true"
/>
</RouterLink>
</li>
)
})}
</ul>
<p class="r-welcome__hint">{t('welcome.navigationHint')}</p>
</nav>

View File

@ -2,13 +2,13 @@
<main class="ray-home">
<header class="ray-hero">
<div>
<p class="ray-home-version">v{{ version }}</p>
<h1>Ray Template</h1>
<p class="ray-lead">
v{{ version }}
{{
label(
'将 Ray Admin、官网文档和共享包放在同一个工作区。可在文档里直接体验真实组件。',
'puts Ray Admin, the documentation site, and shared packages in one workspace. Try the components directly in the docs.',
'基于 Vue 3、TSX 与 Naive UI 的中后台模板。跟随指南搭建页面,或直接运行组件。',
'An admin template built with Vue 3, TSX, and Naive UI. Follow a guide to build your first page or run a component example.',
)
}}
</p>
@ -16,47 +16,35 @@
<a class="ray-start" :href="docsLink('/guide/start.html')">
{{ label('快速开始', 'Quick start') }}
</a>
<a class="ray-migrate" :href="docsLink('/migration.html')">
{{ label('v5 与 v6 的版本分界', 'Moving from v5 to v6') }}
<a class="ray-example-link" :href="docsLink(tableExample)">
{{ label('运行 TablePro 示例', 'Try TablePro') }}
</a>
</div>
</div>
<section class="ray-map" aria-labelledby="ray-map-title">
<h2 id="ray-map-title">{{ label('v6 工作区', 'v6 workspace') }}</h2>
<svg class="ray-orbit" viewBox="0 0 200 200" aria-hidden="true">
<circle cx="100" cy="100" r="65" />
<circle cx="100" cy="100" r="89" stroke-dasharray="3 6" />
<path d="M100 0v200M0 100h200M29 29l142 142m0-142L29 171" />
<circle cx="100" cy="100" r="7" fill="currentColor" />
</svg>
<ul>
<li v-for="module in modules" :key="module.href">
<a :href="docsLink(module.href)">
<span>{{ module.title }}</span>
<code>{{ module.name }}</code>
</a>
</li>
</ul>
</section>
</header>
<section class="ray-paths" aria-labelledby="ray-paths-title">
<h2 id="ray-paths-title">{{ label('常用文档', 'Popular guides') }}</h2>
<ul>
<li v-for="(card, index) in cards" :key="card.href">
<a
class="ray-path"
:href="docsLink(card.href)"
:aria-labelledby="`ray-path-title-${index}`"
:aria-describedby="`ray-path-summary-${index}`"
>
<article>
<nav class="ray-paths" aria-labelledby="ray-paths-title">
<h2 id="ray-paths-title">
{{ label('按任务找文档', 'Browse by task') }}
</h2>
<ul role="list">
<li v-for="(card, index) in cards" :key="card.href">
<a
class="ray-path"
:href="docsLink(card.href)"
:aria-labelledby="`ray-path-title-${index}`"
:aria-describedby="`ray-path-summary-${index}`"
>
<svg class="ray-path-icon" viewBox="0 0 24 24" aria-hidden="true">
<path :d="card.icon" />
</svg>
<h3 :id="`ray-path-title-${index}`">{{ card.title }}</h3>
<p :id="`ray-path-summary-${index}`">{{ card.summary }}</p>
<span class="ray-path-copy">
<strong :id="`ray-path-title-${index}`">{{
card.title
}}</strong>
<span :id="`ray-path-summary-${index}`">{{
card.summary
}}</span>
</span>
<svg
class="ray-path-arrow"
viewBox="0 0 24 24"
@ -64,11 +52,11 @@
>
<path d="M5 12h13m-5-5 5 5-5 5" />
</svg>
</article>
</a>
</li>
</ul>
</section>
</a>
</li>
</ul>
</nav>
</header>
<section class="ray-showcase" aria-labelledby="ray-showcase-title">
<div>
@ -87,13 +75,7 @@
<a :href="docsLink('/reference/table-pro.html')">
{{ label('TablePro 用法', 'TablePro reference') }}
</a>
<a
:href="
docsLink(
'/reference/table-pro-examples.html#自适应高度与虚拟滚动',
)
"
>
<a :href="docsLink(tableExample)">
{{ label('在线示例', 'Live example') }}
</a>
</div>
@ -111,6 +93,27 @@
"
/>
</section>
<section class="ray-map" aria-labelledby="ray-map-title">
<h2 id="ray-map-title">{{ label('v6 工作区', 'v6 workspace') }}</h2>
<svg class="ray-orbit" viewBox="0 0 200 200" aria-hidden="true">
<circle cx="100" cy="100" r="65" />
<circle cx="100" cy="100" r="89" stroke-dasharray="3 6" />
<path d="M100 0v200M0 100h200M29 29l142 142m0-142L29 171" />
<circle cx="100" cy="100" r="7" fill="currentColor" />
</svg>
<ul role="list">
<li v-for="module in modules" :key="module.href">
<a :href="docsLink(module.href)">
<span>{{ module.title }}</span>
<code>{{ module.name }}</code>
</a>
</li>
</ul>
<a class="ray-map-migration" :href="docsLink('/migration.html')">
{{ label('v5 与 v6 的版本分界', 'Moving from v5 to v6') }}
</a>
</section>
</main>
</template>
@ -123,6 +126,7 @@ const { localeIndex } = useData()
const english = computed(() => localeIndex.value === 'en')
const label = (zh: string, en: string) => (english.value ? en : zh)
const docsLink = (path: string) => withBase((english.value ? '/en' : '') + path)
const tableExample = '/reference/table-pro-examples.html#自适应高度与虚拟滚动'
const modules = computed(() => [
{ title: 'Ray Admin', name: 'apps/admin', href: '/guide/layout.html' },
@ -151,10 +155,10 @@ const cards = computed(() => [
{
title: label('组件与 Hooks', 'Components and hooks'),
summary: label(
'查找表单、弹窗和常用组合式函数。',
'查阅表单、弹窗和组合式函数。',
'Find forms, dialogs, and commonly used composables.',
),
href: '/reference/components.html',
href: '/reference/',
icon: 'M3.5 3.5h7v7h-7z M13.5 3.5h7v7h-7z M3.5 13.5h7v7h-7z M13.5 13.5h7v7h-7z',
},
{

View File

@ -18,13 +18,48 @@ export default {
const prefix = english ? '/en' : ''
const path = page.value.relativePath.replace(/^en\//, '')
const section = path.startsWith('guide/')
? { zh: '开发指南', en: 'Development guide' }
? {
title: english ? 'Guide' : '开发指南',
href: '/guide/start.html',
page: 'guide/start.md',
}
: path.startsWith('reference/')
? { zh: '参考', en: 'Reference' }
: { zh: '版本迁移', en: 'Migration' }
? {
title: english ? 'Reference' : '参考',
href: '/reference/',
page: 'reference/index.md',
}
: {
title: english ? 'Migration' : '版本迁移',
href: '/migration.html',
page: 'migration.md',
}
return h('div', { class: 'ray-doc-meta' }, [
h('span', english ? section.en : section.zh),
h(
'nav',
{ 'aria-label': english ? 'Documentation path' : '文档路径' },
h('ol', { class: 'ray-doc-trail', role: 'list' }, [
h(
'li',
h(
'a',
{ href: withBase(prefix + '/') },
english ? 'Docs' : '文档',
),
),
h(
'li',
path === section.page
? h('span', { 'aria-current': 'page' }, section.title)
: h(
'a',
{ href: withBase(prefix + section.href) },
section.title,
),
),
]),
),
path !== 'reference/source.md'
? h(
'a',

View File

@ -38,16 +38,26 @@
}
.ray-home {
width: min(100% - 3rem, 76rem);
display: grid;
gap: clamp(1.25rem, 3vw, 2.25rem);
width: min(100% - 2.5rem, 76rem);
margin-inline: auto;
padding-block: clamp(2rem, 5vw, 4.25rem);
}
.ray-hero {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
grid-template-columns: minmax(0, 1fr);
align-items: center;
gap: clamp(1.75rem, 5vw, 5rem);
padding-block: clamp(2.5rem, 6vw, 5rem) clamp(2.25rem, 5vw, 3.75rem);
gap: clamp(1.5rem, 4vw, 4rem);
}
.ray-home-version {
margin-block-end: 0.4rem;
color: var(--vp-c-brand-1);
font-family: var(--vp-font-family-mono);
font-size: 0.85rem;
font-weight: 650;
}
.ray-hero h1 {
@ -76,7 +86,7 @@
.ray-actions a {
display: inline-flex;
align-items: center;
min-height: 2.625rem;
min-block-size: 2.75rem;
padding-inline: 0.95rem;
border: 1px solid transparent;
border-radius: 0.5rem;
@ -93,11 +103,11 @@
background-color: var(--vp-c-brand-2);
}
.ray-actions .ray-migrate {
.ray-actions .ray-example-link {
border-color: var(--vp-c-border);
}
.ray-actions .ray-migrate:hover {
.ray-actions .ray-example-link:hover {
background-color: var(--vp-c-bg-soft);
}
@ -130,16 +140,17 @@
.ray-map ul {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
gap: 0.5rem;
width: min(100%, 15rem);
}
.ray-map a {
.ray-map li > a {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 0.25rem 0.65rem;
align-items: center;
min-block-size: 2.75rem;
padding: 0.55rem 0.75rem;
border: 1px solid var(--vp-c-divider);
border-radius: 0.45rem;
@ -148,10 +159,21 @@
font-weight: 600;
}
.ray-map a:hover {
.ray-map li > a:hover {
border-color: var(--vp-c-brand-1);
}
.ray-map-migration {
display: inline-flex;
align-items: center;
min-block-size: 2rem;
margin-block-start: 0.4rem;
color: var(--vp-c-brand-1);
font-size: 0.875rem;
text-decoration: underline;
text-underline-offset: 0.2em;
}
.ray-map code,
.ray-doc-meta code {
font-size: 0.8rem;
@ -171,8 +193,10 @@
}
.ray-paths {
padding-block: 1.5rem 2.5rem;
border-block-start: 1px solid var(--vp-c-divider);
padding: clamp(0.85rem, 2.5vw, 1.5rem);
border: 1px solid var(--vp-c-divider);
border-radius: 0.875rem;
background: var(--vp-c-bg-alt);
}
.ray-paths h2,
@ -183,33 +207,32 @@
}
.ray-paths h2 {
margin-block-end: 0.9rem;
margin-block-end: 0.75rem;
font-size: 1rem;
}
.ray-paths ul {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
gap: 0.8rem;
gap: 0.5rem;
}
.ray-path {
display: block;
height: 100%;
display: grid;
grid-template-columns: auto minmax(0, 1fr) auto;
align-items: center;
gap: 0.75rem;
min-block-size: 4rem;
padding: 0.65rem 0.85rem;
border: 1px solid var(--vp-c-divider);
border-radius: 0.65rem;
background: var(--vp-c-bg);
}
.ray-path:hover {
.ray-path:is(:hover, :focus-visible) {
border-color: var(--vp-c-brand-1);
background: var(--vp-c-bg-soft);
}
.ray-path article {
position: relative;
padding: 1rem 1.15rem;
}
.ray-path-icon,
.ray-path-arrow {
display: block;
@ -230,19 +253,22 @@
}
.ray-path-arrow {
position: absolute;
inset: 1.15rem 1.15rem auto auto;
width: 1.1rem;
height: 1.1rem;
}
.ray-path h3 {
margin-block: 0.65rem 0.2rem;
font-size: 1rem;
.ray-path-copy {
display: grid;
gap: 0.15rem;
overflow-wrap: anywhere;
}
.ray-path-copy strong {
font-size: 0.95rem;
font-weight: 650;
}
.ray-path p,
.ray-path-copy > span,
.ray-showcase p {
color: var(--vp-c-text-2);
font-size: 0.9rem;
@ -251,7 +277,7 @@
.ray-showcase {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 2.1fr);
grid-template-columns: minmax(0, 1fr);
align-items: center;
gap: clamp(1rem, 3vw, 2.5rem);
padding: clamp(1rem, 3vw, 2rem);
@ -274,6 +300,12 @@
font-weight: 600;
}
.ray-showcase-links a {
display: inline-flex;
align-items: center;
min-block-size: 1.75rem;
}
.ray-showcase-links a:hover,
.ray-doc-meta a:hover {
text-decoration: underline;
@ -291,6 +323,7 @@
.ray-doc-meta {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 0.25rem 1rem;
margin-block-end: 1.25rem;
@ -300,26 +333,62 @@
font-size: 0.85rem;
}
.ray-doc-meta > span {
.ray-doc-trail {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0 0.6rem;
margin: 0;
padding: 0;
list-style: none;
}
.ray-doc-trail > li {
display: inline-flex;
align-items: center;
gap: 0.6rem;
}
.ray-doc-trail > li + li::before {
content: '';
inline-size: 0.35rem;
block-size: 0.35rem;
border: solid currentColor;
border-width: 1px 1px 0 0;
transform: rotate(45deg);
}
.ray-doc-trail a {
color: var(--vp-c-brand-1);
}
.ray-doc-trail [aria-current='page'] {
font-weight: 650;
}
.ray-doc-meta a {
display: inline-flex;
align-items: center;
gap: 0.25em;
min-block-size: 1.75rem;
}
.ray-home a:focus-visible,
.ray-doc-meta a:focus-visible {
outline: 2px solid var(--vp-c-brand-1);
outline-offset: 3px;
}
@media (max-width: 800px) {
.ray-hero,
.ray-showcase {
grid-template-columns: minmax(0, 1fr);
}
}
@media (max-width: 560px) {
@media (min-width: 801px) {
.ray-home {
width: calc(100% - 2.5rem);
width: min(100% - 3rem, 76rem);
}
.ray-hero {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.ray-showcase {
grid-template-columns: minmax(0, 1fr) minmax(0, 2.1fr);
}
}