remove Article classId and ABOUT type
This commit is contained in:
@ -32,6 +32,7 @@ const articleTime = computed(() => {
|
||||
return "编辑于 " + Time.toPassedDateTime(article.value.updatedAt);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@ -25,11 +25,6 @@ export default createRouter({
|
||||
path: "/about",
|
||||
name: "About",
|
||||
component: ArticleDetail
|
||||
},
|
||||
{
|
||||
// 兼容性保留
|
||||
path: "/article/aid:id.html",
|
||||
redirect: to => `/aid${to.params.id}.html`
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -4,7 +4,6 @@ import { AttachmentView, Model } from "timi-web";
|
||||
export type Article<E extends ArticleMusicExtendData | ArticleSoftwareExtendData> = {
|
||||
title?: string;
|
||||
type: ArticleType;
|
||||
classId: number;
|
||||
digest?: string;
|
||||
data?: string;
|
||||
extendData?: E;
|
||||
@ -24,9 +23,6 @@ export type ArticleView<E extends ArticleMusicExtendData | ArticleSoftwareExtend
|
||||
|
||||
export enum ArticleType {
|
||||
|
||||
/** 关于 */
|
||||
ABOUT,
|
||||
|
||||
/** 公版 */
|
||||
PUBLIC,
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<article class="article-detail">
|
||||
<header v-if="!isAbout" class="header">
|
||||
<header v-if="!isAboutRoute" class="header">
|
||||
<div class="relative">
|
||||
<t-button
|
||||
class="back"
|
||||
@ -50,7 +50,6 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const article = ref<ArticleView<any>>();
|
||||
const isAbout = ref<boolean>(false);
|
||||
const template = ref<Component | null>(null);
|
||||
const templates: Record<string, Component> = {
|
||||
ABOUT: ArticleAbout,
|
||||
@ -58,17 +57,17 @@ const templates: Record<string, Component> = {
|
||||
PUBLIC: ArticlePublic,
|
||||
SOFTWARE: ArticleSoftware
|
||||
};
|
||||
const isAboutRoute = computed(() => route.name === "About");
|
||||
|
||||
watch(article, () => {
|
||||
if (article.value) {
|
||||
template.value = markRaw(templates[article.value.type]);
|
||||
const key = isAboutRoute.value ? "ABOUT" : article.value.type;
|
||||
template.value = markRaw(templates[key]);
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
isAbout.value = route.name === "About";
|
||||
|
||||
const id = isAbout.value ? 1 : route.params.id as any as number;
|
||||
const id = isAboutRoute.value ? 1 : route.params.id as any as number;
|
||||
article.value = await ArticleAPI.view(id);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user