mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	refactor: 还原 loginStore 命名,重命名为 userStore
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| import axios from 'axios'; | ||||
| import type { RouteRecordNormalized } from 'vue-router'; | ||||
| import { UserState } from '@/store/modules/login/types'; | ||||
| import { UserState } from '@/store/modules/user/types'; | ||||
|  | ||||
| const BASE_URL = '/auth'; | ||||
|  | ||||
|   | ||||
| @@ -162,7 +162,7 @@ | ||||
|           > | ||||
|             <img | ||||
|               alt="avatar" | ||||
|               :src="getAvatar(loginStore.avatar, loginStore.gender)" | ||||
|               :src="getAvatar(userStore.avatar, userStore.gender)" | ||||
|             /> | ||||
|           </a-avatar> | ||||
|           <template #content> | ||||
| @@ -192,7 +192,7 @@ | ||||
| <script lang="ts" setup> | ||||
|   import { computed, ref, inject } from 'vue'; | ||||
|   import { useDark, useToggle, useFullscreen } from '@vueuse/core'; | ||||
|   import { useAppStore, useLoginStore } from '@/store'; | ||||
|   import { useAppStore, useUserStore } from '@/store'; | ||||
|   import { LOCALE_OPTIONS } from '@/locale'; | ||||
|   import useLocale from '@/hooks/locale'; | ||||
|   import useUser from '@/hooks/user'; | ||||
| @@ -202,7 +202,7 @@ | ||||
|   import MessageBox from '../message-box/index.vue'; | ||||
|  | ||||
|   const appStore = useAppStore(); | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const { logout } = useUser(); | ||||
|   const { changeLocale, currentLocale } = useLocale(); | ||||
|   const { isFullscreen, toggle: toggleFullScreen } = useFullscreen(); | ||||
|   | ||||
| @@ -1,10 +1,10 @@ | ||||
| import { DirectiveBinding } from 'vue'; | ||||
| import { useLoginStore } from '@/store'; | ||||
| import { useUserStore } from '@/store'; | ||||
|  | ||||
| function checkPermission(el: HTMLElement, binding: DirectiveBinding) { | ||||
|   const { value } = binding; | ||||
|   const loginStore = useLoginStore(); | ||||
|   const { permissions, roles } = loginStore; | ||||
|   const userStore = useUserStore(); | ||||
|   const { permissions, roles } = userStore; | ||||
|   const superAdmin = 'admin'; | ||||
|   const allPermission = '*'; | ||||
|  | ||||
|   | ||||
| @@ -1,15 +1,15 @@ | ||||
| import { RouteLocationNormalized, RouteRecordRaw } from 'vue-router'; | ||||
| import { useLoginStore } from '@/store'; | ||||
| import { useUserStore } from '@/store'; | ||||
|  | ||||
| export default function usePermission() { | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   return { | ||||
|     accessRouter(route: RouteLocationNormalized | RouteRecordRaw) { | ||||
|       return ( | ||||
|         !route.meta?.requiresAuth || | ||||
|         !route.meta?.roles || | ||||
|         route.meta?.roles?.includes('*') || | ||||
|         this.includeRole(route.meta?.roles, loginStore.roles) | ||||
|         this.includeRole(route.meta?.roles, userStore.roles) | ||||
|       ); | ||||
|     }, | ||||
|     includeRole(arr1: Array<string>, arr2: Array<string>) { | ||||
|   | ||||
| @@ -2,14 +2,14 @@ import { useRouter } from 'vue-router'; | ||||
| import { useI18n } from 'vue-i18n'; | ||||
| import { Notification } from '@arco-design/web-vue'; | ||||
|  | ||||
| import { useLoginStore } from '@/store'; | ||||
| import { useUserStore } from '@/store'; | ||||
|  | ||||
| export default function useUser() { | ||||
|   const { t } = useI18n(); | ||||
|   const router = useRouter(); | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const logout = async (logoutTo?: string) => { | ||||
|     await loginStore.logout(); | ||||
|     await userStore.logout(); | ||||
|     const currentRoute = router.currentRoute.value; | ||||
|     Notification.success(t('login.logout.success')); | ||||
|     router.push({ | ||||
|   | ||||
| @@ -47,7 +47,7 @@ | ||||
| <script lang="ts" setup> | ||||
|   import { ref, computed, watch, provide, onMounted } from 'vue'; | ||||
|   import { useRouter, useRoute } from 'vue-router'; | ||||
|   import { useAppStore, useLoginStore } from '@/store'; | ||||
|   import { useAppStore, useUserStore } from '@/store'; | ||||
|   import NavBar from '@/components/navbar/index.vue'; | ||||
|   import Menu from '@/components/menu/index.vue'; | ||||
|   import Footer from '@/components/footer/index.vue'; | ||||
| @@ -58,7 +58,7 @@ | ||||
|  | ||||
|   const isInit = ref(false); | ||||
|   const appStore = useAppStore(); | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const router = useRouter(); | ||||
|   const route = useRoute(); | ||||
|   const permission = usePermission(); | ||||
| @@ -88,7 +88,7 @@ | ||||
|     appStore.updateSettings({ menuCollapse: val }); | ||||
|   }; | ||||
|   watch( | ||||
|     () => loginStore.roles, | ||||
|     () => userStore.roles, | ||||
|     (roleValue) => { | ||||
|       if (roleValue && !permission.accessRouter(route)) | ||||
|         router.push({ name: 'notFound' }); | ||||
|   | ||||
| @@ -2,14 +2,14 @@ import type { Router, RouteRecordNormalized } from 'vue-router'; | ||||
| import NProgress from 'nprogress'; // progress bar | ||||
|  | ||||
| import usePermission from '@/hooks/permission'; | ||||
| import { useLoginStore, useAppStore } from '@/store'; | ||||
| import { useUserStore, useAppStore } from '@/store'; | ||||
| import { fixedRoutes, demoRoutes } from '../routes'; | ||||
| import { WHITE_LIST, NOT_FOUND } from '../constants'; | ||||
|  | ||||
| export default function setupPermissionGuard(router: Router) { | ||||
|   router.beforeEach(async (to, from, next) => { | ||||
|     const appStore = useAppStore(); | ||||
|     const loginStore = useLoginStore(); | ||||
|     const userStore = useUserStore(); | ||||
|     const Permission = usePermission(); | ||||
|     const permissionsAllow = Permission.accessRouter(to); | ||||
|     if (appStore.menuFromServer) { | ||||
| @@ -52,7 +52,7 @@ export default function setupPermissionGuard(router: Router) { | ||||
|         const destination = | ||||
|           Permission.findFirstPermissionRoute( | ||||
|             [...fixedRoutes, ...demoRoutes], | ||||
|             loginStore.roles[0] | ||||
|               userStore.roles[0] | ||||
|           ) || NOT_FOUND; | ||||
|         next(destination); | ||||
|       } | ||||
|   | ||||
| @@ -1,13 +1,13 @@ | ||||
| import type { Router, LocationQueryRaw } from 'vue-router'; | ||||
| import NProgress from 'nprogress'; // progress bar | ||||
|  | ||||
| import { useLoginStore, useAppStore } from '@/store'; | ||||
| import { useUserStore, useAppStore } from '@/store'; | ||||
| import { isLogin } from '@/utils/auth'; | ||||
|  | ||||
| export default function setupUserLoginInfoGuard(router: Router) { | ||||
|   router.beforeEach(async (to, from, next) => { | ||||
|     NProgress.start(); | ||||
|     const loginStore = useLoginStore(); | ||||
|     const userStore = useUserStore(); | ||||
|     const appStore = useAppStore(); | ||||
|     appStore.init(); | ||||
|     if (isLogin()) { | ||||
| @@ -16,14 +16,14 @@ export default function setupUserLoginInfoGuard(router: Router) { | ||||
|         NProgress.done(); | ||||
|         return; | ||||
|       } | ||||
|       if (loginStore.roles[0]) { | ||||
|       if (userStore.roles[0]) { | ||||
|         next(); | ||||
|       } else { | ||||
|         try { | ||||
|           await loginStore.getInfo(); | ||||
|           await userStore.getInfo(); | ||||
|           next(); | ||||
|         } catch (error) { | ||||
|           await loginStore.logout(); | ||||
|           await userStore.logout(); | ||||
|           next({ | ||||
|             name: 'login', | ||||
|             query: { | ||||
|   | ||||
| @@ -1,10 +1,10 @@ | ||||
| import { createPinia } from 'pinia'; | ||||
| import useAppStore from './modules/app'; | ||||
| import useLoginStore from './modules/login'; | ||||
| import useUserStore from './modules/user'; | ||||
| import useDictStore from './modules/dict'; | ||||
| import useTabBarStore from './modules/tab-bar'; | ||||
|  | ||||
| const pinia = createPinia(); | ||||
|  | ||||
| export { useAppStore, useLoginStore, useDictStore, useTabBarStore }; | ||||
| export { useAppStore, useUserStore, useDictStore, useTabBarStore }; | ||||
| export default pinia; | ||||
|   | ||||
| @@ -12,7 +12,7 @@ import { removeRouteListener } from '@/utils/route-listener'; | ||||
| import { UserState } from './types'; | ||||
| import useAppStore from '../app'; | ||||
| 
 | ||||
| const useLoginStore = defineStore('user', { | ||||
| const useUserStore = defineStore('user', { | ||||
|   state: (): UserState => ({ | ||||
|     id: '', | ||||
|     username: '', | ||||
| @@ -96,4 +96,4 @@ const useLoginStore = defineStore('user', { | ||||
|   }, | ||||
| }); | ||||
| 
 | ||||
| export default useLoginStore; | ||||
| export default useUserStore; | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { useLoginStore } from '@/store'; | ||||
| import { useUserStore } from '@/store'; | ||||
|  | ||||
| /** | ||||
|  * 权限判断 | ||||
| @@ -7,8 +7,8 @@ import { useLoginStore } from '@/store'; | ||||
|  * @return true 有权限,false 没有权限 | ||||
|  */ | ||||
| export default function checkPermission(value: Array<string>) { | ||||
|   const loginStore = useLoginStore(); | ||||
|   const { permissions, roles } = loginStore; | ||||
|   const userStore = useUserStore(); | ||||
|   const { permissions, roles } = userStore; | ||||
|   const superAdmin = 'admin'; | ||||
|   const allPermission = '*'; | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import axios from 'axios'; | ||||
| import type { AxiosRequestConfig, AxiosResponse } from 'axios'; | ||||
| import { useLoginStore } from '@/store'; | ||||
| import { useUserStore } from '@/store'; | ||||
| import { getToken } from '@/utils/auth'; | ||||
| import modalErrorWrapper from '@/utils/modal-error-wrapper'; | ||||
| import messageErrorWrapper from '@/utils/message-error-wrapper'; | ||||
| @@ -58,8 +58,8 @@ axios.interceptors.response.use( | ||||
|         escToClose: false, | ||||
|         okText: '重新登录', | ||||
|         async onOk() { | ||||
|           const loginStore = useLoginStore(); | ||||
|           await loginStore.logout(); | ||||
|           const userStore = useUserStore(); | ||||
|           await userStore.logout(); | ||||
|           window.location.reload(); | ||||
|         }, | ||||
|       }); | ||||
|   | ||||
| @@ -11,12 +11,12 @@ | ||||
|  | ||||
| <script lang="ts" setup> | ||||
|   import { computed } from 'vue'; | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|  | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const userInfo = computed(() => { | ||||
|     return { | ||||
|       nickname: loginStore.nickname, | ||||
|       nickname: userStore.nickname, | ||||
|     }; | ||||
|   }); | ||||
| </script> | ||||
|   | ||||
| @@ -36,10 +36,10 @@ | ||||
| </template> | ||||
|  | ||||
| <script lang="ts" setup> | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|   import getAvatar from '@/utils/avatar'; | ||||
|  | ||||
|   const userInfo = useLoginStore(); | ||||
|   const userInfo = useUserStore(); | ||||
| </script> | ||||
|  | ||||
| <style scoped lang="less"> | ||||
|   | ||||
| @@ -56,7 +56,7 @@ | ||||
|   import { getCurrentInstance, ref, toRefs, reactive } from 'vue'; | ||||
|   import { useI18n } from 'vue-i18n'; | ||||
|   import { useStorage } from '@vueuse/core'; | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|   import { LoginReq } from '@/api/auth/login'; | ||||
|   import { ValidatedError } from '@arco-design/web-vue'; | ||||
|   import { encryptByRsa } from '@/utils/encrypt'; | ||||
| @@ -65,7 +65,7 @@ | ||||
|   const { proxy } = getCurrentInstance() as any; | ||||
|   const { t } = useI18n(); | ||||
|   const router = useRouter(); | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const loading = ref(false); | ||||
|   const captchaImgBase64 = ref(); | ||||
|   const loginConfig = useStorage('login-config', { | ||||
| @@ -100,7 +100,7 @@ | ||||
|    * 获取验证码 | ||||
|    */ | ||||
|   const getCaptcha = () => { | ||||
|     loginStore.getImgCaptcha().then((res) => { | ||||
|     userStore.getImgCaptcha().then((res) => { | ||||
|       form.value.uuid = res.data.uuid; | ||||
|       captchaImgBase64.value = res.data.img; | ||||
|     }); | ||||
| @@ -123,7 +123,7 @@ | ||||
|     if (loading.value) return; | ||||
|     if (!errors) { | ||||
|       loading.value = true; | ||||
|       loginStore | ||||
|       userStore | ||||
|         .login({ | ||||
|           username: values.username, | ||||
|           password: encryptByRsa(values.password) || '', | ||||
|   | ||||
| @@ -40,12 +40,12 @@ | ||||
| <script lang="ts" setup> | ||||
|   import { getCurrentInstance, ref, toRefs, reactive, computed } from 'vue'; | ||||
|   import { useI18n } from 'vue-i18n'; | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|   import { LoginReq } from '@/api/auth/login'; | ||||
|  | ||||
|   const { proxy } = getCurrentInstance() as any; | ||||
|   const { t } = useI18n(); | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const loading = ref(false); | ||||
|   const captchaLoading = ref(false); | ||||
|   const captchaDisable = ref(false); | ||||
|   | ||||
| @@ -42,12 +42,12 @@ | ||||
| <script lang="ts" setup> | ||||
|   import { getCurrentInstance, ref, toRefs, reactive, computed } from 'vue'; | ||||
|   import { useI18n } from 'vue-i18n'; | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|   import { LoginReq } from '@/api/auth/login'; | ||||
|  | ||||
|   const { proxy } = getCurrentInstance() as any; | ||||
|   const { t } = useI18n(); | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const loading = ref(false); | ||||
|   const captchaLoading = ref(false); | ||||
|   const captchaDisable = ref(false); | ||||
|   | ||||
| @@ -7,14 +7,14 @@ | ||||
| <script setup lang="ts"> | ||||
|   import { getCurrentInstance, ref } from 'vue'; | ||||
|   import { useRoute, useRouter } from 'vue-router'; | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|   import { useI18n } from 'vue-i18n'; | ||||
|  | ||||
|   const { proxy } = getCurrentInstance() as any; | ||||
|   const { t } = useI18n(); | ||||
|   const route = useRoute(); | ||||
|   const router = useRouter(); | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const loading = ref(false); | ||||
|   const source = route.query.source as string; | ||||
|  | ||||
| @@ -25,7 +25,7 @@ | ||||
|     if (loading.value) return; | ||||
|     loading.value = true; | ||||
|     const { redirect, ...othersQuery } = router.currentRoute.value.query; | ||||
|     loginStore | ||||
|     userStore | ||||
|       .socialLogin(source, othersQuery) | ||||
|       .then(() => { | ||||
|         router.push({ | ||||
|   | ||||
| @@ -56,20 +56,20 @@ | ||||
|   import { FieldRule } from '@arco-design/web-vue'; | ||||
|   import { BasicInfoModel, updateBasicInfo } from '@/api/system/user-center'; | ||||
|   import { useI18n } from 'vue-i18n'; | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|  | ||||
|   const { proxy } = getCurrentInstance() as any; | ||||
|  | ||||
|   const { t } = useI18n(); | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const loading = ref(false); | ||||
|  | ||||
|   const data = reactive({ | ||||
|     // 表单数据 | ||||
|     form: { | ||||
|       username: loginStore.username, | ||||
|       nickname: loginStore.nickname, | ||||
|       gender: loginStore.gender, | ||||
|       username: userStore.username, | ||||
|       nickname: userStore.nickname, | ||||
|       gender: userStore.gender, | ||||
|     } as BasicInfoModel, | ||||
|     // 表单验证规则 | ||||
|     rules: computed((): Record<string, FieldRule[]> => { | ||||
| @@ -107,8 +107,8 @@ | ||||
|           nickname: form.value.nickname, | ||||
|           gender: form.value.gender, | ||||
|         }) | ||||
|           .then((res) => { | ||||
|             loginStore.getInfo(); | ||||
|           .then(() => { | ||||
|             userStore.getInfo(); | ||||
|             proxy.$message.success(t('userCenter.basicInfo.form.save.success')); | ||||
|           }) | ||||
|           .finally(() => { | ||||
|   | ||||
| @@ -62,9 +62,9 @@ | ||||
|     OperationLogRecord, | ||||
|     listOperationLog, | ||||
|   } from '@/api/monitor/log'; | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|  | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|  | ||||
|   const dataList = ref<OperationLogRecord[]>([]); | ||||
|   const total = ref(0); | ||||
| @@ -73,7 +73,7 @@ | ||||
|   const data = reactive({ | ||||
|     // 查询参数 | ||||
|     queryParams: { | ||||
|       uid: loginStore.id, | ||||
|       uid: userStore.id, | ||||
|       page: 1, | ||||
|       size: 10, | ||||
|       sort: ['createTime,desc'], | ||||
|   | ||||
| @@ -7,12 +7,12 @@ | ||||
|     </template> | ||||
|     <template #description> | ||||
|       <div class="content"> | ||||
|         <a-typography-paragraph v-if="loginStore.email"> | ||||
|         <a-typography-paragraph v-if="userStore.email"> | ||||
|           {{ | ||||
|             $t( | ||||
|               'userCenter.securitySettings.updateEmail.placeholder.success.email' | ||||
|             ) | ||||
|           }}:{{ loginStore.email }} | ||||
|           }}:{{ userStore.email }} | ||||
|         </a-typography-paragraph> | ||||
|         <a-typography-paragraph v-else class="tip"> | ||||
|           {{ | ||||
| @@ -114,13 +114,13 @@ | ||||
|   import { getMailCaptcha } from '@/api/common/captcha'; | ||||
|   import { updateEmail } from '@/api/system/user-center'; | ||||
|   import { useI18n } from 'vue-i18n'; | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|   import { encryptByRsa } from '@/utils/encrypt'; | ||||
|  | ||||
|   const { proxy } = getCurrentInstance() as any; | ||||
|  | ||||
|   const { t } = useI18n(); | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const captchaTime = ref(60); | ||||
|   const captchaTimer = ref(); | ||||
|   const captchaLoading = ref(false); | ||||
| @@ -155,7 +155,7 @@ | ||||
|         }, | ||||
|         { | ||||
|           validator: (value, callback) => { | ||||
|             if (value === loginStore.email) { | ||||
|             if (value === userStore.email) { | ||||
|               callback( | ||||
|                 t( | ||||
|                   'userCenter.securitySettings.updateEmail.form.error.validator.newEmail' | ||||
| @@ -261,7 +261,7 @@ | ||||
|           currentPassword: encryptByRsa(form.currentPassword) || '', | ||||
|         }).then((res) => { | ||||
|           handleCancel(); | ||||
|           loginStore.getInfo(); | ||||
|           userStore.getInfo(); | ||||
|           proxy.$message.success(res.msg); | ||||
|         }); | ||||
|       } | ||||
|   | ||||
| @@ -7,12 +7,12 @@ | ||||
|     </template> | ||||
|     <template #description> | ||||
|       <div class="content"> | ||||
|         <a-typography-paragraph v-if="loginStore.phone"> | ||||
|         <a-typography-paragraph v-if="userStore.phone"> | ||||
|           {{ | ||||
|             $t( | ||||
|               'userCenter.securitySettings.updatePhone.placeholder.success.phone' | ||||
|             ) | ||||
|           }}:{{ loginStore.phone }} | ||||
|           }}:{{ userStore.phone }} | ||||
|         </a-typography-paragraph> | ||||
|         <a-typography-paragraph v-else class="tip"> | ||||
|           {{ | ||||
| @@ -32,9 +32,9 @@ | ||||
| </template> | ||||
|  | ||||
| <script lang="ts" setup> | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|  | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
| </script> | ||||
|  | ||||
| <style scoped lang="less"></style> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     </template> | ||||
|     <template #description> | ||||
|       <div class="content"> | ||||
|         <a-typography-paragraph v-if="loginStore.pwdResetTime"> | ||||
|         <a-typography-paragraph v-if="userStore.pwdResetTime"> | ||||
|           {{ | ||||
|             $t( | ||||
|               'userCenter.securitySettings.updatePwd.placeholder.success.password' | ||||
| @@ -102,13 +102,13 @@ | ||||
|   import { FieldRule } from '@arco-design/web-vue'; | ||||
|   import { updatePassword } from '@/api/system/user-center'; | ||||
|   import { useI18n } from 'vue-i18n'; | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|   import { encryptByRsa } from '@/utils/encrypt'; | ||||
|  | ||||
|   const { proxy } = getCurrentInstance() as any; | ||||
|  | ||||
|   const { t } = useI18n(); | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const visible = ref(false); | ||||
|  | ||||
|   // 表单数据 | ||||
|   | ||||
| @@ -38,31 +38,31 @@ | ||||
|         layout="inline-horizontal" | ||||
|       > | ||||
|         <a-descriptions-item :label="$t('userCenter.panel.label.nickname')">{{ | ||||
|           loginStore.nickname | ||||
|           userStore.nickname | ||||
|         }}</a-descriptions-item> | ||||
|         <a-descriptions-item :label="$t('userCenter.panel.label.gender')"> | ||||
|           <div v-if="loginStore.gender === 1"> | ||||
|           <div v-if="userStore.gender === 1"> | ||||
|             {{ $t('userCenter.panel.male') }} | ||||
|             <icon-man style="color: #19bbf1" /> | ||||
|           </div> | ||||
|           <div v-else-if="loginStore.gender === 2"> | ||||
|           <div v-else-if="userStore.gender === 2"> | ||||
|             {{ $t('userCenter.panel.female') }} | ||||
|             <icon-woman style="color: #fa7fa9" /> | ||||
|           </div> | ||||
|           <div v-else>{{ $t('userCenter.panel.unknown') }}</div> | ||||
|         </a-descriptions-item> | ||||
|         <a-descriptions-item :label="$t('userCenter.panel.label.phone')">{{ | ||||
|           loginStore.phone || '暂无' | ||||
|           userStore.phone || '暂无' | ||||
|         }}</a-descriptions-item> | ||||
|         <a-descriptions-item :label="$t('userCenter.panel.label.email')">{{ | ||||
|           loginStore.email || '暂无' | ||||
|           userStore.email || '暂无' | ||||
|         }}</a-descriptions-item> | ||||
|         <a-descriptions-item :label="$t('userCenter.panel.label.deptName')">{{ | ||||
|           loginStore.deptName | ||||
|           userStore.deptName | ||||
|         }}</a-descriptions-item> | ||||
|         <a-descriptions-item | ||||
|           :label="$t('userCenter.panel.label.registrationDate')" | ||||
|           >{{ loginStore.registrationDate }}</a-descriptions-item | ||||
|           >{{ userStore.registrationDate }}</a-descriptions-item | ||||
|         > | ||||
|       </a-descriptions> | ||||
|     </a-space> | ||||
| @@ -73,16 +73,16 @@ | ||||
|   import { getCurrentInstance, ref } from 'vue'; | ||||
|   import { FileItem, RequestOption } from '@arco-design/web-vue'; | ||||
|   import { uploadAvatar } from '@/api/system/user-center'; | ||||
|   import { useLoginStore } from '@/store'; | ||||
|   import { useUserStore } from '@/store'; | ||||
|   import getAvatar from '@/utils/avatar'; | ||||
|  | ||||
|   const { proxy } = getCurrentInstance() as any; | ||||
|  | ||||
|   const loginStore = useLoginStore(); | ||||
|   const userStore = useUserStore(); | ||||
|   const avatar = { | ||||
|     uid: '-2', | ||||
|     name: 'avatar.png', | ||||
|     url: getAvatar(loginStore.avatar, loginStore.gender), | ||||
|     url: getAvatar(userStore.avatar, userStore.gender), | ||||
|   }; | ||||
|   const avatarList = ref<FileItem[]>([avatar]); | ||||
|  | ||||
| @@ -107,7 +107,7 @@ | ||||
|       uploadAvatar(formData) | ||||
|         .then((res) => { | ||||
|           onSuccess(res); | ||||
|           loginStore.avatar = res.data.avatar; | ||||
|           userStore.avatar = res.data.avatar; | ||||
|           proxy.$message.success(res.msg); | ||||
|         }) | ||||
|         .catch((error) => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user