Skip to content

Commit

Permalink
♻️ 帖子显示版块信息
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Jul 27, 2024
1 parent 942e636 commit b502cf4
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 58 deletions.
47 changes: 3 additions & 44 deletions src/components/overlay/to-channel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { computed } from "vue";
import { useRouter } from "vue-router";
import { useAppStore } from "../../store/modules/app.js";
import { ToChannelItem } from "../../web/constant/bbs.js";
import TGConstant from "../../web/constant/TGConstant.js";
import showSnackbar from "../func/snackbar.js";
import TOverlay from "../main/t-overlay.vue";
Expand All @@ -41,12 +43,6 @@ interface ToChannelProps {
type ToChannelEmits = (e: "update:modelValue", value: boolean) => void;
interface ToChannelItem {
title: string;
icon: string;
gid: string;
}
const props = withDefaults(defineProps<ToChannelProps>(), {
modelValue: false,
});
Expand All @@ -60,44 +56,7 @@ const visible = computed({
});
const router = useRouter();
const appStore = useAppStore();
const channelList: ToChannelItem[] = [
{
title: "原神",
icon: "/platforms/mhy/ys.webp",
gid: "2",
},
{
title: "崩坏:星穹铁道",
icon: "/platforms/mhy/sr.webp",
gid: "6",
},
{
title: "绝区零",
icon: "/platforms/mhy/zzz.webp",
gid: "8",
},
{
title: "崩坏3",
icon: "/platforms/mhy/bh3.webp",
gid: "1",
},
{
title: "崩坏2",
icon: "/platforms/mhy/bh2.webp",
gid: "3",
},
{
title: "未定事件簿",
icon: "/platforms/mhy/wd.webp",
gid: "4",
},
{
title: "大别野",
icon: "/platforms/mhy/dby.webp",
gid: "5",
},
];
const channelList = TGConstant.BBS.CHANNELS;
function onCancel(): void {
visible.value = false;
Expand Down
35 changes: 24 additions & 11 deletions src/views/t-post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,32 @@
</div>
<div class="tp-post-meta">
<div class="mpm-forum" v-if="postData.forum">
<img :src="getGameIcon(postData.forum.game_id)" alt="gameIcon" />
<img :src="postData.forum.icon" alt="forumIcon" />
<span>{{ postData.forum.name }}</span>
</div>
<div class="mpm-item" :title="`浏览数:${postData.stat.view_num}`">
<div class="mpm-item" :title="`浏览数:${postData?.stat?.view_num}`">
<v-icon>mdi-eye</v-icon>
<span>{{ postData.stat.view_num }}</span>
<span>{{ postData?.stat?.view_num }}</span>
</div>
<div class="mpm-item" :title="`收藏数:${postData.stat.bookmark_num}`">
<div class="mpm-item" :title="`收藏数:${postData?.stat?.bookmark_num}`">
<v-icon>mdi-star</v-icon>
<span>{{ postData.stat.bookmark_num }}</span>
<span>{{ postData?.stat?.bookmark_num }}</span>
</div>
<div class="mpm-item" :title="`回复数:${postData.stat.reply_num}`">
<div class="mpm-item" :title="`回复数:${postData?.stat?.reply_num}`">
<v-icon>mdi-comment</v-icon>
<span>{{ postData.stat.reply_num }}</span>
<span>{{ postData?.stat?.reply_num }}</span>
</div>
<div class="mpm-item" :title="`点赞数:${postData.stat.like_num}`">
<div class="mpm-item" :title="`点赞数:${postData?.stat?.like_num}`">
<v-icon>mdi-thumb-up</v-icon>
<span>{{ postData.stat.like_num }}</span>
<span>{{ postData?.stat?.like_num }}</span>
</div>
<div class="mpm-item" :title="`转发数:${postData.stat.forward_num}`">
<div class="mpm-item" :title="`转发数:${postData?.stat?.forward_num}`">
<v-icon>mdi-share-variant</v-icon>
<span>{{ postData.stat.forward_num }}</span>
<span>{{ postData?.stat?.forward_num }}</span>
</div>
</div>
<TpAvatar :data="postData.user" position="right" />
<TpAvatar :data="postData.user" position="right" v-if="postData.user" />
</div>
<div class="tp-post-title" @click="toPost()" title="点击查看评论">
<span class="mpt-official" v-if="postData.post.post_status.is_official">官</span>
Expand Down Expand Up @@ -98,6 +99,7 @@ import { useAppStore } from "../store/modules/app.js";
import TGClient from "../utils/TGClient.js";
import TGLogger from "../utils/TGLogger.js";
import { createTGWindow } from "../utils/TGWindow.js";
import TGConstant from "../web/constant/TGConstant.js";
// loading
const loading = ref<boolean>(true);
Expand All @@ -122,6 +124,12 @@ const shareTimeTimer = ref<any>();
// 合集
const showCollection = ref<boolean>(false);
function getGameIcon(gameId: number): string {
const find = TGConstant.BBS.CHANNELS.find((item) => item.gid === gameId.toString());
if (find) return find.icon;
return "/platforms/mhy/mys.webp";
}
onMounted(async () => {
appVersion.value = await app.getVersion();
// 检查数据
Expand Down Expand Up @@ -357,6 +365,11 @@ onUnmounted(() => {
object-fit: cover;
}
.mpm-forum img:first-child {
border-radius: 5px;
margin-right: 5px;
}
.mpm-forum span {
overflow: hidden;
text-overflow: ellipsis;
Expand Down
12 changes: 10 additions & 2 deletions src/web/constant/TGConstant.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
/**
* @file web/constant/TGConstant.ts
* @description 常量
* @since Beta v0.3.6
* @since Beta v0.5.1
*/

import { BBS_APP_ID, BBS_SALT, BBS_UA_MOBILE, BBS_UA_PC, BBS_VERSION } from "./bbs.js";
import {
BBS_APP_ID,
BBS_SALT,
BBS_UA_MOBILE,
BBS_UA_PC,
BBS_VERSION,
CHANNEL_LIST,
} from "./bbs.js";
import SERVER from "./server.js";
import { GAME_BIZ } from "./utils.js";

Expand All @@ -14,6 +21,7 @@ const TGConstant = {
UA_PC: BBS_UA_PC,
UA_MOBILE: BBS_UA_MOBILE,
APP_ID: BBS_APP_ID,
CHANNELS: CHANNEL_LIST,
},
Salt: BBS_SALT,
Server: SERVER,
Expand Down
62 changes: 61 additions & 1 deletion src/web/constant/bbs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file web/constant/bbs.ts
* @description 常量-应用数据
* @since Beta v0.5.0
* @since Beta v0.5.1
*/

export const BBS_VERSION = "2.72.2";
Expand All @@ -21,3 +21,63 @@ export const BBS_SALT = {
X6: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
PROD: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
};

/**
* @description 频道列表
* @version 2.72.2
* @since Beta v0.5.1
* @interface ToChannelItem
* @property {string} title - 频道名称
* @property {string} icon - 频道图标
* @property {string} gid - 频道 gid
* @return ToChannelItem
*/
export interface ToChannelItem {
title: string;
icon: string;
gid: string;
}

/**
* @description 渠道列表
* @version 2.72.2
* @since Beta v0.5.1
* @type {Array<ToChannelItem>}
*/
export const CHANNEL_LIST: ToChannelItem[] = [
{
title: "原神",
icon: "/platforms/mhy/ys.webp",
gid: "2",
},
{
title: "崩坏:星穹铁道",
icon: "/platforms/mhy/sr.webp",
gid: "6",
},
{
title: "绝区零",
icon: "/platforms/mhy/zzz.webp",
gid: "8",
},
{
title: "崩坏3",
icon: "/platforms/mhy/bh3.webp",
gid: "1",
},
{
title: "崩坏2",
icon: "/platforms/mhy/bh2.webp",
gid: "3",
},
{
title: "未定事件簿",
icon: "/platforms/mhy/wd.webp",
gid: "4",
},
{
title: "大别野",
icon: "/platforms/mhy/dby.webp",
gid: "5",
},
];

0 comments on commit b502cf4

Please sign in to comment.