明树Git Lab

Commit 9bb75707 authored by zhanghan's avatar zhanghan

消息模块完成

parent d2c0f73b
Pipeline #111532 passed with stage
in 20 seconds
......@@ -82,12 +82,14 @@
import { computed, ref, onMounted, getCurrentInstance, watch } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useUserStore } from "@/stores/user.js";
import { useMessageStore } from "@/stores/message.js";
import windowConfig from "@/window";
import LeftMenu from "./leftMenu.vue";
import axios from "axios";
import { Bell, Avatar, ArrowUp, ArrowDown } from "@element-plus/icons-vue"; // 补充导入图标
import { Bell, Avatar, ArrowUp, ArrowDown } from "@element-plus/icons-vue";
const userStore = useUserStore();
const messageStore = useMessageStore();
const proxyRef = ref(null);
const { proxy } = getCurrentInstance();
const excludeTabs = ["/homePage"];
......@@ -223,14 +225,9 @@ const getResourceData = () => {
};
// 获取未读消息数量
let messageCount = ref(0);
const messageCount = computed(() => messageStore.messageCount);
const getMessageCount = () => {
axios
.post(windowConfig.baseUrl + "/api/message/getMesCount", {})
.then((res) => {
messageCount.value = res.data.count || 0; // 增加默认值
})
.catch((err) => console.error("获取消息数量失败:", err)); // 增加错误处理
messageStore.fetchMessageCount();
};
// 跳转消息列表页
......
......@@ -26,7 +26,7 @@ const routes = [
name: "message",
title: "消息中心",
meta: { title: "消息中心" },
component: () => import("@/views/systemManage/message.vue"),
component: () => import("@/views/systemManage/newMessage.vue"),
},
{
path: "/homePage",
......
import { defineStore } from "pinia";
import axios from "axios";
import windowConfig from "@/window";
export const useMessageStore = defineStore("message", {
state: () => ({
messageCount: 0,
}),
actions: {
fetchMessageCount() {
axios
.post(windowConfig.baseUrl + "/api/message/getMesCount", {})
.then((res) => {
this.messageCount = res.data.count || 0;
})
.catch(() => {});
},
},
});
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment