菜单新增 alwaysShow 总是展示、componentName 组件名

This commit is contained in:
YunaiV
2023-02-10 23:03:10 +08:00
parent 877e2376be
commit 35ba9b36af
26 changed files with 923 additions and 704 deletions

View File

@ -30,6 +30,9 @@ public class AuthMenuRespVO {
@Schema(description = "组件路径,仅菜单类型为菜单时,才需要传", example = "system/post/index")
private String component;
@Schema(description = "组件名", example = "SystemUser")
private String componentName;
@Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list")
private String icon;
@ -39,6 +42,9 @@ public class AuthMenuRespVO {
@Schema(description = "是否缓存", required = true, example = "false")
private Boolean keepAlive;
@Schema(description = "是否总是显示", example = "false")
private Boolean alwaysShow;
/**
* 子路由
*/

View File

@ -46,6 +46,9 @@ public class MenuBaseVO {
@Size(max = 200, message = "组件路径不能超过255个字符")
private String component;
@Schema(description = "组件名", example = "SystemUser")
private String componentName;
@Schema(description = "状态,见 CommonStatusEnum 枚举", required = true, example = "1")
@NotNull(message = "状态不能为空")
private Integer status;
@ -56,4 +59,7 @@ public class MenuBaseVO {
@Schema(description = "是否缓存", example = "false")
private Boolean keepAlive;
@Schema(description = "是否总是显示", example = "false")
private Boolean alwaysShow;
}

View File

@ -61,6 +61,8 @@ public class MenuDO extends BaseDO {
private Long parentId;
/**
* 路由地址
*
* 如果 path 为 http(s) 时,则它是外链
*/
private String path;
/**
@ -71,6 +73,10 @@ public class MenuDO extends BaseDO {
* 组件路径
*/
private String component;
/**
* 组件名
*/
private String componentName;
/**
* 状态
*
@ -87,9 +93,15 @@ public class MenuDO extends BaseDO {
/**
* 是否缓存
*
* 只有菜单、目录使用
* 是否使用 Vue 路由的 keep-alive 特性
* 只有菜单、目录使用,否使用 Vue 路由的 keep-alive 特性
* 注意:如果开启缓存,则必须填写 {@link #componentName} 属性,否则无法缓存
*/
private Boolean keepAlive;
/**
* 是否总是显示
*
* 如果为 false 时,当该菜单只有一个子菜单时,不展示自己,直接展示子菜单
*/
private Boolean alwaysShow;
}

View File

@ -278,6 +278,7 @@ public class MenuServiceImpl implements MenuService {
// 菜单为按钮类型时,无需 component、icon、path 属性,进行置空
if (MenuTypeEnum.BUTTON.getType().equals(menu.getType())) {
menu.setComponent("");
menu.setComponentName("");
menu.setIcon("");
menu.setPath("");
}

View File

@ -76,9 +76,11 @@ CREATE TABLE IF NOT EXISTS "system_menu" (
"path" varchar(200) DEFAULT '',
"icon" varchar(100) DEFAULT '#',
"component" varchar(255) DEFAULT NULL,
"component_name" varchar(255) DEFAULT NULL,
"status" tinyint NOT NULL DEFAULT '0',
"visible" bit NOT NULL DEFAULT TRUE,
"keep_alive" bit NOT NULL DEFAULT TRUE,
"always_show" bit NOT NULL DEFAULT TRUE,
"creator" varchar(64) DEFAULT '',
"create_time" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updater" varchar(64) DEFAULT '',