Update API formatting and routing structure

This commit is contained in:
wangqiao
2025-08-28 11:29:20 +08:00
parent 9edc63ff4f
commit 3f1431f972
9 changed files with 263 additions and 118 deletions

View File

@ -4,12 +4,12 @@
<!-- Logo and Title Section -->
<div class="logo-title-section">
<div class="logo">
<img :src="lunTanRes.channelIcon" alt="JRS Logo" />
<img :src="lunTanRes?.channelIcon" alt="JRS Logo" />
</div>
<div class="title-section">
<h1 class="main-title">#{{ lunTanRes.channelTitle }}</h1>
<h1 class="main-title">#{{ lunTanRes?.channelTitle }}</h1>
<div class="action-buttons">
<el-button v-if="!lunTanRes.isFollow" type="danger" class="subscribe-btn" @click="handleFollow"
<el-button v-if="!lunTanRes?.isFollow" type="danger" class="subscribe-btn" @click="handleFollow"
><el-icon class="mr-[4px] color-[#fff!]"><Plus /></el-icon> 关注
</el-button>
<el-button v-else type="danger" class="subscribe-btn" @click="handleUnfollow"> 取消关注 </el-button>
@ -21,7 +21,7 @@
<!-- Channel Info -->
<div class="channel-info">
<span class="info-item">话题介绍</span>
<span class="info-item">{{ lunTanRes.channelProfile }}</span>
<span class="info-item">{{ lunTanRes?.channelProfile }}</span>
</div>
<!-- Stats -->
@ -32,11 +32,11 @@
</div>
<div class="stats-item">
<span class="stats-label">关注人数</span>
<span class="stats-value"><i class="el-icon-arrow-up"></i> {{ lunTanRes.followCount }}</span>
<span class="stats-value"><i class="el-icon-arrow-up"></i> {{ lunTanRes?.followCount }}</span>
</div>
<div class="stats-item">
<span class="stats-label">当前有</span>
<span class="stats-value"><i class="el-icon-arrow-up"></i> {{ lunTanRes.chatUserCount }}人聊天</span>
<span class="stats-value"><i class="el-icon-arrow-up"></i> {{ lunTanRes?.chatUserCount }}人聊天</span>
<span class="stats-value ml-[2px] cursor-pointer color-[#1a65ff!]" @click="handleChat">立即加入</span>
</div>
</div>
@ -44,8 +44,8 @@
<!-- Tags -->
<div class="channel-tags">
<span class="tag-label">标签:</span>
<span v-for="(item, index) in lunTanRes.hotTags" :key="index" class="tag-item"
>{{ item }}{{ index === lunTanRes.hotTags.length - 1 ? '' : '、' }}</span
<span v-for="(item, index) in lunTanRes?.hotTags" :key="index" class="tag-item"
>{{ item }}{{ index === lunTanRes!.hotTags.length - 1 ? '' : '、' }}</span
>
</div>
</div>
@ -55,9 +55,9 @@
<ChatPage
v-if="isChat"
v-model:is-chat="isChat"
:chat-title="lunTanRes.channelTitle"
:chat-description="lunTanRes.channelProfile"
:channel-id="lunTanRes.channelId"
:chat-title="lunTanRes!.channelTitle"
:chat-description="lunTanRes!.channelProfile"
:channel-id="lunTanRes!.channelId"
/>
</div>
</template>
@ -71,25 +71,25 @@
import useUserStore from '~/stores/user'
const userStore = useUserStore()
const lunTanRes = defineModel<ChannelRespVO>('modelValue', {
const lunTanRes = defineModel<ChannelRespVO | null>('modelValue', {
required: true,
})
const handleClick = () => {
navigateTo('/channel/create?channelId=' + lunTanRes.value.channelId)
navigateTo('/channel/create?channelId=' + lunTanRes.value?.channelId)
}
const handleFollow = () => {
createChannelFollow({ channelId: lunTanRes.value.channelId }).then((res) => {
createChannelFollow({ channelId: lunTanRes.value!.channelId }).then((res) => {
if (res.code === 0) {
lunTanRes.value.isFollow = true
lunTanRes.value!.isFollow = true
ElMessage.success('关注成功')
}
})
}
const handleUnfollow = () => {
deleteChannelFollow({ channelId: lunTanRes.value.channelId }).then((res) => {
deleteChannelFollow({ channelId: lunTanRes.value!.channelId }).then((res) => {
if (res.code === 0) {
lunTanRes.value.isFollow = false
lunTanRes.value!.isFollow = false
ElMessage.success('取消关注成功')
}
})
@ -103,7 +103,7 @@
ElMessage.warning('请先登录')
return
}
await userStore.mqttClient?.subscribe(`zbjk_message_group/${lunTanRes.value.channelId}`)
await userStore.mqttClient?.subscribe(`zbjk_message_group/${lunTanRes.value!.channelId}`)
isChat.value = true
}
</script>