无人机管理后台前端(已迁走)
罗广辉
2025-07-21 134be8a104645503793668e8c6f8b40fa5b73af1
fix: 尝试修复首次进入页面空白错误
1 files modified
21 ■■■■ changed files
src/store/modules/user.js 21 ●●●● patch | view | raw | blame | history
src/store/modules/user.js
@@ -27,6 +27,7 @@
import { encrypt } from '@/utils/sm2';
import md5 from 'js-md5';
const user = {
  state: {
    tenantId: getStore({ name: 'tenantId' }) || '',
@@ -269,20 +270,30 @@
      });
    },
    GetMenu({ commit, dispatch }, tenantId) {
      const errLogOut = () => {
        dispatch('LogOut').then(()=>{
          const env = import.meta.env.VITE_APP_ENV
          const adminUrl = import.meta.env.VITE_APP_DASHBOARD_URL
          env === 'development'
            ? window.location.href = "/manage/login"
            : window.location.replace(`${adminUrl}#/login`)
        })
      }
      return new Promise(resolve => {
        getRoutes(tenantId).then(res => {
          const data = res.data.data;
          let menu = deepClone(data);
          menu?.forEach(ele => formatPath(ele, true));
          if (!res.data?.data?.length){
            errLogOut()
            return
          }
          menu.forEach(ele => formatPath(ele, true));
          commit('SET_MENU', menu);
          commit('SET_MENU_ALL', menu);
          dispatch('GetButtons');
          resolve(menu);
        }).catch(err =>{
          dispatch('LogOut').then(()=>{
            const adminUrl = import.meta.env.VITE_APP_DASHBOARD_URL
            window.location.replace(`${adminUrl}#/login`)
          })
          errLogOut()
        })
      });
    },