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 "编辑于 " + Time.toPassedDateTime(article.value.updatedAt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -25,11 +25,6 @@ export default createRouter({
|
|||||||
path: "/about",
|
path: "/about",
|
||||||
name: "About",
|
name: "About",
|
||||||
component: ArticleDetail
|
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> = {
|
export type Article<E extends ArticleMusicExtendData | ArticleSoftwareExtendData> = {
|
||||||
title?: string;
|
title?: string;
|
||||||
type: ArticleType;
|
type: ArticleType;
|
||||||
classId: number;
|
|
||||||
digest?: string;
|
digest?: string;
|
||||||
data?: string;
|
data?: string;
|
||||||
extendData?: E;
|
extendData?: E;
|
||||||
@ -24,9 +23,6 @@ export type ArticleView<E extends ArticleMusicExtendData | ArticleSoftwareExtend
|
|||||||
|
|
||||||
export enum ArticleType {
|
export enum ArticleType {
|
||||||
|
|
||||||
/** 关于 */
|
|
||||||
ABOUT,
|
|
||||||
|
|
||||||
/** 公版 */
|
/** 公版 */
|
||||||
PUBLIC,
|
PUBLIC,
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<article class="article-detail">
|
<article class="article-detail">
|
||||||
<header v-if="!isAbout" class="header">
|
<header v-if="!isAboutRoute" class="header">
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<t-button
|
<t-button
|
||||||
class="back"
|
class="back"
|
||||||
@ -50,7 +50,6 @@ const route = useRoute();
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const article = ref<ArticleView<any>>();
|
const article = ref<ArticleView<any>>();
|
||||||
const isAbout = ref<boolean>(false);
|
|
||||||
const template = ref<Component | null>(null);
|
const template = ref<Component | null>(null);
|
||||||
const templates: Record<string, Component> = {
|
const templates: Record<string, Component> = {
|
||||||
ABOUT: ArticleAbout,
|
ABOUT: ArticleAbout,
|
||||||
@ -58,17 +57,17 @@ const templates: Record<string, Component> = {
|
|||||||
PUBLIC: ArticlePublic,
|
PUBLIC: ArticlePublic,
|
||||||
SOFTWARE: ArticleSoftware
|
SOFTWARE: ArticleSoftware
|
||||||
};
|
};
|
||||||
|
const isAboutRoute = computed(() => route.name === "About");
|
||||||
|
|
||||||
watch(article, () => {
|
watch(article, () => {
|
||||||
if (article.value) {
|
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 () => {
|
onMounted(async () => {
|
||||||
isAbout.value = route.name === "About";
|
const id = isAboutRoute.value ? 1 : route.params.id as any as number;
|
||||||
|
|
||||||
const id = isAbout.value ? 1 : route.params.id as any as number;
|
|
||||||
article.value = await ArticleAPI.view(id);
|
article.value = await ArticleAPI.view(id);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user