💄 参照 anno 美化 post

This commit is contained in:
BTMuli
2023-06-16 17:15:22 +08:00
parent 029377b3cf
commit bd75cc432c
4 changed files with 44 additions and 14 deletions

View File

@@ -12,17 +12,14 @@
} }
.anno-title { .anno-title {
font-family: Genshin, serif; font-family: var(--font-title);
color: #5b738f; color: var(--common-text);
font-size: 24px; font-size: 24px;
font-weight: 500;
margin-bottom: 8px;
} }
.anno-subtitle { .anno-subtitle {
font-size: 16px; font-size: 16px;
color: #a1aeb6; color: var(--common-text-3);
margin-bottom: 16px;
} }
.anno-img { .anno-img {

View File

@@ -12,6 +12,21 @@
color: var(--post-default-text); color: var(--post-default-text);
} }
.mys-post-title {
font-family: var(--font-title);
color: var(--common-text);
font-size: 24px;
}
.mys-post-subtitle {
font-size: 16px;
color: var(--common-text-3);
}
.mys-post-content {
line-height: 2;
}
:deep(.mys-post-div) { :deep(.mys-post-div) {
margin: 20px auto; margin: 20px auto;
} }

View File

@@ -1,9 +1,18 @@
<!-- eslint-disable vue/no-v-html --> <!-- eslint-disable vue/no-v-html -->
<template> <template>
<TSwitchTheme /> <TSwitchTheme />
<TShareBtn v-show="!loadingEmpty" v-model="postRef" :title="postTitle" /> <TShareBtn v-show="!loadingEmpty" v-model="postRef" :title="shareTitle" />
<TOLoading v-model="loading" :empty="loadingEmpty" :title="loadingTitle" /> <TOLoading v-model="loading" :empty="loadingEmpty" :title="loadingTitle" />
<div class="mys-post-body" v-html="postHtml" /> <div class="mys-post-body">
<div class="mys-post-title">
{{ postRender.title }}
</div>
<div class="mys-post-subtitle">
<span>创建时间{{ postRender.created }}&emsp;</span>
<span>更新时间{{ postRender.updated }}</span>
</div>
<div class="mys-post-content" v-html="postHtml" />
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
// vue // vue
@@ -24,12 +33,16 @@ const loadingEmpty = ref(false as boolean);
// share // share
const postRef = ref({} as HTMLElement); const postRef = ref({} as HTMLElement);
const postTitle = ref(""); const shareTitle = ref("");
// 数据 // 数据
const postId = Number(useRoute().params.post_id); const postId = Number(useRoute().params.post_id);
const postHtml = ref(""); const postHtml = ref("");
const postRender = ref({
title: "",
created: "",
updated: "",
});
onMounted(async () => { onMounted(async () => {
await appWindow.show(); await appWindow.show();
@@ -46,14 +59,19 @@ onMounted(async () => {
const postData = await MysOper.Post.get(postId); const postData = await MysOper.Post.get(postId);
loadingTitle.value = "正在渲染数据..."; loadingTitle.value = "正在渲染数据...";
postHtml.value = MysOper.Post.parser(postData); postHtml.value = MysOper.Post.parser(postData);
postTitle.value = `【帖子】${postData.post.post_id}-${postData.post.subject}`; postRender.value = {
title: postData.post.subject,
created: new Date(postData.post.created_at * 1000).toLocaleString().replace(/\//g, "-"),
updated: new Date(postData.post.updated_at * 1000).toLocaleString().replace(/\//g, "-"),
};
shareTitle.value = `【帖子】${postId}-${postData.post.subject}`;
postRef.value = document.querySelector(".mys-post-body") as HTMLElement; postRef.value = document.querySelector(".mys-post-body") as HTMLElement;
await appWindow.setTitle(postData.post.subject); await appWindow.setTitle(shareTitle.value);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
loadingEmpty.value = true; loadingEmpty.value = true;
loadingTitle.value = "帖子不存在或解析失败"; loadingTitle.value = "帖子不存在或解析失败";
await appWindow.setTitle("帖子不存在或解析失败"); await appWindow.setTitle(`【帖子】${postId}-解析失败`);
return; return;
} }
setTimeout(() => { setTimeout(() => {

View File

@@ -14,7 +14,7 @@ import { saveImgLocal } from "../../utils/TGShare";
* @param {string} data 游戏内公告数据 * @param {string} data 游戏内公告数据
* @returns {Promise<string>} 解析后的数据 * @returns {Promise<string>} 解析后的数据
*/ */
export async function parseAnnoContent(data: string): Promise<string> { export async function parseAnnoContent (data: string): Promise<string> {
const htmlBase = new DOMParser().parseFromString(data, "text/html"); const htmlBase = new DOMParser().parseFromString(data, "text/html");
htmlBase.querySelectorAll("span").forEach((span) => { htmlBase.querySelectorAll("span").forEach((span) => {
if (span.style.fontSize) { if (span.style.fontSize) {