feat: 推荐帖子 调整

This commit is contained in:
2025-08-04 21:41:58 +08:00
parent c40c64c92f
commit 800052a900
5 changed files with 25 additions and 71 deletions

View File

@@ -76,7 +76,7 @@
import { ref } from 'vue'
import { defineEmits } from 'vue'
import { onLoad } from '@dcloudio/uni-app';
import { SCROLL_TO_BOTTOM } from '../../constant/constant'
import { SCROLL_TO_BOTTOM, RECOMMEND_POSTS_TITLE } from '@/constant/constant'
import { MessageRole, MessageType, CompName } from '../../model/ChatModel';
import ChatTopWelcome from './ChatTopWelcome.vue';
@@ -231,6 +231,13 @@
scrollToBottom()
}, 200)
})
uni.$on(RECOMMEND_POSTS_TITLE, (value) => {
console.log('RECOMMEND_POSTS_TITLE:', value)
if(value && value.length > 0) {
handleReply(value)
}
})
}
/// 获取最近一次的会话id

View File

@@ -1,7 +1,7 @@
<template>
<view class="container">
<view v-for="item in themeDTOList" :key="item.title">
<DiscoveryCradContentList :recommendTheme="item" />
<RecommendPostsList :recommendTheme="item" />
</view>
</view>
</template>
@@ -10,8 +10,8 @@
import { ref, nextTick } from 'vue'
import { onMounted } from 'vue'
import { discoveryCradComponent } from '@/request/api/MainPageDataApi'
import RecommendPostsList from '../recommend/RecommendPostsList.vue'
import { SCROLL_TO_BOTTOM } from '@/constant/constant'
import DiscoveryCradContentList from './DiscoveryCradContentList.vue'
const themeDTOList = ref([])

View File

@@ -1,65 +0,0 @@
<template>
<view class="container">
<ModuleTitle :title="recommendTheme.themeName" />
<view class="container-scroll">
<view class="mk-card-item" v-for="(item, index) in recommendTheme.recommendPostsList" :key="index">
<image :src="item.coverPhoto" mode="widthFix"></image>
<text>{{ item.topic }}</text>
</view>
</view>
</view>
</template>
<script setup>
import ModuleTitle from '@/components/ModuleTitle/index.vue'
import { defineProps } from 'vue'
const props = defineProps({
recommendTheme: {
type: Object,
default: {}
}
})
</script>
<style lang="scss" scoped>
.container {
.container-scroll {
display: flex;
flex-direction: row;
overflow-x: auto;
margin-top: 4px;
/* 隐藏滚动条 */
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
.mk-card-item {
display: flex;
flex-direction: column;
align-items: start;
width: 188px;
height: 154px;
background-color: #ffffff;
border-radius: 10px;
margin-right: 8px;
image {
width: 188px;
height: 112px;
}
text {
padding: 12px;
text-align: center;
font-weight: 500;
font-size: 12px;
color: #333333;
}
}
}
}
</style>

View File

@@ -2,9 +2,9 @@
<view class="container">
<ModuleTitle :title="recommendTheme.themeName" />
<view class="container-scroll">
<view class="mk-card-item" v-for="(item, index) in recommendTheme.recommendPostsList" :key="index">
<view class="mk-card-item" v-for="(item, index) in recommendTheme.recommendPostsList" :key="index" @click="sendReply(item)">
<image :src="item.coverPhoto" mode="widthFix"></image>
<text>{{ item.topic }}</text>
<text>{{ item.topic }} dd</text>
</view>
</view>
</view>
@@ -12,6 +12,8 @@
<script setup>
import ModuleTitle from '@/components/ModuleTitle/index.vue'
import { RECOMMEND_POSTS_TITLE } from '@/constant/constant.js'
import { defineProps } from 'vue'
const props = defineProps({
recommendTheme: {
@@ -19,6 +21,13 @@
default: {}
}
})
const sendReply = (item) => {
// 向父组件传递数据
const topic = item.topic.replace(/^#/, '');
console.log("======>", topic)
uni.$emit(RECOMMEND_POSTS_TITLE, topic);
}
</script>