diff --git a/src/layout/header/components/update_avatar.vue b/src/layout/header/components/update_avatar.vue index 80492c0..6e74c1f 100644 --- a/src/layout/header/components/update_avatar.vue +++ b/src/layout/header/components/update_avatar.vue @@ -29,9 +29,7 @@ import { setAvatar } from "@/request/api.js"; import { ElMessage } from "element-plus"; import { ref } from "vue"; import { useVModels } from "@vueuse/core"; -import { useUserStore } from "@/pinia/user.js"; -const userStore = useUserStore(); const props = defineProps({ visible: { type: Boolean, @@ -44,7 +42,7 @@ const props = defineProps({ default: () => ({}), }, }); -const emits = defineEmits(["update:visible", "update:form"]); +const emits = defineEmits(["update:visible", "update:form", "get-data"]); const { visible, form } = useVModels(props, emits); const formRef = ref(null); const rules = { @@ -60,13 +58,10 @@ const fnSubmit = debounce( } const formData = new FormData(); formData.append("FFILE", form.value.file[0].raw); - const resData = await setAvatar(formData); + await setAvatar(formData); fnClose(); ElMessage.success("修改成功"); - userStore.setUserInfo({ - ...userStore.getUserInfo, - userPhoto: resData.userPhoto, - }); + emits("get-data"); }, { atBegin: true } ); diff --git a/src/layout/header/components/update_info.vue b/src/layout/header/components/update_info.vue index 885a7c3..47538f1 100644 --- a/src/layout/header/components/update_info.vue +++ b/src/layout/header/components/update_info.vue @@ -67,7 +67,7 @@ const props = defineProps({ default: () => ({}), }, }); -const emits = defineEmits(["update:visible", "update:form"]); +const emits = defineEmits(["update:visible", "update:form", "get-data"]); const { visible, form } = useVModels(props, emits); const formRef = ref(null); const validatePass = (rule, value, callback) => { @@ -118,6 +118,7 @@ const fnSubmit = debounce( }); fnClose(); ElMessage.success("修改成功"); + emits("get-data"); }, { atBegin: true } ); diff --git a/src/layout/header/index.vue b/src/layout/header/index.vue index 2723b5d..7b87f08 100644 --- a/src/layout/header/index.vue +++ b/src/layout/header/index.vue @@ -52,10 +52,12 @@ diff --git a/src/layout/menu/index.vue b/src/layout/menu/index.vue index 411dc99..3c859dd 100644 --- a/src/layout/menu/index.vue +++ b/src/layout/menu/index.vue @@ -7,7 +7,8 @@ :route="{ path: menu.path }" >