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