Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

config-meta.constants.ts 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /**
  2. * 配置元信息相关常量定义
  3. */
  4. // 字段类型枚举
  5. export const FIELD_TYPES = ['string', 'int', 'bool', 'config', 'array'] as const;
  6. export type FieldType = typeof FIELD_TYPES[number];
  7. // 配置名称常量
  8. export const CONFIG_NAMES = ['app', 'database', 'redis', 'logger', 'cache'] as const;
  9. // Tabulator字段映射:前端字段名 -> 后端字段名
  10. export const FIELD_MAPPING: Record<string, string> = {
  11. 'id': 'id',
  12. 'configName': 'configName',
  13. 'fieldName': 'fieldName',
  14. 'fieldType': 'fieldType',
  15. 'yamlName': 'yamlName',
  16. 'fieldDesc': 'fieldDesc',
  17. 'description': 'fieldDesc', // 兼容别名
  18. 'creator': 'creator',
  19. 'createdAt': 'createdAt'
  20. } as const;
  21. // Tabulator操作符映射:Tabulator操作符 -> 后端操作符
  22. export const OPERATOR_MAPPING: Record<string, string> = {
  23. '=': '=',
  24. '!=': '!=',
  25. 'like': 'like',
  26. '>': '>',
  27. '<': '<',
  28. '>=': '>=',
  29. '<=': '<=',
  30. 'in': 'in'
  31. } as const;
  32. // 调试信息默认值
  33. export const DEBUG_INFO_DEFAULTS = {
  34. dataSource: '',
  35. recordCount: 0,
  36. lastUpdated: '',
  37. useMockData: false,
  38. registerUrl: '',
  39. listUrl: '',
  40. currentPage: 1,
  41. totalPages: 1,
  42. pageSize: 100 // 与组件中的paginationPageSize保持一致
  43. } as const;
  44. // Tabulator列配置工厂函数
  45. export function createTabulatorColumns() {
  46. return [
  47. {
  48. title: 'ID',
  49. field: 'id',
  50. width: 120,
  51. sorter: 'string',
  52. headerFilter: true,
  53. headerFilterPlaceholder: '筛选ID...'
  54. },
  55. {
  56. title: '配置名称',
  57. field: 'configName',
  58. width: 150,
  59. sorter: 'string',
  60. headerFilter: true,
  61. headerFilterFunc: 'like',
  62. headerFilterPlaceholder: '筛选配置名称...'
  63. },
  64. {
  65. title: '字段名',
  66. field: 'fieldName',
  67. width: 150,
  68. sorter: 'string',
  69. headerFilter: true,
  70. headerFilterPlaceholder: '筛选字段名...'
  71. },
  72. {
  73. title: '字段类型',
  74. field: 'fieldType',
  75. width: 120,
  76. sorter: 'string',
  77. headerFilter: 'select',
  78. headerFilterParams: {
  79. values: [...FIELD_TYPES],
  80. clearable: true
  81. },
  82. headerFilterPlaceholder: '选择类型...'
  83. },
  84. {
  85. title: 'YAML名称',
  86. field: 'yamlName',
  87. width: 150,
  88. sorter: 'string',
  89. headerFilter: true,
  90. headerFilterFunc: 'like',
  91. headerFilterPlaceholder: '筛选YAML名称...'
  92. },
  93. {
  94. title: '字段描述',
  95. field: 'fieldDesc',
  96. width: 200,
  97. sorter: 'string',
  98. headerFilter: true,
  99. headerFilterPlaceholder: '筛选描述...'
  100. },
  101. {
  102. title: '创建者',
  103. field: 'creator',
  104. width: 120,
  105. sorter: 'string',
  106. headerFilter: true,
  107. headerFilterPlaceholder: '筛选创建者...'
  108. },
  109. {
  110. title: '创建时间',
  111. field: 'createdAt',
  112. width: 180,
  113. sorter: 'date',
  114. headerFilter: true,
  115. headerFilterPlaceholder: 'YYYY-MM-DD...'
  116. }
  117. ];
  118. }