Parcourir la source

refactor: 更新参数信息

lixuan il y a 3 semaines
Parent
commit
2956083e01

+ 4 - 2
apps/web-velofex/src/views/dashboard/application-management/index.vue

@@ -1,6 +1,6 @@
 <script setup lang="ts">
 import { computed, ref, watch } from 'vue';
-import { useRoute } from 'vue-router';
+import { useRoute, useRouter } from 'vue-router';
 
 import { useUserStore } from '@vben/stores';
 
@@ -39,6 +39,8 @@ const isLogin = computed(() => !!userStore.userInfo);
 const applicationList = ref<UserApi.ApplicationModel[]>([]);
 const loading = ref(false);
 
+const router = useRouter();
+
 const searchParams = ref({
   applicationName: '',
   applicationId: '',
@@ -220,7 +222,7 @@ async function deleteApplication(item: any) {
 }
 
 function handleClick(item: UserApi.ApplicationModel) {
-  window.open(`/jumpToEnterprise?enterpriseCode=${item.code}`, '_blank');
+  router.push({ path: `/jumpToEnterprise?enterpriseCode=${item.code}` });
 }
 
 watch(

+ 1 - 1
apps/web-velofex/src/views/dashboard/home/application-management.vue

@@ -70,7 +70,7 @@ function handleMore() {
 }
 
 function handleClick(item: UserApi.ApplicationModel) {
-  window.open(`/jumpToEnterprise?enterpriseCode=${item.code}`, '_blank');
+  router.push({ path: `/jumpToEnterprise?enterpriseCode=${item.code}` });
 }
 
 watch(

+ 37 - 3
apps/web-velofex/src/views/dashboard/home/index.vue

@@ -1,11 +1,11 @@
 <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 { getAllMenusApi } from '#/api';
+import { getAllMenusApi, getUserInfoApi } from '#/api';
 
 import ApplicationManagement from './application-management.vue';
 import DeliveryPartners from './delivery-partners.vue';
@@ -15,6 +15,7 @@ import SalesPartners from './sales-partners.vue';
 import UserInfo from './user-info.vue';
 
 const userStore = useUserStore();
+const accessStore = useAccessStore();
 
 const isLogin = computed(() => !!userStore.userInfo);
 const menus = ref<any[]>([]);
@@ -23,6 +24,35 @@ const enterpriseCustomersShow = ref(true);
 const applicationManagementShow = 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() {
   try {
     const result = await getAllMenusApi();
@@ -46,6 +76,10 @@ watch(
   },
   { immediate: true },
 );
+
+onMounted(() => {
+  checkTokenAndGetUserInfo();
+});
 </script>
 
 <template>

+ 1 - 1
apps/web-velofex/src/views/dashboard/home/product-list.vue

@@ -65,7 +65,7 @@ function handleMore() {
 }
 
 function handleClick(item: UserApi.ApplicationModel) {
-  window.open(`/jumpToEnterprise?enterpriseCode=${item.code}`, '_blank');
+  router.push({ path: `/jumpToEnterprise?enterpriseCode=${item.code}` });
 }
 
 watch(