新增消息列表
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import { defineStore } from "pinia";
|
||||
import _hook from "@/hooks/index.js";
|
||||
import { login, getUserInfo } from "@/api/user.js";
|
||||
import { login, getUserInfo, getNotices } from "@/api/user.js";
|
||||
|
||||
export const useUser = defineStore("useUser", {
|
||||
state: () => {
|
||||
return {
|
||||
userInfo: {},
|
||||
token: _hook.useLocalStorage.get("token") || "",
|
||||
notices: {
|
||||
num: 0,
|
||||
list: []
|
||||
}
|
||||
};
|
||||
},
|
||||
getters: {},
|
||||
@@ -40,5 +44,20 @@ export const useUser = defineStore("useUser", {
|
||||
return res.userInfo;
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 获取消息列表
|
||||
*/
|
||||
async getNotices() {
|
||||
try {
|
||||
const res = await getNotices({
|
||||
currPage: 1,
|
||||
size: 10
|
||||
})
|
||||
this.notices.num = res.unread
|
||||
this.notices.list = res.list.list
|
||||
} catch (error) {
|
||||
console.error('获取消息列表error=', error)
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user