add About

This commit is contained in:
Timi
2026-09-10 17:06:11 +08:00
parent e508722326
commit 3e7fe5ce14
5 changed files with 351 additions and 2 deletions
+115
View File
@@ -0,0 +1,115 @@
<template>
<div class="agreement-page">
<template v-if="article">
<header class="header" v-entrance-transition>
<h3 v-text="article.title || '协议'" />
<markdown-view
v-if="article.description"
class="description"
:content="article.description"
/>
</header>
<article-view
:article="article"
empty-text="暂无协议正文"
:resolve-attachment-url="resolveAttachmentUrl"
/>
</template>
<t-empty
v-else
:description="isLoading ? '正在加载协议' : '协议不存在'"
/>
</div>
</template>
<script setup lang="ts">
import { type Article, ArticleAPI, AttachmentAPI } from "timi-web-api";
import { ArticleView } from "timi-tdesign-mobile";
import { MarkdownView } from "timi-web";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
defineOptions({
name: "Agreement"
});
const route = useRoute();
const article = ref<Article>();
const isLoading = ref(false);
let loadToken = 0;
function resolveAttachmentUrl(attachmentId: string): string {
return AttachmentAPI.getReadURL(attachmentId);
}
async function loadArticle(): Promise<void> {
const requestToken = loadToken + 1;
loadToken = requestToken;
article.value = undefined;
const articleId = String(route.params.id || "").trim();
if (!articleId) {
return;
}
isLoading.value = true;
try {
const result = await ArticleAPI.detail(articleId);
if (requestToken !== loadToken) {
return;
}
article.value = result;
} catch (error) {
Message.error(getErrorMessage(error, "协议加载失败"));
} finally {
if (requestToken === loadToken) {
isLoading.value = false;
}
}
}
watch(() => route.params.id, async () => {
await loadArticle();
}, { immediate: true });
</script>
<style scoped lang="less">
.agreement-page {
padding: var(--app-nav-height) 0 1rem 0;
.header {
padding: .5rem 1rem;
h3 {
color: #0f172a;
margin: 0;
text-align: center;
line-height: 1.4;
}
.description {
color: #52607a;
font-size: .875rem;
margin-top: .5rem;
line-height: 1.7;
}
}
:deep(.content) {
border: none;
}
}
:global(html.theme-dark) {
.agreement-page {
.header {
h1 {
color: #e2e8f0;
}
.description {
color: #94a3b8;
}
}
}
}
</style>