master-detail layout for help article
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
left-arrow
|
||||
@left-click="$router.back()"
|
||||
/>
|
||||
<main class="tui-page-content scroll column list help-page">
|
||||
<master-detail-page class="list help-page" :split="isWide" :selected="!!selectedArticleId">
|
||||
<template #master>
|
||||
<div class="pull-refresh empty-cell-title-margin">
|
||||
<div class="filters glass">
|
||||
<t-input
|
||||
@@ -43,7 +44,11 @@
|
||||
:description="emptyDescription"
|
||||
/>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
<template #detail>
|
||||
<help-article v-if="selectedArticleId" :article-id="selectedArticleId" />
|
||||
</template>
|
||||
</master-detail-page>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -52,6 +57,8 @@ import { SettingAPI } from "timi-web-api";
|
||||
import { useUserStore } from "timi-web-api/store";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { Message } from "@/utils/message";
|
||||
import { MasterDetailPage, useLayout } from "timi-tdesign-mobile";
|
||||
import HelpArticle from "@/pages/setting/HelpArticle.vue";
|
||||
|
||||
type HelpMenuItem = {
|
||||
children: HelpMenuItem[];
|
||||
@@ -85,6 +92,14 @@ defineOptions({
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const userStore = useUserStore();
|
||||
const { isWide } = useLayout({ tablet: true });
|
||||
const selectedArticleId = computed(() => typeof route.query.article === "string" ? route.query.article : "");
|
||||
|
||||
watch(isWide, async wide => {
|
||||
if (!wide && selectedArticleId.value) {
|
||||
await router.replace({ name: "HelpArticle", params: { id: selectedArticleId.value } });
|
||||
}
|
||||
});
|
||||
|
||||
const helpMenu = shallowRef<HelpMenuItem[]>([]);
|
||||
const isLoading = shallowRef(false);
|
||||
@@ -269,6 +284,11 @@ async function openItem(entry: HelpListEntry): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isWide.value) {
|
||||
await router.push({ query: { ...route.query, article: item.contentId } });
|
||||
return;
|
||||
}
|
||||
|
||||
await router.push({
|
||||
name: "HelpArticle",
|
||||
params: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="tui-page-layout tui-navbar">
|
||||
<div class="tui-page-layout tui-navbar help-article">
|
||||
<t-navbar
|
||||
fixed
|
||||
:z-index="20"
|
||||
@@ -7,21 +7,19 @@
|
||||
left-arrow
|
||||
@left-click="$router.back()"
|
||||
/>
|
||||
<main class="tui-page-content scroll column">
|
||||
<div class="help-article-page">
|
||||
<template v-if="article">
|
||||
<article-view
|
||||
:article="article"
|
||||
empty-text="暂无使用说明正文"
|
||||
v-entrance-transition
|
||||
:resolve-attachment-url="resolveAttachmentUrl"
|
||||
/>
|
||||
</template>
|
||||
<t-empty
|
||||
v-else
|
||||
:description="isLoading ? '正在加载使用说明' : '使用说明不存在'"
|
||||
<main class="tui-page-content content scroll column">
|
||||
<template v-if="article">
|
||||
<article-view
|
||||
:article="article"
|
||||
empty-text="暂无使用说明正文"
|
||||
v-entrance-transition
|
||||
:resolve-attachment-url="resolveAttachmentUrl"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<t-empty
|
||||
v-else
|
||||
:description="isLoading ? '正在加载使用说明' : '使用说明不存在'"
|
||||
/>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
@@ -39,6 +37,7 @@ defineOptions({
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const props = defineProps<{ articleId?: string }>();
|
||||
const pageNavBarTitle = ref("");
|
||||
|
||||
function setPageNavBarTitle(value?: string): void {
|
||||
@@ -61,7 +60,7 @@ async function loadArticle(): Promise<void> {
|
||||
loadToken = requestToken;
|
||||
article.value = undefined;
|
||||
setPageNavBarTitle(getFallbackPageTitle());
|
||||
const articleId = String(route.params.id || "").trim();
|
||||
const articleId = String(props.articleId || route.params.id || "").trim();
|
||||
if (!articleId) {
|
||||
return;
|
||||
}
|
||||
@@ -83,7 +82,7 @@ async function loadArticle(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => route.params.id, async () => {
|
||||
watch(() => props.articleId || route.params.id, async () => {
|
||||
await loadArticle();
|
||||
}, { immediate: true });
|
||||
|
||||
@@ -94,22 +93,25 @@ onBeforeRouteLeave(() => {
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.help-article-page {
|
||||
padding: 0 0 1rem;
|
||||
.help-article {
|
||||
|
||||
.header {
|
||||
padding: .5rem 1rem;
|
||||
.content {
|
||||
padding: calc(var(--tui-nav-height) - 1rem) 0 1rem;
|
||||
|
||||
.description {
|
||||
margin-top: .5rem;
|
||||
color: #52607a;
|
||||
font-size: .875rem;
|
||||
line-height: 1.7;
|
||||
.header {
|
||||
padding: .5rem 1rem;
|
||||
|
||||
.description {
|
||||
margin-top: .5rem;
|
||||
color: #52607a;
|
||||
font-size: .875rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.content) {
|
||||
border: none;
|
||||
:deep(.content) {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user