From 28db5873ad3dab44739bdf2b4ee680a55f69b66a Mon Sep 17 00:00:00 2001 From: baiqi Date: Tue, 28 May 2024 11:53:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=85=A8=E5=B1=80):=20=20=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E7=BB=84=E7=BB=87=E3=80=81=E7=99=BB=E5=BD=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/business/ms-menu/index.vue | 47 +++++-------------- .../pure/ms-minder-editor/main/mainEditor.vue | 2 +- .../src/models/caseManagement/featureCase.ts | 28 ++++++----- frontend/src/views/base/no-project/index.vue | 8 ++-- .../src/views/login/components/login-form.vue | 2 +- frontend/src/views/setting/utils.ts | 8 ++-- 6 files changed, 36 insertions(+), 59 deletions(-) diff --git a/frontend/src/components/business/ms-menu/index.vue b/frontend/src/components/business/ms-menu/index.vue index a52e57d75f..00eb079e84 100644 --- a/frontend/src/components/business/ms-menu/index.vue +++ b/frontend/src/components/business/ms-menu/index.vue @@ -12,15 +12,15 @@ import { getOrgOptions, switchUserOrg } from '@/api/modules/system'; import { useI18n } from '@/hooks/useI18n'; import useUser from '@/hooks/useUser'; - import { BOTTOM_MENU_LIST, NO_PROJECT_ROUTE_NAME } from '@/router/constants'; + import { BOTTOM_MENU_LIST } from '@/router/constants'; import { useAppStore, useUserStore } from '@/store'; import useLicenseStore from '@/store/modules/setting/license'; import { openWindow, regexUrl } from '@/utils'; import { scrollIntoView } from '@/utils/dom'; - import { getFirstRouterNameByCurrentRoute } from '@/utils/permission'; + import { getFirstRouteNameByPermission, getFirstRouterNameByCurrentRoute } from '@/utils/permission'; import { listenerRouteChange } from '@/utils/route-listener'; - import { ProjectManagementRouteEnum, SettingRouteEnum } from '@/enums/routeEnum'; + import { SettingRouteEnum } from '@/enums/routeEnum'; import useMenuTree from './use-menu-tree'; import type { RouteMeta } from 'vue-router'; @@ -147,38 +147,15 @@ Message.success(t('personal.switchOrgSuccess')); personalMenusVisible.value = false; orgKeyword.value = ''; - await userStore.isLogin(true); - if ( - (!appStore.currentProjectId || appStore.currentProjectId === 'no_such_project') && - !(route.name as string).startsWith(SettingRouteEnum.SETTING) - ) { - // 没有项目权限(组织没有项目, 或项目全被禁用)且访问的页面非系统菜单模块,则重定向到无项目权限页面 - router.push({ - name: NO_PROJECT_ROUTE_NAME, - }); - return; - } - if (route.name === NO_PROJECT_ROUTE_NAME) { - // 无项目权限组织切换到正常组织, 默认跳转到项目基本信息页面 - router.replace({ - name: ProjectManagementRouteEnum.PROJECT_MANAGEMENT_PERMISSION_BASIC_INFO, - query: { - ...route.query, - orgId: appStore.currentOrgId, - pId: appStore.currentProjectId, - }, - }); - } else { - // 正常切换组织 - router.replace({ - path: route.path, - query: { - ...route.query, - orgId: appStore.currentOrgId, - pId: appStore.currentProjectId, - }, - }); - } + await userStore.checkIsLogin(); + appStore.hideLoading(); + router.replace({ + name: getFirstRouteNameByPermission(router.getRoutes()), + query: { + orgId: appStore.currentOrgId, + pId: appStore.currentProjectId, + }, + }); } catch (error) { // eslint-disable-next-line no-console console.log(error); diff --git a/frontend/src/components/pure/ms-minder-editor/main/mainEditor.vue b/frontend/src/components/pure/ms-minder-editor/main/mainEditor.vue index 2a17bbdc58..8b0b5d5e26 100644 --- a/frontend/src/components/pure/ms-minder-editor/main/mainEditor.vue +++ b/frontend/src/components/pure/ms-minder-editor/main/mainEditor.vue @@ -3,7 +3,7 @@ {{ t('minder.main.main.save') }} - + import { onBeforeMount, Ref, ref } from 'vue'; - import { useRoute, useRouter } from 'vue-router'; + import { useRouter } from 'vue-router'; import NoPermissionLayoutVue from '@/layout/no-permission-layout.vue'; @@ -43,7 +43,6 @@ const userStore = useUserStore(); - const route = useRoute(); const router = useRouter(); const { t } = useI18n(); @@ -72,12 +71,13 @@ // eslint-disable-next-line no-console console.log(error); } finally { + await userStore.checkIsLogin(); + appStore.hideLoading(); router.replace({ name: getFirstRouteNameByPermission(router.getRoutes()), query: { - ...route.query, orgId: appStore.currentOrgId, - pId: appStore.currentProjectId, + pId: value as string, }, }); } diff --git a/frontend/src/views/login/components/login-form.vue b/frontend/src/views/login/components/login-form.vue index c69fc3239d..080f1a8d17 100644 --- a/frontend/src/views/login/components/login-form.vue +++ b/frontend/src/views/login/components/login-form.vue @@ -179,7 +179,7 @@ loginConfig.value.password = rememberPassword ? password : ''; if ( (!appStore.currentProjectId || appStore.currentProjectId === 'no_such_project') && - !(router.currentRoute.value as unknown as string).startsWith(SettingRouteEnum.SETTING) + !router.currentRoute.value.path.startsWith(SettingRouteEnum.SETTING) ) { // 没有项目权限(用户所在的当前项目被禁用&用户被移除出去该项目/白板用户没有项目)且访问的页面非系统菜单模块,则重定向到无项目权限页面 router.push({ diff --git a/frontend/src/views/setting/utils.ts b/frontend/src/views/setting/utils.ts index 14e3ddb59b..2245d3035c 100644 --- a/frontend/src/views/setting/utils.ts +++ b/frontend/src/views/setting/utils.ts @@ -10,9 +10,7 @@ import { NO_PROJECT_ROUTE_NAME } from '@/router/constants'; import { useUserStore } from '@/store'; import useAppStore from '@/store/modules/app'; import useLicenseStore from '@/store/modules/setting/license'; -import { hasAnyPermission } from '@/utils/permission'; - -import { ProjectManagementRouteEnum } from '@/enums/routeEnum'; +import { getFirstRouteNameByPermission, hasAnyPermission } from '@/utils/permission'; const { t } = useI18n(); const userStore = useUserStore(); @@ -41,10 +39,10 @@ export async function enterProject(projectId: string, organizationId?: string) { await userStore.checkIsLogin(); // 跳转到项目页面 router.replace({ - name: ProjectManagementRouteEnum.PROJECT_MANAGEMENT_PERMISSION, + name: getFirstRouteNameByPermission(router.getRoutes()), query: { orgId: appStore.currentOrgId, - pId: appStore.currentProjectId, + pId: projectId, }, }); } catch (error) {