verce-vue-test 0.0.70 → 0.0.72

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,6 +1,6 @@
1
1
  {
2
2
  "name": "verce-vue-test",
3
- "version": "0.0.70",
3
+ "version": "0.0.72",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -5,9 +5,12 @@
5
5
  */
6
6
  import {
7
7
  computed,
8
+ onBeforeUnmount,
9
+ onDeactivated,
8
10
  ref,
9
11
  useAttrs,
10
12
  useSlots,
13
+ watch,
11
14
  cloneVNode,
12
15
  Fragment,
13
16
  type VNode,
@@ -51,6 +54,12 @@ const props = withDefaults(
51
54
  layout?: string
52
55
  // 分页尺寸
53
56
  paginationSize?: 'large' | 'default' | 'small'
57
+ // 外部选择重置标识;值变化时清空表格内部及跨页保留的选择
58
+ selectionResetKey?: number
59
+ // 弹窗挂载目标;页面可传入局部容器,避免 KeepAlive 下遮罩残留在 body
60
+ appendTo?: string | HTMLElement
61
+ // 是否启用页面级浮层隔离;默认关闭,确保其他 ElTablePro 的既有行为不变
62
+ isolateOverlays?: boolean
54
63
  }>(),
55
64
  {
56
65
  columnConfig: true,
@@ -61,6 +70,7 @@ const props = withDefaults(
61
70
  pageSizes: () => [10, 20, 50, 100],
62
71
  layout: 'total, sizes, prev, pager, next, jumper',
63
72
  paginationSize: 'default',
73
+ isolateOverlays: false,
64
74
  },
65
75
  )
66
76
 
@@ -88,6 +98,36 @@ const slots = useSlots()
88
98
  */
89
99
  // 列配置弹窗可见性
90
100
  const dialogVisible = ref(false)
101
+ /** ElTable 选择控制器,仅声明当前组件需要调用的方法。 */
102
+ const tableRef = ref<{ clearSelection: () => void } | null>(null)
103
+
104
+ /**
105
+ * 关闭组件内部创建的临时浮层。
106
+ *
107
+ * 列配置弹窗属于 ElTablePro 自己的状态,父业务页面无法直接感知;
108
+ * KeepAlive 只停用组件时必须主动关闭,避免遮罩和焦点陷阱继续留在其他页面上。
109
+ */
110
+ const closeTransientOverlays = () => {
111
+ dialogVisible.value = false
112
+ }
113
+
114
+ defineExpose({
115
+ closeTransientOverlays,
116
+ })
117
+
118
+ onDeactivated(() => {
119
+ if (props.isolateOverlays) closeTransientOverlays()
120
+ })
121
+ onBeforeUnmount(() => {
122
+ if (props.isolateOverlays) closeTransientOverlays()
123
+ })
124
+
125
+ /** 业务操作完成后,在新数据渲染完毕时清空 reserve-selection 保存的勾选。 */
126
+ watch(
127
+ () => props.selectionResetKey,
128
+ () => tableRef.value?.clearSelection(),
129
+ { flush: 'post' },
130
+ )
91
131
 
92
132
  // 列选项类型定义
93
133
  type ColumnOption = {
@@ -351,6 +391,7 @@ initColumns()
351
391
 
352
392
  <!-- 表格主体 -->
353
393
  <el-table
394
+ ref="tableRef"
354
395
  v-bind="attrs"
355
396
  :data="data"
356
397
  :row-key="rowKey"
@@ -378,18 +419,23 @@ initColumns()
378
419
  v-model:current-page="currentPage"
379
420
  v-model:page-size="currentPageSize"
380
421
  :total="total || data.length"
381
- :page-sizes="pageSizes"
382
- :layout="layout"
383
- :size="paginationSize"
384
- background
385
- />
422
+ :page-sizes="pageSizes"
423
+ :layout="layout"
424
+ :size="paginationSize"
425
+ :teleported="!isolateOverlays"
426
+ background
427
+ />
386
428
  </div>
387
429
 
388
430
  <!-- 列配置弹窗 -->
389
431
  <el-dialog
432
+ v-if="!isolateOverlays || dialogVisible"
390
433
  v-model="dialogVisible"
391
434
  title="表格列配置"
392
435
  width="500px"
436
+ :append-to="isolateOverlays ? appendTo : 'body'"
437
+ :destroy-on-close="isolateOverlays"
438
+ :lock-scroll="!isolateOverlays"
393
439
  :close-on-click-modal="false"
394
440
  >
395
441
  <!-- 弹窗提示文字 -->
@@ -14,25 +14,119 @@ import IconEcosystem from './icons/IconEcosystem.vue'
14
14
  import IconSupport from './icons/IconSupport.vue'
15
15
  import IconTooling from './icons/IconTooling.vue'
16
16
 
17
- const globalComponents: Record<string, Component> = {
18
- ElButtonPro,
19
- ElFormDialog,
20
- ElInputThousandth,
21
- ElTablePro,
22
- ElUploadButton,
23
- LoginSuccessNotification,
24
- NumberRange,
25
- WebsiteNoticeTitle,
26
- IconCommunity,
27
- IconDocumentation,
28
- IconEcosystem,
29
- IconSupport,
30
- IconTooling,
17
+ type GlobalComponentDefinition = {
18
+ name: string
19
+ component: Component
20
+ category: '操作组件' | '表单组件' | '数据组件' | '反馈组件' | '展示组件' | '图标组件'
21
+ description: string
22
+ filePath: string
31
23
  }
32
24
 
25
+ const globalComponentDefinitions: GlobalComponentDefinition[] = [
26
+ {
27
+ name: 'ElButtonPro',
28
+ component: ElButtonPro,
29
+ category: '操作组件',
30
+ description: '增强版按钮,提供权限、防抖、节流和操作确认能力。',
31
+ filePath: 'src/components/ElButtonPro.vue',
32
+ },
33
+ {
34
+ name: 'ElFormDialog',
35
+ component: ElFormDialog,
36
+ category: '表单组件',
37
+ description: '通过字段配置快速生成新增或编辑表单弹窗。',
38
+ filePath: 'src/components/ElFormDialog.vue',
39
+ },
40
+ {
41
+ name: 'ElInputThousandth',
42
+ component: ElInputThousandth,
43
+ category: '表单组件',
44
+ description: '支持千分位展示和数字输入格式化的金额输入框。',
45
+ filePath: 'src/components/ElInputThousandth.vue',
46
+ },
47
+ {
48
+ name: 'ElTablePro',
49
+ component: ElTablePro,
50
+ category: '数据组件',
51
+ description: '封装列配置、列持久化和分页能力的增强表格。',
52
+ filePath: 'src/components/ElTablePro.vue',
53
+ },
54
+ {
55
+ name: 'ElUploadButton',
56
+ component: ElUploadButton,
57
+ category: '操作组件',
58
+ description: '以按钮形态封装上传流程、校验和上传状态。',
59
+ filePath: 'src/components/ElUploadButton.vue',
60
+ },
61
+ {
62
+ name: 'LoginSuccessNotification',
63
+ component: LoginSuccessNotification,
64
+ category: '反馈组件',
65
+ description: '展示当前与上次登录信息的登录成功通知内容。',
66
+ filePath: 'src/components/LoginSuccessNotification.vue',
67
+ },
68
+ {
69
+ name: 'NumberRange',
70
+ component: NumberRange,
71
+ category: '表单组件',
72
+ description: '支持数组或双字段绑定、单位换算和区间校验的数字范围输入。',
73
+ filePath: 'src/components/NumberRange.vue',
74
+ },
75
+ {
76
+ name: 'WebsiteNoticeTitle',
77
+ component: WebsiteNoticeTitle,
78
+ category: '展示组件',
79
+ description: '用于页面顶部展示网站公告内容和查看更多入口。',
80
+ filePath: 'src/components/WebsiteNoticeTitle.vue',
81
+ },
82
+ {
83
+ name: 'IconCommunity',
84
+ component: IconCommunity,
85
+ category: '图标组件',
86
+ description: '社区场景图标。',
87
+ filePath: 'src/components/icons/IconCommunity.vue',
88
+ },
89
+ {
90
+ name: 'IconDocumentation',
91
+ component: IconDocumentation,
92
+ category: '图标组件',
93
+ description: '文档场景图标。',
94
+ filePath: 'src/components/icons/IconDocumentation.vue',
95
+ },
96
+ {
97
+ name: 'IconEcosystem',
98
+ component: IconEcosystem,
99
+ category: '图标组件',
100
+ description: '生态场景图标。',
101
+ filePath: 'src/components/icons/IconEcosystem.vue',
102
+ },
103
+ {
104
+ name: 'IconSupport',
105
+ component: IconSupport,
106
+ category: '图标组件',
107
+ description: '支持与服务场景图标。',
108
+ filePath: 'src/components/icons/IconSupport.vue',
109
+ },
110
+ {
111
+ name: 'IconTooling',
112
+ component: IconTooling,
113
+ category: '图标组件',
114
+ description: '工具场景图标。',
115
+ filePath: 'src/components/icons/IconTooling.vue',
116
+ },
117
+ ]
118
+
119
+ /** 组件清单页与全局注册共用同一份数据,避免展示内容与实际注册状态不一致。 */
120
+ export const globalComponentCatalog = globalComponentDefinitions.map((definition) => ({
121
+ name: definition.name,
122
+ category: definition.category,
123
+ description: definition.description,
124
+ filePath: definition.filePath,
125
+ }))
126
+
33
127
  /** 注册 src/components 下的公共组件,页面模板中可直接使用。 */
34
128
  export function registerGlobalComponents(app: App) {
35
- Object.entries(globalComponents).forEach(([name, component]) => {
129
+ globalComponentDefinitions.forEach(({ name, component }) => {
36
130
  app.component(name, component)
37
131
  })
38
132
  }
@@ -35,6 +35,11 @@ const router = createRouter({
35
35
  name: 'form',
36
36
  component: () => import('../views/FormView.vue'),
37
37
  },
38
+ {
39
+ path: '/components',
40
+ name: 'componentCatalog',
41
+ component: () => import('../views/ComponentCatalogView.vue'),
42
+ },
38
43
  {
39
44
  path: '/table-pro',
40
45
  name: 'tablePro',