@ysgroup/ui 0.1.24 → 0.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ysgroup/ui",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
7
7
  "dependencies": {
8
8
  "@element-plus/icons-vue": "^2.3.1",
9
- "@ysgroup/contracts": "0.1.7",
9
+ "@ysgroup/contracts": "0.1.8",
10
10
  "@ysgroup/theme": "^0.1.0"
11
11
  },
12
12
  "peerDependencies": {
@@ -0,0 +1,25 @@
1
+ /** 各业务仓在启动时注册本系统表格列宽;查找只认 table.field,缺键告警并回退 140。 */
2
+
3
+ export type ColumnWidthMap = Record<string, Record<string, number>>;
4
+
5
+ const MISSING_WIDTH = 140;
6
+ let widths: ColumnWidthMap = {};
7
+ const warned = new Set<string>();
8
+
9
+ export function registerColumnWidths(map: ColumnWidthMap): void {
10
+ widths = map;
11
+ warned.clear();
12
+ }
13
+
14
+ export function columnWidth(table: string, field: string): number {
15
+ const width = widths[table]?.[field];
16
+ if (width == null) {
17
+ const key = `${table}.${field}`;
18
+ if (!warned.has(key)) {
19
+ warned.add(key);
20
+ console.warn(`[columnWidths] missing ${key}`);
21
+ }
22
+ return MISSING_WIDTH;
23
+ }
24
+ return width;
25
+ }
@@ -5,6 +5,7 @@
5
5
  import { computed, ref, watch } from "vue";
6
6
  import { FIELD_SPECS, ENUM_META } from "@ysgroup/contracts";
7
7
  import { enumLabel } from "../tokens-runtime";
8
+ import { columnWidth as lookupColumnWidth } from "../columnWidths";
8
9
  import YsFormDialog from "./YsFormDialog.vue";
9
10
  import YsRowActionMenu from "./YsRowActionMenu.vue";
10
11
  import YsTableToolbar from "./YsTableToolbar.vue";
@@ -17,41 +18,6 @@ interface FieldSpec {
17
18
  sensitivity: string;
18
19
  }
19
20
 
20
- const COLUMN_WIDTHS: Record<string, number> = {
21
- enabled: 54,
22
- auto_trade: 72,
23
- cname: 120,
24
- account: 112,
25
- type: 110,
26
- trade_env: 72,
27
- owner_id: 120,
28
- team_id: 120,
29
- broker_id: 120,
30
- bank_card_id: 150,
31
- fee_rate: 76,
32
- commission_refund: 84,
33
- positions_refund: 84,
34
- interest: 72,
35
- traded_br: 72,
36
- traded_xt: 72,
37
- cfmmc_username: 120,
38
- futures_app_id: 120,
39
- futures_auth_code: 130,
40
- name: 140,
41
- full_name: 200,
42
- code: 110,
43
- memo: 180,
44
- phone: 120,
45
- email: 180,
46
- role: 90,
47
- status: 80,
48
- max_sessions: 80,
49
- };
50
-
51
- function columnWidth(field: FieldSpec): number {
52
- return COLUMN_WIDTHS[field.key] ?? (field.widget === "switch" ? 64 : field.widget === "enum" ? 100 : 140);
53
- }
54
-
55
21
  const props = defineProps<{
56
22
  table: string;
57
23
  rows: Record<string, unknown>[];
@@ -81,6 +47,10 @@ const editing = ref<Record<string, unknown> | null>(null);
81
47
  const currentPage = ref(1);
82
48
  const pageSize = ref(20);
83
49
 
50
+ function columnWidth(field: FieldSpec): number {
51
+ return lookupColumnWidth(props.table, field.key);
52
+ }
53
+
84
54
  const allSpecs = computed<FieldSpec[]>(() => (FIELD_SPECS as unknown as Record<string, FieldSpec[]>)[props.table] ?? []);
85
55
 
86
56
  const displayColumns = computed<FieldSpec[]>(() => {
package/src/index.ts CHANGED
@@ -13,3 +13,4 @@ export { default as YsSettingsCenterDialog } from "./components/YsSettingsCenter
13
13
  export { default as YsPortalGrid } from "./components/YsPortalGrid.vue";
14
14
  export { default as YsRoleTag } from "./components/YsRoleTag.vue";
15
15
  export { enumOptions, enumLabel, type EnumOption } from "./tokens-runtime";
16
+ export { registerColumnWidths, columnWidth, type ColumnWidthMap } from "./columnWidths";