Merge pull request #28 from cshaptx4869/patch-2
refactor(userStore): ♻️ 优化user数据定义
This commit is contained in:
@@ -7,10 +7,10 @@ import { LoginData } from "@/api/auth/types";
|
|||||||
import { UserInfo } from "@/api/user/types";
|
import { UserInfo } from "@/api/user/types";
|
||||||
|
|
||||||
export const useUserStore = defineStore("user", () => {
|
export const useUserStore = defineStore("user", () => {
|
||||||
const user: UserInfo = {
|
const user = ref<UserInfo>({
|
||||||
roles: [],
|
roles: [],
|
||||||
perms: [],
|
perms: [],
|
||||||
};
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
@@ -45,7 +45,7 @@ export const useUserStore = defineStore("user", () => {
|
|||||||
reject("getUserInfo: roles must be a non-null array!");
|
reject("getUserInfo: roles must be a non-null array!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Object.assign(user, { ...data });
|
Object.assign(user.value, { ...data });
|
||||||
resolve(data);
|
resolve(data);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -209,11 +209,11 @@ const greetings = computed(() => {
|
|||||||
if (hours >= 6 && hours < 8) {
|
if (hours >= 6 && hours < 8) {
|
||||||
return "晨起披衣出草堂,轩窗已自喜微凉🌅!";
|
return "晨起披衣出草堂,轩窗已自喜微凉🌅!";
|
||||||
} else if (hours >= 8 && hours < 12) {
|
} else if (hours >= 8 && hours < 12) {
|
||||||
return "上午好," + useUserStore().user.nickname + "!";
|
return "上午好," + userStore.user.nickname + "!";
|
||||||
} else if (hours >= 12 && hours < 18) {
|
} else if (hours >= 12 && hours < 18) {
|
||||||
return "下午好," + useUserStore().user.nickname + "!";
|
return "下午好," + userStore.user.nickname + "!";
|
||||||
} else if (hours >= 18 && hours < 24) {
|
} else if (hours >= 18 && hours < 24) {
|
||||||
return "晚上好," + useUserStore().user.nickname + "!";
|
return "晚上好," + userStore.user.nickname + "!";
|
||||||
} else if (hours >= 0 && hours < 6) {
|
} else if (hours >= 0 && hours < 6) {
|
||||||
return "偷偷向银河要了一把碎星,只等你闭上眼睛撒入你的梦中,晚安🌛!";
|
return "偷偷向银河要了一把碎星,只等你闭上眼睛撒入你的梦中,晚安🌛!";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user