|
@@ -1,11 +1,11 @@
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { computed, ref, watch } from 'vue';
|
|
|
|
|
|
|
+import { computed, onMounted, ref, watch } from 'vue';
|
|
|
|
|
|
|
|
-import { useUserStore } from '@vben/stores';
|
|
|
|
|
|
|
+import { useAccessStore, useUserStore } from '@vben/stores';
|
|
|
|
|
|
|
|
import { Col, Row } from 'antdv-next';
|
|
import { Col, Row } from 'antdv-next';
|
|
|
|
|
|
|
|
-import { getAllMenusApi } from '#/api';
|
|
|
|
|
|
|
+import { getAllMenusApi, getUserInfoApi } from '#/api';
|
|
|
|
|
|
|
|
import ApplicationManagement from './application-management.vue';
|
|
import ApplicationManagement from './application-management.vue';
|
|
|
import DeliveryPartners from './delivery-partners.vue';
|
|
import DeliveryPartners from './delivery-partners.vue';
|
|
@@ -15,6 +15,7 @@ import SalesPartners from './sales-partners.vue';
|
|
|
import UserInfo from './user-info.vue';
|
|
import UserInfo from './user-info.vue';
|
|
|
|
|
|
|
|
const userStore = useUserStore();
|
|
const userStore = useUserStore();
|
|
|
|
|
+const accessStore = useAccessStore();
|
|
|
|
|
|
|
|
const isLogin = computed(() => !!userStore.userInfo);
|
|
const isLogin = computed(() => !!userStore.userInfo);
|
|
|
const menus = ref<any[]>([]);
|
|
const menus = ref<any[]>([]);
|
|
@@ -23,6 +24,35 @@ const enterpriseCustomersShow = ref(true);
|
|
|
const applicationManagementShow = ref(true);
|
|
const applicationManagementShow = ref(true);
|
|
|
const deliveryPartnersShow = ref(true);
|
|
const deliveryPartnersShow = ref(true);
|
|
|
|
|
|
|
|
|
|
+async function checkTokenAndGetUserInfo() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const token = localStorage.getItem('token_a');
|
|
|
|
|
+ if (token) {
|
|
|
|
|
+ accessStore.setAccessToken(token);
|
|
|
|
|
+ const userInfoRes = await getUserInfoApi();
|
|
|
|
|
+ if (userInfoRes && userInfoRes.isSuccess) {
|
|
|
|
|
+ const userInfo = {
|
|
|
|
|
+ account:
|
|
|
|
|
+ userInfoRes.result?.account ||
|
|
|
|
|
+ userInfoRes.result?.englishName ||
|
|
|
|
|
+ '',
|
|
|
|
|
+ avatar: userInfoRes.result?.avatarFileId || '',
|
|
|
|
|
+ cellPhone: userInfoRes.result?.cellPhone || '',
|
|
|
|
|
+ realName:
|
|
|
|
|
+ userInfoRes.result?.chineseName || userInfoRes.result?.name || '',
|
|
|
|
|
+ email: userInfoRes.result?.emailAddress || '',
|
|
|
|
|
+ roles: [],
|
|
|
|
|
+ userId: userInfoRes.result?.id || '',
|
|
|
|
|
+ username: userInfoRes.result?.name || '',
|
|
|
|
|
+ };
|
|
|
|
|
+ userStore.setUserInfo(userInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('检查token并获取用户信息失败:', error);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
async function fetchMenus() {
|
|
async function fetchMenus() {
|
|
|
try {
|
|
try {
|
|
|
const result = await getAllMenusApi();
|
|
const result = await getAllMenusApi();
|
|
@@ -46,6 +76,10 @@ watch(
|
|
|
},
|
|
},
|
|
|
{ immediate: true },
|
|
{ immediate: true },
|
|
|
);
|
|
);
|
|
|
|
|
+
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ checkTokenAndGetUserInfo();
|
|
|
|
|
+});
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
<template>
|