mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-03-21 04:49:46 +08:00
🚸 调整参数,处理点击事件
This commit is contained in:
@@ -19,23 +19,18 @@
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="props.modelValue.post.images.length > 1"
|
||||
:title="`图片数:${props.modelValue.post.images.length}`"
|
||||
v-else-if="props.post.post.images.length > 1"
|
||||
:title="`图片数:${props.post.post.images.length}`"
|
||||
class="tpc-image-cnt"
|
||||
>
|
||||
<v-icon size="10">mdi-folder-multiple-image</v-icon>
|
||||
<span>{{ props.modelValue.post.images.length }}</span>
|
||||
<span>{{ props.post.post.images.length }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div :title="card.title" class="tpc-title" @click="shareCard()">{{ card.title }}</div>
|
||||
</div>
|
||||
<div v-if="card.user !== null" class="tpc-mid">
|
||||
<TpAvatar
|
||||
:data="card.user"
|
||||
:style="{ cursor: props.userClick ? 'pointer' : 'default' }"
|
||||
position="left"
|
||||
@click="onUserClick()"
|
||||
/>
|
||||
<TpAvatar :data="card.user" position="left" @click="onUserClick()" />
|
||||
</div>
|
||||
<div class="tpc-bottom">
|
||||
<div class="tpc-tags">
|
||||
@@ -104,9 +99,9 @@
|
||||
@click.stop="trySelect()"
|
||||
/>
|
||||
<div v-else class="tpc-info-id" @click="shareCard()">
|
||||
<span>{{ props.modelValue.post.post_id }}</span>
|
||||
<span>{{ props.post.post.post_id }}</span>
|
||||
<template v-if="isDevEnv">
|
||||
<span data-html2canvas-ignore>[{{ props.modelValue.post.view_type }}]</span>
|
||||
<span data-html2canvas-ignore>[{{ props.post.post.view_type }}]</span>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -126,10 +121,12 @@ import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, ref, shallowRef, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
/** 帖子卡片参数 */
|
||||
type TPostCardProps = {
|
||||
modelValue: TGApp.BBS.Post.FullData;
|
||||
/** 帖子数据 */
|
||||
post: TGApp.BBS.Post.FullData;
|
||||
/** 是否开启选择模式 */
|
||||
selectMode?: boolean;
|
||||
userClick?: boolean;
|
||||
};
|
||||
type TPostCardEmits = {
|
||||
(e: "onSelected", v: string): void;
|
||||
@@ -178,17 +175,17 @@ const cardBg = computed<string>(() => {
|
||||
const forumBg = computed<string>(() =>
|
||||
str2Color(`${card.value?.forum?.id}${card.value?.forum?.icon}${card.value?.forum?.name}`, -60),
|
||||
);
|
||||
const idBg = computed<string>(() => str2Color(`${props.modelValue.post.post_id}`, 0));
|
||||
const idBg = computed<string>(() => str2Color(`${props.post.post.post_id}`, 0));
|
||||
|
||||
onMounted(async () => (card.value = getPostCard(props.modelValue)));
|
||||
onMounted(async () => (card.value = getPostCard(props.post)));
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
async () => (card.value = getPostCard(props.modelValue)),
|
||||
() => props.post,
|
||||
async () => (card.value = getPostCard(props.post)),
|
||||
);
|
||||
|
||||
function trySelect(): void {
|
||||
if (props.selectMode) emits("onSelected", props.modelValue.post.post_id);
|
||||
if (props.selectMode) emits("onSelected", props.post.post.post_id);
|
||||
isSelected.value = !isSelected.value;
|
||||
}
|
||||
|
||||
@@ -293,20 +290,20 @@ async function shareCard(): Promise<void> {
|
||||
|
||||
async function toTopic(topic: TGApp.BBS.Post.Topic): Promise<void> {
|
||||
if (props.selectMode) return;
|
||||
const gid = props.modelValue.post.game_id;
|
||||
const gid = props.post.post.game_id;
|
||||
await emit("active_deep_link", `router?path=/posts/topic/${gid}/${topic.id}`);
|
||||
}
|
||||
|
||||
async function toForum(forum: RenderForum): Promise<void> {
|
||||
if (props.selectMode) return;
|
||||
const gid = props.modelValue.post.game_id;
|
||||
const gid = props.post.post.game_id;
|
||||
await emit("active_deep_link", `router?path=/posts/forum/${gid}/${forum.id}`);
|
||||
}
|
||||
|
||||
function onUserClick(): void {
|
||||
if (props.selectMode) return;
|
||||
if (!card.value || card.value.user === null) return;
|
||||
emits("onUserClick", card.value.user, props.modelValue.post.game_id);
|
||||
emits("onUserClick", card.value.user, props.post.post.game_id);
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<!-- 头像组件 -->
|
||||
<template>
|
||||
<div class="tp-avatar-box">
|
||||
<div class="tpa-img">
|
||||
@@ -48,7 +49,7 @@ const levelColor = computed<string>(() => {
|
||||
return "var(--tgc-od-white)";
|
||||
});
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
<style lang="scss" scoped>
|
||||
.tp-avatar-box {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
@@ -57,6 +58,7 @@ const levelColor = computed<string>(() => {
|
||||
flex-direction: v-bind("props.position === 'left' ? 'row' : 'row-reverse'");
|
||||
align-items: center;
|
||||
justify-content: v-bind("props.position === 'left' ? 'flex-start' : 'flex-end'");
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tpa-text {
|
||||
|
||||
@@ -11,10 +11,11 @@
|
||||
<span>加载中...</span>
|
||||
</div>
|
||||
<TPostcard
|
||||
v-for="(item, index) in postList"
|
||||
v-for="(post, index) in postList"
|
||||
:key="index"
|
||||
:class="{ selected: index === props.collection.cur - 1 }"
|
||||
:model-value="item"
|
||||
:post
|
||||
@onUserClick="toUserProfile"
|
||||
class="tpoc-item"
|
||||
/>
|
||||
</div>
|
||||
@@ -69,6 +70,13 @@ async function refreshPosts(): Promise<void> {
|
||||
async function toOuterCollect(): Promise<void> {
|
||||
await openUrl(`https://www.miyoushe.com/ys/collection/${props.collection.collection_id}`);
|
||||
}
|
||||
|
||||
async function toUserProfile(user: TGApp.BBS.Post.User, gid: number): Promise<void> {
|
||||
// TODO: 专门的个人页面
|
||||
console.log(user, gid);
|
||||
const profileUrl = `https://www.miyoushe.com/ys/accountCenter/postList?id=${user.uid}`;
|
||||
await openUrl(profileUrl);
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.tpoc-box {
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
</div>
|
||||
<div ref="listRef" class="vp-of-list">
|
||||
<TPostcard
|
||||
v-for="(item, index) in posts"
|
||||
:key="index"
|
||||
:model-value="item"
|
||||
v-for="post in posts"
|
||||
:key="post.post.post_id"
|
||||
:post
|
||||
class="vp-of-list-item"
|
||||
@onUserClick="toUserProfile"
|
||||
/>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<span>{{ timeStatus }}</span>
|
||||
</div>
|
||||
<div class="tpol-info">
|
||||
<TpAvatar :data="card.creator" position="left" />
|
||||
<TpAvatar @click="toUserProfile(card.creator.uid)" :data="card.creator" position="left" />
|
||||
<div>参与方式:{{ upWay }}</div>
|
||||
<div>奖品详情:</div>
|
||||
<div v-for="reward in card.rewards" :key="reward.name" class="tpol-info-reward">
|
||||
@@ -41,6 +41,7 @@ import showSnackbar from "@comp/func/snackbar.js";
|
||||
import TpAvatar from "@comp/viewPost/tp-avatar.vue";
|
||||
import painterReq from "@req/painterReq.js";
|
||||
import { emit } from "@tauri-apps/api/event";
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
import { generateShareImg } from "@utils/TGShare.js";
|
||||
import { stamp2LastTime } from "@utils/toolFunc.js";
|
||||
import { onUnmounted, ref, shallowRef, watch } from "vue";
|
||||
@@ -155,6 +156,12 @@ async function shareLottery(): Promise<void> {
|
||||
await generateShareImg(fileName, shareDom, 2, true);
|
||||
}
|
||||
|
||||
async function toUserProfile(uid: string): Promise<void> {
|
||||
// TODO: 专门的个人页面
|
||||
const profileUrl = `https://www.miyoushe.com/ys/accountCenter/postList?id=${uid}`;
|
||||
await openUrl(profileUrl);
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
if (timer !== undefined) {
|
||||
clearInterval(timer);
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
<div class="tops-divider" />
|
||||
<div ref="listRef" class="tops-list">
|
||||
<TPostCard
|
||||
v-for="item in results"
|
||||
:key="item.post.post_id"
|
||||
:model-value="item"
|
||||
v-for="post in results"
|
||||
:key="post.post.post_id"
|
||||
:post
|
||||
@onUserClick="toUserProfile"
|
||||
class="tops-item"
|
||||
/>
|
||||
</div>
|
||||
@@ -40,6 +41,7 @@ import showSnackbar from "@comp/func/snackbar.js";
|
||||
import { useBoxReachBottom } from "@hooks/reachBottom.js";
|
||||
import postReq from "@req/postReq.js";
|
||||
import useBBSStore from "@store/bbs.js";
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, onMounted, ref, shallowRef, useTemplateRef, watch } from "vue";
|
||||
|
||||
@@ -160,6 +162,13 @@ async function searchPosts(): Promise<void> {
|
||||
if (!visible.value) visible.value = true;
|
||||
showSnackbar.success(`成功加载${res.posts.length}条数据`);
|
||||
}
|
||||
|
||||
async function toUserProfile(user: TGApp.BBS.Post.User, gid: number): Promise<void> {
|
||||
// TODO: 专门的个人页面
|
||||
console.log(user, gid);
|
||||
const profileUrl = `https://www.miyoushe.com/ys/accountCenter/postList?id=${user.uid}`;
|
||||
await openUrl(profileUrl);
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
.tops-box {
|
||||
|
||||
@@ -30,9 +30,10 @@
|
||||
<div class="vp-ou-divider" />
|
||||
<div ref="listRef" class="vp-ou-list">
|
||||
<TPostCard
|
||||
v-for="item in results"
|
||||
:key="item.post.post_id"
|
||||
:model-value="item"
|
||||
@onUserClick="toUserProfile()"
|
||||
v-for="post in results"
|
||||
:key="post.post.post_id"
|
||||
:post
|
||||
class="vp-ou-item"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -103,11 +103,10 @@
|
||||
</template>
|
||||
</v-app-bar>
|
||||
<div class="pc-posts">
|
||||
<div v-for="item in curPosts" :key="item.post.post_id">
|
||||
<div v-for="post in curPosts" :key="post.post.post_id">
|
||||
<TPostCard
|
||||
:model-value="item"
|
||||
:post
|
||||
:select-mode="selectedMode"
|
||||
:user-click="true"
|
||||
@onSelected="handleSelected"
|
||||
@onUserClick="handleUserClick"
|
||||
/>
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
</v-app-bar>
|
||||
<div class="posts-grid">
|
||||
<div v-for="post in posts" :key="post.post.post_id">
|
||||
<TPostCard :model-value="post" :user-click="true" @onUserClick="handleUserClick" />
|
||||
<TPostCard :post @onUserClick="handleUserClick" />
|
||||
</div>
|
||||
</div>
|
||||
<VpOverlaySearch v-model="showSearch" :gid="curGid" :keyword="search" />
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
<v-window v-model="recentNewsType">
|
||||
<v-window-item v-for="(value, index) in bbsEnum.post.newsTypeList" :key="index" :value="value">
|
||||
<div class="pn-grid">
|
||||
<div v-for="item in postData[value]" :key="item.post.post_id">
|
||||
<TPostCard :model-value="item" />
|
||||
<div v-for="post in postData[value]" :key="post.post.post_id">
|
||||
<TPostCard :post />
|
||||
</div>
|
||||
</div>
|
||||
</v-window-item>
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
</v-app-bar>
|
||||
<div class="post-topic-grid">
|
||||
<div v-for="post in posts" :key="post.post.post_id">
|
||||
<TPostCard :model-value="post" :user-click="true" @onUserClick="handleUserClick" />
|
||||
<TPostCard :post @onUserClick="handleUserClick" />
|
||||
</div>
|
||||
</div>
|
||||
<VpOverlaySearch v-model="showSearch" :gid="curGid" :keyword="search" />
|
||||
|
||||
Reference in New Issue
Block a user