diff --git a/api/channel/index.ts b/api/channel/index.ts index 287caf9..f3f5bb7 100644 --- a/api/channel/index.ts +++ b/api/channel/index.ts @@ -20,7 +20,7 @@ import type { * @return {Promise} */ export const page = (params: TpageReq) => { - return useDollarFetchRequest.get>('/prod-api/app-api/business/posts/page', {query: params}) + return useDollarFetchRequest.get>('/prod-api/app-api/business/posts/page', { query: params }) } /** @@ -56,7 +56,7 @@ export const postsDelete = (params: { id: number }) => { * @return {Promise} */ export const getChannelDetail = (params: { id: string }) => { - return useFetchRequest.get>('/prod-api/app-api/business/posts/get', params) + return useFetchRequest.get>('/prod-api/app-api/business/posts/get', { query: params }) } /** @@ -64,7 +64,7 @@ export const getChannelDetail = (params: { id: string }) => { * @return {Promise} */ export const postscommentpage = (params: { postsId: string; pageNo: number; pageSize: number }) => { - return useFetchRequest.get>('/prod-api/app-api/business/posts-comment/page', params) + return useFetchRequest.get>('/prod-api/app-api/business/posts-comment/page', { query: params }) } /** * 创建帖子评论 @@ -93,7 +93,7 @@ export const sendKefuMessage = (params: SingleMessageVo) => { * 获得消息记录分页 */ export const getMessagePage = (params: { pageNo: number; pageSize: number; fromId?: number; msgType?: number; topic: string }) => { - return useDollarFetchRequest.get>('/prod-api/app-api/mqtt/message/page', {query:params}) + return useDollarFetchRequest.get>('/prod-api/app-api/mqtt/message/page', { query: params }) } /** @@ -107,7 +107,7 @@ export const conversationList = () => { * 获取聊天记录 */ export const getChatDetail = (params: { sessionId: number; pageNo: number; pageSize: number }) => { - return useDollarFetchRequest.get>('/prod-api/app-api/mqtt/message/pageBySession', {query:params}) + return useDollarFetchRequest.get>('/prod-api/app-api/mqtt/message/pageBySession', { query: params }) } /** @@ -121,7 +121,7 @@ export const clearUnreadMessage = (params: { id: number }) => { * 获得论坛频道 */ export const getChannelLunTanDetail = (params: { id: string }) => { - return useDollarFetchRequest.get>('/prod-api/app-api/business/channel/get', {query:params}) + return useDollarFetchRequest.get>('/prod-api/app-api/business/channel/get', { query: params }) } /** diff --git a/nuxt.config.ts b/nuxt.config.ts index f307dd4..4472021 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -12,7 +12,7 @@ export default defineNuxtConfig({ ssr: true, modules: ['@unocss/nuxt', '@pinia/nuxt', '@element-plus/nuxt', 'pinia-plugin-persistedstate/nuxt', 'nuxt-swiper'], - css: ['@unocss/reset/tailwind.css', 'element-plus/dist/index.css', '~/assets/scss/app.scss'], + css: ['element-plus/dist/index.css', '~/assets/scss/app.scss'], vite: { css: { preprocessorOptions: { @@ -119,7 +119,7 @@ export default defineNuxtConfig({ }, build: { - transpile: ['vueuc', '@css-render/vue3-ssr', '@unocss', '@tinymce/tinymce-vue', 'tinymce'], + transpile: ['vueuc', '@css-render/vue3-ssr', '@tinymce/tinymce-vue', 'tinymce'], }, plugins: [ // 在这里引入插件 diff --git a/pages/channel/[channelId]/[pageNo].vue b/pages/channel/[channelId]/[pageNo].vue new file mode 100644 index 0000000..549ad09 --- /dev/null +++ b/pages/channel/[channelId]/[pageNo].vue @@ -0,0 +1,99 @@ + + + + + diff --git a/pages/channel/components/ChannelHeader.vue b/pages/channel/components/ChannelHeader.vue index dfda5ab..9eb993c 100644 --- a/pages/channel/components/ChannelHeader.vue +++ b/pages/channel/components/ChannelHeader.vue @@ -4,12 +4,12 @@
-

#{{ lunTanRes.channelTitle }}

+

#{{ lunTanRes?.channelTitle }}

- @@ -21,7 +21,7 @@
话题介绍 - {{ lunTanRes.channelProfile }} + {{ lunTanRes?.channelProfile }}
@@ -32,11 +32,11 @@
关注人数 - {{ lunTanRes.followCount }}人 + {{ lunTanRes?.followCount }}人
当前有 - {{ lunTanRes.chatUserCount }}人聊天 + {{ lunTanRes?.chatUserCount }}人聊天 立即加入
@@ -44,8 +44,8 @@
标签: - {{ item }}{{ index === lunTanRes.hotTags.length - 1 ? '' : '、' }}{{ item }}{{ index === lunTanRes!.hotTags.length - 1 ? '' : '、' }}
@@ -55,9 +55,9 @@ @@ -71,25 +71,25 @@ import useUserStore from '~/stores/user' const userStore = useUserStore() - const lunTanRes = defineModel('modelValue', { + const lunTanRes = defineModel('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 } diff --git a/pages/channel/components/HotLlabel.vue b/pages/channel/components/HotLlabel.vue index 2030879..648b6b9 100644 --- a/pages/channel/components/HotLlabel.vue +++ b/pages/channel/components/HotLlabel.vue @@ -16,27 +16,32 @@ diff --git a/pages/channel/components/LeftContent.vue b/pages/channel/components/LeftContent.vue index b903b28..7b4f4c3 100644 --- a/pages/channel/components/LeftContent.vue +++ b/pages/channel/components/LeftContent.vue @@ -2,7 +2,7 @@
- +
@@ -13,6 +13,10 @@ const channelId = defineModel('modelValue', { required: true, }) + + const channelIdList = defineModel('channelIdList', { + required: true, + }) diff --git a/pages/channel/components/RightContent.vue b/pages/channel/components/RightContent.vue index b967fb7..51d6c3d 100644 --- a/pages/channel/components/RightContent.vue +++ b/pages/channel/components/RightContent.vue @@ -1,7 +1,9 @@ @@ -11,7 +11,7 @@ import KlNavTab from '~/components/kl-nav-tab/index.vue' import LeftContent from './components/LeftContent.vue' import RightContent from './components/RightContent.vue' - import { page, getChannelLunTanDetail } from '~/api/channel/index' + import { page, getChannelLunTanDetail, list } from '~/api/channel/index' import { reactive, watch, ref } from 'vue' import type { TpageRes, ChannelRespVO } from '~/api/channel/types' @@ -25,44 +25,59 @@ total: 0, }) + // 获取频道列表 + const { data: channelIdList } = await useAsyncData(`prod-api/app-api/business/channel/list-${Date.now()}`, async () => { + const res = await list() + return res.data as any[] + }) + + // console.log(channelIdList) + + // 获取第一个论坛详情 + // if (!channelIdList.value?.length) return + // const { data: lunTanRes, execute } = await useAsyncData(`prod-api/app-api/business/channel/detail-${Date.now()}`, async () => { + // const res = await getChannelLunTanDetail({ + // id: channelIdList.value?.[0].channelId, + // }) + // return res.data as ChannelRespVO + // }) + // const {data:pageRes, refresh:getPage} = await useAsyncData(`prod-api/app-api/business/posts/page-${Date.now()}`, async () => { // const res = await page(pageReq) // return res.data as TpageRes // }) - // 获得频道帖子分页 - const getPage = () => { - page(pageReq).then((res) => { - pageRes.list = res.data.list - pageRes.total = res.data.total - }) - } - getPage() + // 获得频道帖子分页 + // const getPage = () => { + // page(pageReq).then((res) => { + // pageRes.list = res.data.list + // pageRes.total = res.data.total + // }) + // } + // getPage() - const handleUpdatePageNo = (pageNo: number) => { - pageReq.pageNo = pageNo - getPage() - } + // const handleUpdatePageNo = (pageNo: number) => { + // pageReq.pageNo = pageNo + // getPage() + // } // 获取论坛详情 - const lunTanRes = ref({} as ChannelRespVO) - const getLunTanDetaiil = (val: string) => { - getChannelLunTanDetail({ - id: val, - }).then((res) => { - lunTanRes.value = res.data - }) - } + // const lunTanRes = ref({} as ChannelRespVO) + // const getLunTanDetaiil = (val: string) => { + // getChannelLunTanDetail({ + // id: val, + // }).then((res) => { + // lunTanRes.value = res.data + // }) + // } watch( - () => pageReq.channelId, + () => channelIdList.value, (val) => { if (val) { - console.log(val); - - getPage() - getLunTanDetaiil(val) + navigateTo(`/channel/${val[0].channelId}/1`) } - } + }, + { immediate: true } ) diff --git a/pages/chat-detail/index.vue b/pages/chat-detail/[channelId]-[pageNo].vue similarity index 74% rename from pages/chat-detail/index.vue rename to pages/chat-detail/[channelId]-[pageNo].vue index d0c385a..3d4c865 100644 --- a/pages/chat-detail/index.vue +++ b/pages/chat-detail/[channelId]-[pageNo].vue @@ -1,6 +1,6 @@