diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerators.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerators.java index 87f4827f..9487af06 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerators.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/CodeGenerators.java @@ -27,7 +27,7 @@ public class CodeGenerators { // 作者 String author = Const.ORION_AUTHOR; // 模块 - String module = "infra"; + String module = "asset"; // 生成的表 Table[] tables = { // Template.create("dict_key", "字典配置项", "dict") @@ -45,9 +45,24 @@ public class CodeGenerators { // .color("blue", "gray", "red", "green", "white") // .valueUseFields() // .build(), - Template.create("data_permission", "数据权限", "data") - .enableProviderApi() + Template.create("code_snippet", "代码片段", "snippet") .disableUnitTest() + .cache("code:snippet:{}", "代码片段") + .expire(1, TimeUnit.DAYS) + .vue("asset", "snippet") + .enableCardView() + .enableDrawerForm() + .dict("codeSnippetType", "type") + .comment("代码片段类型") + .fields("COMMAND", "TEMPLATE") + .labels("命令", "模板") + .extra("icon", "icon-code-block", "icon-code") + .valueUseFields() + .dict("codeSnippetRender", "prepare_render") + .comment("是否使用脚本渲染") + .fields("UN_RENDER", "RENDER") + .labels("不渲染", "渲染") + .values(0, 1) .build(), }; // jdbc 配置 - 使用配置文件 diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/template/DictMeta.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/template/DictMeta.java index f47a0a0f..dca2a6a4 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/template/DictMeta.java +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/generator/template/DictMeta.java @@ -16,6 +16,17 @@ import java.util.Map; @Data public class DictMeta { + // // $comment + // export const $field = { + // // labels[0] + // fields[0]: 'values[0]', + // // labels[1] + // fields[0]: 'values[1]', + // }; + // + // // $comment 字典项 + // export const $keyField = '$keyName'; + /** * 字典配置名称 */ diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-sql-dict.sql.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-sql-dict.sql.vm index 39f87bee..97811b54 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-sql-dict.sql.vm +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-sql-dict.sql.vm @@ -42,7 +42,7 @@ VALUES #set($count = $enumEntity.value.fields.size() - 1) #foreach($index in [0..$count]) #set($sort = $index * 10 + 10) - (@TMP_KEY_ID, '$enumEntity.value.keyName', '$enumEntity.value.values.get($index)', '$enumEntity.value.labels.get($index)', '$enumEntity.value.extraJson.get($index)', $sort, now(), now(), '1', '1', 0)#if($foreach.hasNext),#else;#end + (@TMP_KEY_ID, '$enumEntity.value.keyName', '$enumEntity.value.values.get($index)', '$enumEntity.value.labels.get($index)', #if($enumEntity.value.extraJson.size() > $index)'$enumEntity.value.extraJson.get($index)'#else'{}'#end, $sort, now(), now(), '1', '1', 0)#if($foreach.hasNext),#else;#end #end #end diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/handler/preference/model/AppPreferenceModel.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/handler/preference/model/AppPreferenceModel.java index 40e63eb4..4d5a4c06 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/handler/preference/model/AppPreferenceModel.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/handler/preference/model/AppPreferenceModel.java @@ -41,9 +41,9 @@ public class AppPreferenceModel implements PreferenceModel { private Integer menuWidth; @Schema(description = "表格默认页数") - private Integer defaultPageSize; + private Integer defaultTablePageSize; @Schema(description = "卡片默认页数") - private Integer defaultCardSize; + private Integer defaultCardPageSize; } diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/handler/preference/strategy/SystemPreferenceStrategy.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/handler/preference/strategy/SystemPreferenceStrategy.java index b526490a..7770466a 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/handler/preference/strategy/SystemPreferenceStrategy.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/handler/preference/strategy/SystemPreferenceStrategy.java @@ -23,8 +23,8 @@ public class SystemPreferenceStrategy implements IPreferenceStrategy [ { name: '表格默认页数', - key: 'defaultPageSize', + key: 'defaultTablePageSize', type: 'select', margin: '0 0 4px 0', - defaultVal: appStore.defaultPageSize, - options: (useTablePagination().pageSizeOptions || []).map(s => { + defaultVal: appStore.defaultTablePageSize, + options: TablePageSizeOptions.map(s => { return { value: s, label: `${s} 条/页` @@ -95,10 +94,10 @@ }, { name: '卡片默认页数', - key: 'defaultCardSize', + key: 'defaultCardPageSize', type: 'select', - defaultVal: appStore.defaultCardSize, - options: (useCardPagination().pageSizeOptions || []).map(s => { + defaultVal: appStore.defaultCardPageSize, + options: CardPageSizeOptions.map(s => { return { value: s, label: `${s} 条/页` diff --git a/orion-ops-ui/src/store/modules/app/index.ts b/orion-ops-ui/src/store/modules/app/index.ts index cb616c9f..74e1518f 100644 --- a/orion-ops-ui/src/store/modules/app/index.ts +++ b/orion-ops-ui/src/store/modules/app/index.ts @@ -1,5 +1,6 @@ import type { AppState } from './types'; import { defineStore } from 'pinia'; +import { CardPageSizeOptions, TablePageSizeOptions } from '@/types/const'; const defaultConfig: AppState = { // 应用设置 @@ -16,8 +17,8 @@ const defaultConfig: AppState = { menuWidth: 220, colorWeak: false, // 用户偏好-数据设置 - defaultPageSize: 10, - defaultCardSize: 12, + defaultTablePageSize: TablePageSizeOptions[0], + defaultCardPageSize: CardPageSizeOptions[0], // 用户偏好-页面视图 hostView: 'table', hostKeyView: 'table', diff --git a/orion-ops-ui/src/store/modules/app/types.ts b/orion-ops-ui/src/store/modules/app/types.ts index 861bc9f9..f628b8cc 100644 --- a/orion-ops-ui/src/store/modules/app/types.ts +++ b/orion-ops-ui/src/store/modules/app/types.ts @@ -36,8 +36,8 @@ export interface UserPreferenceLayout { * 用户偏好 - 数据设置 */ export interface UserPreferenceData { - defaultPageSize: number; - defaultCardSize: number; + defaultTablePageSize: number; + defaultCardPageSize: number; } /** diff --git a/orion-ops-ui/src/types/card.ts b/orion-ops-ui/src/types/card.ts index b359114f..a0840fd3 100644 --- a/orion-ops-ui/src/types/card.ts +++ b/orion-ops-ui/src/types/card.ts @@ -3,6 +3,7 @@ import type { VNodeChild } from 'vue'; import { reactive } from 'vue'; import { useAppStore } from '@/store'; import { isNumber } from '@/utils/is'; +import { CardPageSizeOptions } from '@/types/const'; /** * 字段对齐方式 @@ -110,9 +111,9 @@ export const usePagination = (): PaginationProps => { return reactive({ total: 0, current: 1, - pageSize: isNumber(appStore.defaultCardSize) ? appStore.defaultCardSize : 12, + pageSize: isNumber(appStore.defaultCardPageSize) ? appStore.defaultCardPageSize : CardPageSizeOptions[0], showTotal: true, showPageSize: true, - pageSizeOptions: [12, 18, 36, 48, 96] + pageSizeOptions: CardPageSizeOptions }); }; diff --git a/orion-ops-ui/src/types/const.ts b/orion-ops-ui/src/types/const.ts index 75b97ff1..70c1b84b 100644 --- a/orion-ops-ui/src/types/const.ts +++ b/orion-ops-ui/src/types/const.ts @@ -1,2 +1,8 @@ // 管理员角色编码 export const AdminRoleCode = 'admin'; + +// 表格视图分页数配置 +export const TablePageSizeOptions = [10, 20, 30, 50, 100]; + +// 卡片视图分页数配置 +export const CardPageSizeOptions = [12, 18, 36, 48, 96]; diff --git a/orion-ops-ui/src/types/table.ts b/orion-ops-ui/src/types/table.ts index 1b746c70..f7c006fb 100644 --- a/orion-ops-ui/src/types/table.ts +++ b/orion-ops-ui/src/types/table.ts @@ -2,6 +2,7 @@ import type { PaginationProps, TableRowSelection } from '@arco-design/web-vue'; import { reactive } from 'vue'; import { useAppStore } from '@/store'; import { isNumber } from '@/utils/is'; +import { TablePageSizeOptions } from '@/types/const'; /** * 创建列表分页 @@ -11,10 +12,10 @@ export const usePagination = (): PaginationProps => { return reactive({ total: 0, current: 1, - pageSize: isNumber(appStore.defaultPageSize) ? appStore.defaultPageSize : 12, + pageSize: isNumber(appStore.defaultTablePageSize) ? appStore.defaultTablePageSize : TablePageSizeOptions[0], showTotal: true, showPageSize: true, - pageSizeOptions: [10, 20, 30, 50, 100] + pageSizeOptions: TablePageSizeOptions }); };