
本手册涵盖了 OneCode 框架中导航类组件的核心注解及其子注解。
@LayoutAnnotation:用于配置布局属性,常与导航类注解结合使用这些注解密切相关,共同用于构建复杂的导航结构和布局,特别是在系统管理模块中有着广泛应用。
@Inherited
@CustomClass(clazz = FullNavGalleryComponent.class, viewType = CustomViewType.FRAME, moduleType = ModuleViewType.NAVGALLERYCONFIG)
@Retention(RetentionPolicy.RUNTIME)
@BeanClass(clazz = NavGalleryDataBean.class)
@Target({ElementType.METHOD})
public @interface NavGalleryViewAnnotation {
String expression() default "";
String dataUrl() default "";
@NotNull
boolean cache() default false;
}@Inherited
@Retention(RetentionPolicy.RUNTIME)
@BeanClass(clazz = NavGroupViewBean.class)
@Target({ElementType.TYPE})
public @interface NavGroupAnnotation {
String expression() default "";
@NotNull
Dock dock() default Dock.none;
boolean noFrame() default false;
@NotNull
boolean toggleBtn() default true;
CustomFormMenu[] customMenu() default {};
CustomFormMenu[] bottombarMenu() default {};
CustomFormEvent[] event() default {};
ComponentType[] bindTypes() default {ComponentType.FormLayout, ComponentType.TreeView, ComponentType.Panel, ComponentType.Group, ComponentType.Dialog};
Class[] customService() default {};
}@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@BeanClass(clazz = NavMenuBarViewBean.class)
public @interface NavMenuBarAnnotation {
CustomFormMenu[] customMenu() default {};
Class[] customService() default {};
}@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.CONSTRUCTOR, ElementType.TYPE})
@BeanClass(clazz = NavFoldingComboViewBean.class)
public @interface NavFoldingTreeAnnotation {
String caption() default "";
Class[] customService() default {};
CustomFormMenu[] customMenu() default {};
CustomFormMenu[] bottombarMenu() default {};
ComponentType[] bindTypes() default {ComponentType.TreeBar, ComponentType.TreeView};
}@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@BeanClass(clazz = NavGalleryComboViewBean.class)
public @interface NavGalleryAnnotation {
String bgimg() default "";
String imageClass() default "";
@NotNull
int columns() default 5;
int rows() default 1;
boolean autoImgSize() default false;
boolean autoItemSize() default false;
boolean iconOnly() default false;
@NotNull
String iconFontSize() default "4em";
String position() default "";
@NotNull
BorderType borderType() default BorderType.none;
@NotNull
String height() default "7em";
String itemMargin() default "";
String itemPadding() default "";
@NotNull
String itemWidth() default "5em";
String itemHeight() default "-1";
String imgWidth() default "-1";
String imgHeight() default "-1";
@NotNull
Dock dock() default Dock.left;
}@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@BeanClass(clazz = CustomLayoutViewBean.class)
public @interface LayoutAnnotation {
LayoutItemAnnotation[] layoutItems() default {};
@NotNull
LayoutType type() default LayoutType.horizontal;
boolean dragSortable() default false;
boolean flexSize() default false;
@NotNull
BorderType borderType() default BorderType.none;
@NotNull
boolean transparent() default true;
NavComboType navComboType() default NavComboType.CUSTOM;
String[] listKey() default {};
String left() default "0em";
String top() default "0em";
@NotNull
Class<? extends Enum> enumClass() default LayoutItemEnums.class;
int conLayoutColumns() default -1;
}@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@BeanClass(clazz = CustomLayoutItemBean.class)
public @interface LayoutItemAnnotation {
@NotNull
String id() default "before";
int max() default 600;
int min() default 200;
int size() default 200;
boolean folded() default false;
boolean locked() default false;
boolean hidden() default false;
boolean cmd() default true;
@NotNull
OverflowType overflow() default OverflowType.auto;
PosType pos();
String expression() default "";
String panelBgClr() default "";
String panelBgImg() default "";
String panelBgImgPos() default "";
String panelBgImgRepeat() default "";
AttachmentType panelBgImgAttachment() default AttachmentType.none;
String itemClass() default "";
public Class[] getBindClass() default {};
String url() default "";
@NotNull
boolean flexSize() default false;
@NotNull
boolean transparent() default true;
String title() default "";
}id: 布局项ID,默认为"before"## 核心属性说明
### 1. 导航类注解通用属性
- `expression`:表达式,用于动态计算值
- `dataUrl`:数据加载URL
- `saveUrl`:保存URL
- `cache`:是否缓存数据
- `dock`:停靠方式
- `caption`:标题
- `customMenu`:自定义菜单
- `customService`:自定义服务类
- `bindTypes`:绑定的组件类型
### 2. LayoutAnnotation 属性
- `layoutItems`:布局项注解数组
- `type`:布局类型(水平/垂直)
- `dragSortable`:是否可拖动排序
- `flexSize`:是否弹性大小
- `borderType`:边框类型
- `transparent`:是否透明
- `navComboType`:导航组合类型
- `listKey`:列表键
- `left`:左边距
- `top`:上边距
- `enumClass`:枚举类
- `conLayoutColumns`:内容布局列数
## 枚举类型解释
### 1. Dock 停靠方式
- `none`:无停靠
- `left`:靠左停靠
- `right`:靠右停靠
- `top`:靠上停靠
- `bottom`:靠下停靠
### 2. BorderType 边框类型
- `none`:无边框
- `solid`:实线边框
- `dashed`:虚线边框
- `dotted`:点线边框
### 3. LayoutType 布局类型
- `horizontal`:水平布局
- `vertical`:垂直布局
### 4. ResponsePathTypeEnum 响应路径类型
- `TABS`:标签页类型
- `TREEVIEW`:树形视图类型
### 5. CustomViewType 自定义视图类型
- `FRAME`:框架
- `NAV`:导航
- `MODULE`:模块
- `LISTMODULE`:模块
- `INNERMODULE`:内部模块
- `COMPONENT`:组件
- `COMBOBOX`:复合组件
### 6. ModuleViewType 模块视图类型
- `GRIDCONFIG`:列表
- `MGRIDCONFIG`:列表
- `GALLERYCONFIG`:画廊
- `OPINIONCONFIG`:意见
- `BUTTONLAYOUTCONFIG`:按钮布局
- `NAVBUTTONLAYOUTCONFIG`:按钮布局
- `TITLEBLOCKCONFIG`:磁贴块
- `CONTENTBLOCKCONFIG`:内容列表
- `MODULECONFIG`:模块视图
- `BLOCKCONFIG`:块视图
- `PANELCONFIG`:面板视图
- `GROUPCONFIG`:导航
- `SVGPAPERCONFIG`:SVGPage
- `DIVCONFIG`:层视图
- `MFORMCONFIG`:表单
- `FORMCONFIG`:表单
- `NAVGROUPCONFIG`:导航
- `DYNCONFIG`:动态
- `NONE`:无界面
- `UPLOADCONFIG`:文件上传
- `NAVGALLERYCONFIG`:画廊导航
- `LAYOUTCONFIG`:布局
- `CHARTCONFIG`:统计图
- `ECHARTCONFIG`:统计图
- `NAVMENUBARCONFIG`:菜单导航
- `NAVFOLDINGTREECONFIG`:Tree导航
- `NAVFOLDINGTABSCONFIG`:NavTabs导航
- `NAVBUTTONVIEWSCONFIG`:按钮导航
- `MBUTTONVIEWSCONFIG`:按钮导航
- `NAVSTACKSCONFIG`:按钮导航
- `NAVTABSCONFIG`:TAB导航
- `NAVTREECONFIG`:Tree导航
- `TREECONFIG`:树形
- `MTREECONFIG`:树形
- `POPTREECONFIG`:弹出树
## 使用示例
### 示例 1:配置导航组
```java
@NavGroupAnnotation(
dock = Dock.left,
toggleBtn = true,
customMenu = {@CustomFormMenu(name = "刷新", icon = "refresh")}
)
public class MyNavGroup {
// 类实现
}示例 2:配置画廊导航@NavGalleryAnnotation(
columns = 4,
rows = 2,
borderType = BorderType.solid,
dock = Dock.top
)
public class MyGalleryNav {
// 类实现
}示例 3:使用 LayoutAnnotation@LayoutAnnotation(
type = LayoutType.horizontal,
borderType = BorderType.dashed,
dragSortable = true
)
public class MyLayout {
// 类实现
}示例 4:系统管理菜单类级别注解@Controller
@RequestMapping("/system/")
@MenuBarMenu(menuType = CustomMenuType.MENUBAR)
@Aggregation(userSpace = UserSpace.SYS)
@BlockAnnotation(borderType = BorderType.none, dock = Dock.fill)
@LayoutAnnotation(transparent = false, type = LayoutType.vertical, layoutItems = {
@LayoutItemAnnotation(panelBgClr = "#3498DB", size = 28, pos = PosType.before, locked = true, cmd = false)
})
public class SystemMenu {
// ... 类内容
}示例 5:树形导航方法级别注解@MethodChinaName(cname = "系统管理")
@RequestMapping(method = RequestMethod.POST, value = "SystemNav")
@NavTreeViewAnnotation
@ModuleAnnotation(imageClass = "xui-icon-bullet", caption = "系统管理")
@CustomAnnotation(index = 0)
@ResponseBody
public ResultModel<SystemNav> getSystemNav(String projectId) {
return new ResultModel<SystemNav>();
}max: 最大大小,默认为600min: 最小大小,默认为200size: 大小,默认为200folded: 是否折叠,默认为falselocked: 是否锁定,默认为falsehidden: 是否隐藏,默认为falsecmd: 是否可命令,默认为trueoverflow: 溢出类型,默认为autopos: 位置类型,没有默认值expression: 表达式,默认为空panelBgClr: 面板背景颜色,默认为空panelBgImg: 面板背景图片,默认为空panelBgImgPos: 面板背景图片位置,默认为空panelBgImgRepeat: 面板背景图片重复方式,默认为空panelBgImgAttachment: 面板背景图片附着类型,默认为noneitemClass: 项样式类,默认为空getBindClass: 绑定类数组,默认为空url: URL,默认为空flexSize: 是否弹性大小,默认为falsetransparent: 是否透明,默认为truetitle: 标题,默认为空dock 来规划导航组件的位置cache 以提高性能customMenu 提供快捷操作Layoutannotation 优化导航组件的布局@CustomAnnotation 的 index 属性来控制导航项的显示顺序@ModuleAnnotation 的 dynLoad = trueNavGalleryViewAnnotation:适用于图片画廊式导航场景NavGroupAnnotation:适用于分组式导航布局场景NavMenuBarAnnotation:适用于应用顶部或侧边菜单栏场景NavFoldingTreeAnnotation:适用于可折叠的树形导航场景NavGalleryAnnotation:适用于图片或图标画廊展示场景LayoutAnnotation:适用于需要自定义布局的导航组件@RequestMapping 的路径配置,避免冲突loadChildUrl 或相关URL配置正确@LayoutAnnotation 时,注意布局项的配置顺序和属性本手册涵盖了 OneCode 框架中主要的导航类注解及其子注解 LayoutAnnotation,提供了完整的接口定义、属性说明、枚举类型和使用示例,帮助开发者快速掌握导航组件的配置方式。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。