zs 1 year ago
parent
commit
829243944e
3 changed files with 18 additions and 17 deletions
  1. 1 5
      src/store/api/platform/chat.js
  2. 6 10
      src/views/chat/index.vue
  3. 11 2
      src/views/index/index.vue

+ 1 - 5
src/store/api/platform/chat.js

@@ -13,11 +13,7 @@ export const ChatStore = defineStore('chat', () => {
     const res = await axios.$get(`${url}`, cond)
     return res
   }
-  const chat = async ({ skip = 0, limit = undefined, ...info } = {}) => {
-    let cond = {}
-    if (skip) cond.skip = skip
-    if (limit) cond.limit = limit
-    cond = { ...cond, ...info }
+  const chat = async (cond) => {
     const res = await axios.$get(`${url}/chat`, cond)
     return res
   }

+ 6 - 10
src/views/chat/index.vue

@@ -119,20 +119,15 @@ onMounted(async () => {
   loading.value = false
 })
 const search = async () => {
-  searchList({ skip, limit })
+  searchList()
   if (id.value) {
     let res = await store.fetch(id.value)
     if (res.errcode == '0') info.value = res.data
     searchChat({ skip, limit })
   }
 }
-const searchList = async (query = { skip: 0, limit }) => {
-  const info = {
-    skip: query.skip,
-    limit: query.limit,
-    ...searchForm.value
-  }
-  const res = await chatstore.chat(info)
+const searchList = async () => {
+  const res = await chatstore.chat()
   if (res.errcode == '0') chatList.value = res.data
 }
 const toView = async (item) => {
@@ -148,7 +143,8 @@ const searchChat = async (query = { skip: 0, limit }) => {
     ...searchForm.value
   }
   const res = await chatstore.query(data)
-  if (res.errcode == '0') list.value = res.data
+  if (res.errcode == '0' && res.data.length > 0) list.value = res.data
+  else chatList.value.unshift(info.value)
 }
 const toSend = async () => {
   const data = {
@@ -161,7 +157,7 @@ const toSend = async () => {
   const res = await chatstore.create(data)
   if (res.errcode === 0) {
     textarea.value = ''
-    searchChat()
+    await searchChat({ skip, limit })
   }
 }
 // provide

+ 11 - 2
src/views/index/index.vue

@@ -32,8 +32,12 @@
                       </el-button>
                       <template #dropdown>
                         <el-dropdown-menu>
-                          <el-dropdown-item @click="toOpen">管理中心</el-dropdown-item>
-                          <el-dropdown-item @click="toLogout">注销</el-dropdown-item>
+                          <el-dropdown-menu>
+                            <el-dropdown-item @click="toOpen">管理中心</el-dropdown-item>
+                            <el-dropdown-item @click="toCenter(2)">个人中心</el-dropdown-item>
+                            <el-dropdown-item @click="toCenter(3)">我的报名</el-dropdown-item>
+                            <el-dropdown-item @click="toLogout">注销</el-dropdown-item>
+                          </el-dropdown-menu>
                         </el-dropdown-menu>
                       </template>
                     </el-dropdown>
@@ -125,6 +129,11 @@ const switchMenu = async (item) => {
 const toOpen = async () => {
   window.location.href = import.meta.env.VITE_APP_HOME
 }
+// 基础跳转
+const toCenter = (type) => {
+  if (type == '2') router.push('/center')
+  else if (type == '3') router.push('/sign')
+}
 // 退出登录
 const toLogout = () => {
   userStore.logOut()