refactor: ♻️ userStore 代码重构优化

Former-commit-id: ef31b8420a48a91dd2449d62fb615941d528bf24
This commit is contained in:
郝先瑞
2023-09-11 18:20:03 +08:00
parent 7fcf66c8d0
commit 18daf33f9d
8 changed files with 32 additions and 44 deletions

View File

@@ -74,10 +74,10 @@ orderCount.value = 2000;
<div class="flex items-center">
<img
class="user-avatar"
:src="userStore.avatar + '?imageView2/1/w/80/h/80'"
:src="userStore.user.avatar + '?imageView2/1/w/80/h/80'"
/>
<span class="ml-[10px] text-[16px]">
{{ userStore.nickname }}
{{ userStore.user.nickname }}
</span>
</div>

View File

@@ -15,12 +15,12 @@ import { storeToRefs } from "pinia";
const emit = defineEmits(["change"]);
const store = storeToRefs(useUserStoreHook());
const { roles } = store;
const { roles } = store.user.value;
const switchRoles = computed({
get: () => roles.value[0],
get: () => roles[0],
set: (val) => {
roles.value = [val];
Object.assign(roles, [val]);
emit("change");
},
});