mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-16 04:03:17 +08:00
🎨 调整帖子卡片点击处理
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-if="card" :id="`post-card-${card.postId}`" class="tpc-card">
|
||||
<div class="tpc-top">
|
||||
<div class="tpc-cover" @click="createPost(card)">
|
||||
<div class="tpc-cover" @click="toPost()">
|
||||
<TMiImg :src="card.cover" alt="cover" :ori="true" v-if="card.cover !== ''" />
|
||||
<img src="/source/UI/defaultCover.webp" alt="cover" v-else />
|
||||
<div v-if="card.status" class="tpc-act">
|
||||
@@ -75,6 +75,7 @@ import showSnackbar from "@comp/func/snackbar.js";
|
||||
import TpAvatar from "@comp/viewPost/tp-avatar.vue";
|
||||
import { emit } from "@tauri-apps/api/event";
|
||||
import { computed, onMounted, shallowRef, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import { generateShareImg } from "@/utils/TGShare.js";
|
||||
import { createPost } from "@/utils/TGWindow.js";
|
||||
@@ -111,6 +112,8 @@ const stats: Readonly<Array<TPostStatus>> = [
|
||||
{ stat: ActStat.FINISHED, label: "已结束", color: "var(--tgc-od-white)" },
|
||||
{ stat: ActStat.SELECTION, label: "评选中", color: "var(--tgc-od-orange)" },
|
||||
];
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const props = withDefaults(defineProps<TPostCardProps>(), { selectMode: false });
|
||||
const emits = defineEmits<TPostCardEmits>();
|
||||
const card = shallowRef<RenderCard>();
|
||||
@@ -127,6 +130,16 @@ watch(
|
||||
async () => (card.value = getPostCard(props.modelValue)),
|
||||
);
|
||||
|
||||
async function toPost(): Promise<void> {
|
||||
if (!card.value) return;
|
||||
if (route.name !== "帖子详情") await createPost(card.value);
|
||||
if (route.params.post_id.toString() === card.value.postId.toString()) {
|
||||
showSnackbar.warn("当前已在该帖子详情页", 3000);
|
||||
return;
|
||||
}
|
||||
await router.push({ name: "帖子详情", params: { post_id: card.value.postId.toString() } });
|
||||
}
|
||||
|
||||
function getActivityStatus(status: number): RenderStatus {
|
||||
if (status satisfies ActStat) {
|
||||
const stat: ActStat = status;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
class="tpoc-item"
|
||||
v-for="(item, index) in postList"
|
||||
:key="index"
|
||||
@click="toPost(item.post.post_id, index)"
|
||||
:model-value="item"
|
||||
:class="{ selected: index === props.collection.cur - 1 }"
|
||||
/>
|
||||
@@ -25,17 +24,13 @@
|
||||
<script lang="ts" setup>
|
||||
import TOverlay from "@comp/app/t-overlay.vue";
|
||||
import TPostcard from "@comp/app/t-postcard.vue";
|
||||
import showSnackbar from "@comp/func/snackbar.js";
|
||||
import { nextTick, onMounted, shallowRef, useTemplateRef, watch } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
// import bbsReq from "@/web/request/bbsReq.js";
|
||||
import postReq from "@/web/request/postReq.js";
|
||||
|
||||
type TpoCollectionProps = { collection: TGApp.BBS.Post.Collection; gid: number };
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const props = defineProps<TpoCollectionProps>();
|
||||
const visible = defineModel<boolean>();
|
||||
const postList = shallowRef<Array<TGApp.BBS.Post.FullData>>([]);
|
||||
@@ -57,14 +52,6 @@ watch(
|
||||
onMounted(async () => {
|
||||
postList.value = await postReq.collection(props.collection.collection_id);
|
||||
});
|
||||
|
||||
async function toPost(postId: string, index: number): Promise<void> {
|
||||
if (index === props.collection.cur - 1) {
|
||||
showSnackbar.warn("已经在当前帖子");
|
||||
return;
|
||||
}
|
||||
await router.push({ name: "帖子详情", params: { post_id: postId } });
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
.tpoc-box {
|
||||
|
||||
@@ -416,14 +416,13 @@ onUnmounted(() => {
|
||||
}
|
||||
|
||||
.mpm-forum img {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.mpm-forum img:first-child {
|
||||
border-radius: 5px;
|
||||
margin-right: 5px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.mpm-forum span {
|
||||
@@ -467,6 +466,10 @@ onUnmounted(() => {
|
||||
cursor: pointer;
|
||||
font-family: var(--font-title);
|
||||
font-size: 12px;
|
||||
|
||||
&:hover {
|
||||
color: var(--tgc-od-green);
|
||||
}
|
||||
}
|
||||
|
||||
/* topic */
|
||||
|
||||
Reference in New Issue
Block a user