review: 重构代码.

This commit is contained in:
lijiahang
2023-11-24 19:19:05 +08:00
parent a9658b57dd
commit 550366e929
11 changed files with 58 additions and 24 deletions

View File

@@ -27,7 +27,7 @@ public class CodeGenerators {
// 作者 // 作者
String author = Const.ORION_AUTHOR; String author = Const.ORION_AUTHOR;
// 模块 // 模块
String module = "infra"; String module = "asset";
// 生成的表 // 生成的表
Table[] tables = { Table[] tables = {
// Template.create("dict_key", "字典配置项", "dict") // Template.create("dict_key", "字典配置项", "dict")
@@ -45,9 +45,24 @@ public class CodeGenerators {
// .color("blue", "gray", "red", "green", "white") // .color("blue", "gray", "red", "green", "white")
// .valueUseFields() // .valueUseFields()
// .build(), // .build(),
Template.create("data_permission", "数据权限", "data") Template.create("code_snippet", "代码片段", "snippet")
.enableProviderApi()
.disableUnitTest() .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(), .build(),
}; };
// jdbc 配置 - 使用配置文件 // jdbc 配置 - 使用配置文件

View File

@@ -16,6 +16,17 @@ import java.util.Map;
@Data @Data
public class DictMeta { public class DictMeta {
// // $comment
// export const $field = {
// // labels[0]
// fields[0]: 'values[0]',
// // labels[1]
// fields[0]: 'values[1]',
// };
//
// // $comment 字典项
// export const $keyField = '$keyName';
/** /**
* 字典配置名称 * 字典配置名称
*/ */

View File

@@ -42,7 +42,7 @@ VALUES
#set($count = $enumEntity.value.fields.size() - 1) #set($count = $enumEntity.value.fields.size() - 1)
#foreach($index in [0..$count]) #foreach($index in [0..$count])
#set($sort = $index * 10 + 10) #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
#end #end

View File

@@ -41,9 +41,9 @@ public class AppPreferenceModel implements PreferenceModel {
private Integer menuWidth; private Integer menuWidth;
@Schema(description = "表格默认页数") @Schema(description = "表格默认页数")
private Integer defaultPageSize; private Integer defaultTablePageSize;
@Schema(description = "卡片默认页数") @Schema(description = "卡片默认页数")
private Integer defaultCardSize; private Integer defaultCardPageSize;
} }

View File

@@ -23,8 +23,8 @@ public class SystemPreferenceStrategy implements IPreferenceStrategy<AppPreferen
.tabBar(true) .tabBar(true)
.menuWidth(220) .menuWidth(220)
.colorWeak(false) .colorWeak(false)
.defaultPageSize(10) .defaultTablePageSize(10)
.defaultCardSize(12) .defaultCardPageSize(12)
.build(); .build();
} }

View File

@@ -26,8 +26,7 @@
import { useAppStore } from '@/store'; import { useAppStore } from '@/store';
import Block from './block.vue'; import Block from './block.vue';
import useVisible from '@/hooks/visible'; import useVisible from '@/hooks/visible';
import { usePagination as useTablePagination } from '@/types/table'; import { CardPageSizeOptions, TablePageSizeOptions } from '@/types/const';
import { usePagination as useCardPagination } from '@/types/card';
const appStore = useAppStore(); const appStore = useAppStore();
const { visible, setVisible } = useVisible(); const { visible, setVisible } = useVisible();
@@ -82,11 +81,11 @@
const dataOpts = computed(() => [ const dataOpts = computed(() => [
{ {
name: '表格默认页数', name: '表格默认页数',
key: 'defaultPageSize', key: 'defaultTablePageSize',
type: 'select', type: 'select',
margin: '0 0 4px 0', margin: '0 0 4px 0',
defaultVal: appStore.defaultPageSize, defaultVal: appStore.defaultTablePageSize,
options: (useTablePagination().pageSizeOptions || []).map(s => { options: TablePageSizeOptions.map(s => {
return { return {
value: s, value: s,
label: `${s} 条/页` label: `${s} 条/页`
@@ -95,10 +94,10 @@
}, },
{ {
name: '卡片默认页数', name: '卡片默认页数',
key: 'defaultCardSize', key: 'defaultCardPageSize',
type: 'select', type: 'select',
defaultVal: appStore.defaultCardSize, defaultVal: appStore.defaultCardPageSize,
options: (useCardPagination().pageSizeOptions || []).map(s => { options: CardPageSizeOptions.map(s => {
return { return {
value: s, value: s,
label: `${s} 条/页` label: `${s} 条/页`

View File

@@ -1,5 +1,6 @@
import type { AppState } from './types'; import type { AppState } from './types';
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { CardPageSizeOptions, TablePageSizeOptions } from '@/types/const';
const defaultConfig: AppState = { const defaultConfig: AppState = {
// 应用设置 // 应用设置
@@ -16,8 +17,8 @@ const defaultConfig: AppState = {
menuWidth: 220, menuWidth: 220,
colorWeak: false, colorWeak: false,
// 用户偏好-数据设置 // 用户偏好-数据设置
defaultPageSize: 10, defaultTablePageSize: TablePageSizeOptions[0],
defaultCardSize: 12, defaultCardPageSize: CardPageSizeOptions[0],
// 用户偏好-页面视图 // 用户偏好-页面视图
hostView: 'table', hostView: 'table',
hostKeyView: 'table', hostKeyView: 'table',

View File

@@ -36,8 +36,8 @@ export interface UserPreferenceLayout {
* 用户偏好 - 数据设置 * 用户偏好 - 数据设置
*/ */
export interface UserPreferenceData { export interface UserPreferenceData {
defaultPageSize: number; defaultTablePageSize: number;
defaultCardSize: number; defaultCardPageSize: number;
} }
/** /**

View File

@@ -3,6 +3,7 @@ import type { VNodeChild } from 'vue';
import { reactive } from 'vue'; import { reactive } from 'vue';
import { useAppStore } from '@/store'; import { useAppStore } from '@/store';
import { isNumber } from '@/utils/is'; import { isNumber } from '@/utils/is';
import { CardPageSizeOptions } from '@/types/const';
/** /**
* 字段对齐方式 * 字段对齐方式
@@ -110,9 +111,9 @@ export const usePagination = (): PaginationProps => {
return reactive({ return reactive({
total: 0, total: 0,
current: 1, current: 1,
pageSize: isNumber(appStore.defaultCardSize) ? appStore.defaultCardSize : 12, pageSize: isNumber(appStore.defaultCardPageSize) ? appStore.defaultCardPageSize : CardPageSizeOptions[0],
showTotal: true, showTotal: true,
showPageSize: true, showPageSize: true,
pageSizeOptions: [12, 18, 36, 48, 96] pageSizeOptions: CardPageSizeOptions
}); });
}; };

View File

@@ -1,2 +1,8 @@
// 管理员角色编码 // 管理员角色编码
export const AdminRoleCode = 'admin'; export const AdminRoleCode = 'admin';
// 表格视图分页数配置
export const TablePageSizeOptions = [10, 20, 30, 50, 100];
// 卡片视图分页数配置
export const CardPageSizeOptions = [12, 18, 36, 48, 96];

View File

@@ -2,6 +2,7 @@ import type { PaginationProps, TableRowSelection } from '@arco-design/web-vue';
import { reactive } from 'vue'; import { reactive } from 'vue';
import { useAppStore } from '@/store'; import { useAppStore } from '@/store';
import { isNumber } from '@/utils/is'; import { isNumber } from '@/utils/is';
import { TablePageSizeOptions } from '@/types/const';
/** /**
* 创建列表分页 * 创建列表分页
@@ -11,10 +12,10 @@ export const usePagination = (): PaginationProps => {
return reactive({ return reactive({
total: 0, total: 0,
current: 1, current: 1,
pageSize: isNumber(appStore.defaultPageSize) ? appStore.defaultPageSize : 12, pageSize: isNumber(appStore.defaultTablePageSize) ? appStore.defaultTablePageSize : TablePageSizeOptions[0],
showTotal: true, showTotal: true,
showPageSize: true, showPageSize: true,
pageSizeOptions: [10, 20, 30, 50, 100] pageSizeOptions: TablePageSizeOptions
}); });
}; };