fix(系统设置): 组织不存在项目时或项目被禁用涉及的路由跳转问题
--bug=1039530 --user=宋昌昌 【系统设置】项目-模版-新创建组织没有项目的情况下提示已开启项目模版,建议优化 https://www.tapd.cn/55049933/s/1505085
This commit is contained in:
parent
5bde86d4d9
commit
d9943bbf14
|
@ -113,10 +113,12 @@ public class BugAttachmentService {
|
|||
Map<String, FileMetadata> fileMetadataMap = getLinkFileMetaMap(associateFileIds);
|
||||
fileAssociations.forEach(associatedFile -> {
|
||||
FileMetadata associatedFileMetadata = fileMetadataMap.get(associatedFile.getFileId());
|
||||
BugFileDTO associatedFileDTO = BugFileDTO.builder().refId(associatedFile.getId()).fileId(associatedFile.getFileId()).fileName(associatedFileMetadata.getName() + "." + associatedFileMetadata.getType())
|
||||
.fileType(associatedFileMetadata.getType()).fileSize(associatedFileMetadata.getSize()).createTime(associatedFileMetadata.getCreateTime())
|
||||
.createUser(associatedFileMetadata.getCreateUser()).local(false).build();
|
||||
bugFiles.add(associatedFileDTO);
|
||||
if (associatedFileMetadata != null) {
|
||||
BugFileDTO associatedFileDTO = BugFileDTO.builder().refId(associatedFile.getId()).fileId(associatedFile.getFileId()).fileName(associatedFileMetadata.getName() + "." + associatedFileMetadata.getType())
|
||||
.fileType(associatedFileMetadata.getType()).fileSize(associatedFileMetadata.getSize()).createTime(associatedFileMetadata.getCreateTime())
|
||||
.createUser(associatedFileMetadata.getCreateUser()).local(false).build();
|
||||
bugFiles.add(associatedFileDTO);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (CollectionUtils.isEmpty(bugFiles)) {
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
package io.metersphere.system.controller;
|
||||
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.constants.UserSource;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.RsaKey;
|
||||
import io.metersphere.sdk.util.RsaUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.controller.handler.result.MsHttpResultCode;
|
||||
import io.metersphere.system.dto.sdk.LoginRequest;
|
||||
import io.metersphere.system.dto.sdk.SessionUser;
|
||||
import io.metersphere.system.dto.user.UserDTO;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.service.UserLoginService;
|
||||
import io.metersphere.sdk.util.RsaKey;
|
||||
import io.metersphere.sdk.util.RsaUtils;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
|
@ -34,6 +36,8 @@ public class LoginController {
|
|||
|
||||
@Resource
|
||||
private UserLoginService userLoginService;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
|
||||
@GetMapping(value = "/is-login")
|
||||
|
@ -49,8 +53,9 @@ public class LoginController {
|
|||
userLoginService.autoSwitch(userDTO);
|
||||
SessionUser sessionUser = SessionUser.fromUser(userDTO, SessionUtils.getSessionId());
|
||||
SessionUtils.putUser(sessionUser);
|
||||
// 用户只有工作空间权限
|
||||
if (StringUtils.isBlank(sessionUser.getLastProjectId())) {
|
||||
// 用户只有工作空间权限, 或者项目已被禁用
|
||||
Project lastProject = projectMapper.selectByPrimaryKey(sessionUser.getLastProjectId());
|
||||
if (StringUtils.isBlank(sessionUser.getLastProjectId()) || lastProject == null || !lastProject.getEnable()) {
|
||||
sessionUser.setLastProjectId("no_such_project");
|
||||
}
|
||||
return ResultHolder.success(sessionUser);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
import { getOrgOptions, switchUserOrg } from '@/api/modules/system';
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
import useUser from '@/hooks/useUser';
|
||||
import { BOTTOM_MENU_LIST } from '@/router/constants';
|
||||
import { BOTTOM_MENU_LIST, NO_PROJECT_ROUTE_NAME } from '@/router/constants';
|
||||
import { useAppStore, useUserStore } from '@/store';
|
||||
import useLicenseStore from '@/store/modules/setting/license';
|
||||
import { openWindow, regexUrl } from '@/utils';
|
||||
|
@ -20,7 +20,7 @@
|
|||
import { getFisrtRouterNameByCurrentRoute } from '@/utils/permission';
|
||||
import { listenerRouteChange } from '@/utils/route-listener';
|
||||
|
||||
import { SettingRouteEnum } from '@/enums/routeEnum';
|
||||
import { ProjectManagementRouteEnum, SettingRouteEnum } from '@/enums/routeEnum';
|
||||
|
||||
import useMenuTree from './use-menu-tree';
|
||||
import type { RouteMeta } from 'vue-router';
|
||||
|
@ -148,14 +148,34 @@
|
|||
personalMenusVisible.value = false;
|
||||
orgKeyword.value = '';
|
||||
await userStore.isLogin(true);
|
||||
router.replace({
|
||||
path: route.path,
|
||||
query: {
|
||||
...route.query,
|
||||
orgId: appStore.currentOrgId,
|
||||
pId: appStore.currentProjectId,
|
||||
},
|
||||
});
|
||||
if (!appStore.currentProjectId || appStore.currentProjectId === 'no_such_project') {
|
||||
// 没有项目权限(组织没有项目, 或项目全被禁用)
|
||||
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,
|
||||
},
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error);
|
||||
|
|
|
@ -16,6 +16,7 @@ export default function usePermission() {
|
|||
* @returns 是否
|
||||
*/
|
||||
accessRouter(route: RouteLocationNormalized | RouteRecordRaw) {
|
||||
console.log(useUserStore());
|
||||
if (
|
||||
(useUserStore().lastProjectId === 'no_such_project' || useUserStore().lastProjectId === '') &&
|
||||
route.name === 'projectManagement'
|
||||
|
|
|
@ -36,7 +36,11 @@ const useTemplateStore = defineStore('template', {
|
|||
if (currentOrgId.value && hasAnyPermission(['ORGANIZATION_TEMPLATE:READ'])) {
|
||||
this.ordStatus = await getOrdTemplate(currentOrgId.value);
|
||||
}
|
||||
if (currentProjectId.value && hasAnyPermission(['PROJECT_TEMPLATE:READ'])) {
|
||||
if (
|
||||
currentProjectId.value &&
|
||||
hasAnyPermission(['PROJECT_TEMPLATE:READ']) &&
|
||||
currentProjectId.value !== 'no_such_project'
|
||||
) {
|
||||
this.projectStatus = await getProTemplate(currentProjectId.value);
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue