From 144b26f2130fdff329727ed8c4e235817f36adec Mon Sep 17 00:00:00 2001 From: RubyLiu Date: Wed, 24 Jan 2024 21:53:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=97=A0=E6=9D=83=E9=99=90&=E6=97=A0?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E9=A1=B5=E9=9D=A2=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.vue | 15 ++- .../modules/setting/organizationAndProject.ts | 7 +- frontend/src/assets/svg/no_resource.svg | 24 ++++ .../business/ms-user-selector/types.ts | 7 ++ frontend/src/layout/default-layout.vue | 93 ++++++++------- frontend/src/layout/single-logo-layout.vue | 111 ++++++++++++++++++ frontend/src/locale/en-US/common.ts | 3 + frontend/src/locale/zh-CN/common.ts | 3 + frontend/src/router/constants.ts | 6 + frontend/src/router/guard/permission.ts | 4 +- frontend/src/router/index.ts | 4 +- frontend/src/router/routes/base.ts | 20 +++- .../routes/modules/projectManagement.ts | 4 +- frontend/src/store/modules/app/index.ts | 9 +- frontend/src/views/base/no-project/index.vue | 86 ++++++++++++++ frontend/src/views/base/no-resource/index.vue | 7 ++ .../userGroup/projectUserGroup.vue | 17 ++- 17 files changed, 355 insertions(+), 65 deletions(-) create mode 100644 frontend/src/assets/svg/no_resource.svg create mode 100644 frontend/src/components/business/ms-user-selector/types.ts create mode 100644 frontend/src/layout/single-logo-layout.vue create mode 100644 frontend/src/views/base/no-project/index.vue create mode 100644 frontend/src/views/base/no-resource/index.vue diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 4de1b00b93..25ca9381e1 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -10,6 +10,7 @@ import { useRoute, useRouter } from 'vue-router'; import { useEventListener, useWindowSize } from '@vueuse/core'; + import { getProjectInfo } from '@/api/modules/project-management/basicInfo'; import { saveBaseUrl } from '@/api/modules/setting/config'; import { GetPlatformIconUrl } from '@/api/requrls/setting/config'; // import GlobalSetting from '@/components/pure/global-setting/index.vue'; @@ -69,7 +70,19 @@ const isLoginPage = route.name === 'login'; if (isLogin && appStore.currentProjectId) { // 当前为登陆状态,且已经选择了项目,初始化当前项目配置 - appStore.setCurrentMenuConfig(); + try { + const res = await getProjectInfo(appStore.currentProjectId); + if (res.deleted || !res.enable) { + // 如果项目被删除或者被禁用,跳转到无项目页面 + router.push(WorkbenchRouteEnum.WORKBENCH); + return; + } + appStore.setCurrentMenuConfig(res.moduleIds); + } catch (err) { + appStore.setCurrentMenuConfig([]); + // eslint-disable-next-line no-console + console.log(err); + } } if (isLoginPage && isLogin) { // 当前页面为登录页面,且已经登录,跳转到首页 diff --git a/frontend/src/api/modules/setting/organizationAndProject.ts b/frontend/src/api/modules/setting/organizationAndProject.ts index e146d3ec42..a99524991e 100644 --- a/frontend/src/api/modules/setting/organizationAndProject.ts +++ b/frontend/src/api/modules/setting/organizationAndProject.ts @@ -1,3 +1,5 @@ +import { MsUserSelectorOption } from '@/components/business/ms-user-selector/types'; + import MSR from '@/api/http/index'; import * as orgUrl from '@/api/requrls/setting/organizationAndProject'; @@ -172,7 +174,10 @@ export function addProjectMemberByOrg(data: AddUserToOrgOrProjectParams) { // 组织-获取项目下的管理员选项 export function getAdminByProjectByOrg(organizationId: string, keyword: string) { - return MSR.get({ url: `${orgUrl.getAdminByOrganizationOrProjectUrl}${organizationId}`, params: { keyword } }); + return MSR.get({ + url: `${orgUrl.getAdminByOrganizationOrProjectUrl}${organizationId}`, + params: { keyword }, + }); } // 组织-获取成员下的成员选项 diff --git a/frontend/src/assets/svg/no_resource.svg b/frontend/src/assets/svg/no_resource.svg new file mode 100644 index 0000000000..a80a203566 --- /dev/null +++ b/frontend/src/assets/svg/no_resource.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/src/components/business/ms-user-selector/types.ts b/frontend/src/components/business/ms-user-selector/types.ts new file mode 100644 index 0000000000..2e25a93fe0 --- /dev/null +++ b/frontend/src/components/business/ms-user-selector/types.ts @@ -0,0 +1,7 @@ +export interface MsUserSelectorOption { + id: string; + name: string; + email: string; + disabled?: boolean; + [key: string]: string | number | boolean | undefined; +} diff --git a/frontend/src/layout/default-layout.vue b/frontend/src/layout/default-layout.vue index b5e2e43b2a..6e9af107ac 100644 --- a/frontend/src/layout/default-layout.vue +++ b/frontend/src/layout/default-layout.vue @@ -3,55 +3,57 @@
- + - - - - - - - - - - - - - - -