mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-04 01:10:36 +00:00
优化pinia相关
This commit is contained in:
@@ -1,7 +1,37 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { getCurrentUserInfo } from "@/api/system/user";
|
||||
import { getInitConfig } from "@/api/system/config";
|
||||
import { getNoticeList } from '@/api/system/notice'
|
||||
|
||||
export const useNoticeStore = defineStore("notice", {
|
||||
state: () => ({
|
||||
noticeList: [], // 存储系统配置
|
||||
total: 0, // 存储系统配置
|
||||
isNoticeLoaded: false, // 标记配置是否已加载
|
||||
}),
|
||||
actions: {
|
||||
async getNotice() {
|
||||
try {
|
||||
const response = await getNoticeList({ available: true });
|
||||
console.log(response);
|
||||
const { status_code, data } = response.data;
|
||||
if (status_code === 200) {
|
||||
this.noticeList = data.items;
|
||||
this.total = data.total;
|
||||
console.log(this.noticeList);
|
||||
this.isNoticeLoaded = true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("获取通知失败", error);
|
||||
}
|
||||
},
|
||||
clearUserInfo() {
|
||||
this.noticeList = [];
|
||||
this.total = 0;
|
||||
this.isNoticeLoaded = false;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const useUserStore = defineStore("user", {
|
||||
state: () => ({
|
||||
@@ -18,6 +48,7 @@ export const useUserStore = defineStore("user", {
|
||||
delete result.data.menus;
|
||||
this.setRoute(routers);
|
||||
this.basicInfo = { ...this.basicInfo, ...result.data };
|
||||
console.log(this.basicInfo);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
@@ -43,7 +74,7 @@ export const useConfigStore = defineStore("config", {
|
||||
isConfigLoaded: false, // 标记配置是否已加载
|
||||
}),
|
||||
actions: {
|
||||
async fetchConfig() {
|
||||
async getConfig() {
|
||||
try {
|
||||
const response = await getInitConfig();
|
||||
const { status_code, data } = response.data;
|
||||
|
||||
Reference in New Issue
Block a user