基本完成初步框架
This commit is contained in:
@@ -21,17 +21,17 @@ const pageFontSizeClass = computed(() => {
|
||||
// 根据路由参数构建内容路径
|
||||
const path = computed(() => {
|
||||
const slug = route.params.slug;
|
||||
|
||||
|
||||
// 处理 slug 参数
|
||||
if (!slug) {
|
||||
return '/'; // 如果没有 slug,返回根路径
|
||||
}
|
||||
|
||||
|
||||
const pathValue = Array.isArray(slug) ? slug.join("/") : slug;
|
||||
|
||||
|
||||
// 确保路径以 / 开头,不以 / 结尾
|
||||
const normalizedPath = `/${pathValue}`.replace(/\/+$/, ""); // 使用 /+ 匹配多个连续的斜杠
|
||||
|
||||
|
||||
return normalizedPath;
|
||||
});
|
||||
|
||||
@@ -55,11 +55,11 @@ const { data: page } = await useAsyncData(
|
||||
);
|
||||
|
||||
if (!page.value) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: '文档不存在',
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: '文档不存在',
|
||||
message: '当前页面不存在,请您检查路径是否正确',
|
||||
fatal: true
|
||||
fatal: true
|
||||
});
|
||||
}
|
||||
|
||||
@@ -118,21 +118,11 @@ const links = computed(() => {
|
||||
|
||||
<template>
|
||||
<UPage v-if="page" :class="pageFontSizeClass">
|
||||
<UPageHeader
|
||||
:title="page.title"
|
||||
:description="page.description"
|
||||
:headline="headline"
|
||||
:ui="{
|
||||
wrapper: 'flex-row items-center flex-wrap justify-between ',
|
||||
}"
|
||||
>
|
||||
<UPageHeader :title="page.title" :description="page.description" :headline="headline" :ui="{
|
||||
wrapper: 'flex-row items-center flex-wrap justify-between ',
|
||||
}">
|
||||
<template #links>
|
||||
<UButton
|
||||
v-for="(link, index) in page.links"
|
||||
:key="index"
|
||||
size="sm"
|
||||
v-bind="link"
|
||||
/>
|
||||
<UButton v-for="(link, index) in page.links" :key="index" size="sm" v-bind="link" />
|
||||
|
||||
<DocsPageHeaderLinks />
|
||||
</template>
|
||||
@@ -143,25 +133,13 @@ const links = computed(() => {
|
||||
|
||||
<USeparator>
|
||||
<div v-if="editLink" class="flex items-center gap-2 text-sm text-muted">
|
||||
<UButton
|
||||
variant="link"
|
||||
color="neutral"
|
||||
:to="editLink"
|
||||
target="_blank"
|
||||
icon="i-lucide-pen"
|
||||
:ui="{ leadingIcon: 'size-4' }"
|
||||
>
|
||||
<UButton variant="link" color="neutral" :to="editLink" target="_blank" icon="i-lucide-pen"
|
||||
:ui="{ leadingIcon: 'size-4' }">
|
||||
编辑页面
|
||||
</UButton>
|
||||
or
|
||||
<UButton
|
||||
variant="link"
|
||||
color="neutral"
|
||||
:to="`${appConfig.github.url}/issues/new/choose`"
|
||||
target="_blank"
|
||||
icon="i-lucide-alert-circle"
|
||||
:ui="{ leadingIcon: 'size-4' }"
|
||||
>
|
||||
<UButton variant="link" color="neutral" :to="`${appConfig.github.url}/issues/new/choose`" target="_blank"
|
||||
icon="i-lucide-alert-circle" :ui="{ leadingIcon: 'size-4' }">
|
||||
提交问题
|
||||
</UButton>
|
||||
</div>
|
||||
@@ -170,21 +148,18 @@ const links = computed(() => {
|
||||
</UPageBody>
|
||||
|
||||
<template v-if="page?.body?.toc?.links?.length" #right>
|
||||
<div class="fixed top-24 right-10 overflow-y-auto">
|
||||
<div class="fixed top-24 right-15 w-auto">
|
||||
|
||||
<UContentToc :title="appConfig.toc?.title" :links="page.body?.toc?.links">
|
||||
<template v-if="appConfig.toc?.bottom" #bottom>
|
||||
<div
|
||||
class="hidden lg:block space-y-6 "
|
||||
:class="{ '!mt-5': page.body?.toc?.links?.length }"
|
||||
>
|
||||
<USeparator v-if="page.body?.toc?.links?.length" type="dashed" />
|
||||
<UContentToc :title="appConfig.toc?.title" :links="page.body?.toc?.links">
|
||||
<template v-if="appConfig.toc?.bottom" #bottom>
|
||||
<div class="hidden lg:block space-y-6 " :class="{ '!mt-5': page.body?.toc?.links?.length }">
|
||||
<USeparator v-if="page.body?.toc?.links?.length" type="dashed" />
|
||||
|
||||
<UPageLinks :title="appConfig.toc.bottom.title" :links="links" />
|
||||
</div>
|
||||
</template>
|
||||
</UContentToc>
|
||||
</div>
|
||||
<UPageLinks :title="appConfig.toc.bottom.title" :links="links" />
|
||||
</div>
|
||||
</template>
|
||||
</UContentToc>
|
||||
</div>
|
||||
</template>
|
||||
</UPage>
|
||||
</template>
|
||||
|
@@ -18,6 +18,6 @@ useSeoMeta({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- <IndexHero /> -->
|
||||
<IndexHero />
|
||||
<IndexCard />
|
||||
</template>
|
||||
|
Reference in New Issue
Block a user