Skip to content

refactor(grid): use AI to refactor grid components #3163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 45 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4d61448
fix: 更新组件导入路径和渲染方法参数结构
zzcr Mar 19, 2025
f649f74
refactor: 更新类名映射,简化样式绑定逻辑
zzcr Mar 19, 2025
7b33a4e
feat(grid): 增加行序列和索引的计算逻辑,添加多个新属性以支持滚动加载和虚拟行功能
zzcr Mar 19, 2025
7fd013e
feat(grid): 更新表格实例类型,添加行列索引计算方法及相关属性以支持更灵活的表格操作
zzcr Mar 19, 2025
b040c73
feat(grid): 优化行索引计算逻辑,使用表格实例方法简化行序列和索引的获取
zzcr Mar 20, 2025
93eb58e
fix(grid): 更新表格组件导入路径,修正为Table.vue
zzcr Mar 25, 2025
d8af2fe
feat(grid): 重构表格状态管理,使用ref替代reactive以提升性能和可维护性,同时移除冗余代码
zzcr Mar 27, 2025
2bf0b39
feat(grid): 更新多选工具栏的条件判断,优化表格类名计算逻辑,增强状态管理的灵活性
zzcr Mar 28, 2025
7e2e4a2
feat(grid): 新增Grid组件,包含表格、工具栏、分页器等功能,优化数据管理和状态处理逻辑
zzcr Mar 29, 2025
8f14aef
chore: 给表格添加必要的注释
zzcr Mar 31, 2025
20b65ef
feat(grid): 增强Grid组件功能,添加详细注释,优化插件安装逻辑,改进表格渲染和事件处理,支持更灵活的配置管理
zzcr Mar 31, 2025
3d4e0a9
feat(grid): 增加GridColumn组件,优化列宽度分析逻辑,增强表格数据分组处理,添加详细注释以提升可读性
zzcr Mar 31, 2025
7b9f53b
fix(grid): 更新Column组件导入路径,修正为Column.vue,并优化插槽处理逻辑以提升组件性能
zzcr Mar 31, 2025
2eea214
feat(grid): 增强表格滚动处理逻辑,添加详细注释以提升可读性,优化固定列类名生成和事件触发机制
zzcr Mar 31, 2025
b15b9a7
feat(grid): 增强数据获取逻辑,添加详细注释以提升可读性,优化重新加载和过滤条件处理
zzcr Apr 1, 2025
a18aafd
feat(grid): 表格loading组件转化成模板格式
zzcr Apr 8, 2025
8e81277
fix: sync aui table optimization
gimmyhehe Apr 8, 2025
a124ae4
Merge branch 'refactor-grid-zzc' of github.com:opentiny/tiny-vue into…
gimmyhehe Apr 8, 2025
83e26e6
Merge branch 'dev' of github.com:opentiny/tiny-vue into refactor-grid…
zzcr Apr 8, 2025
9093b41
refactor: 重命名方法以去除前缀,提升代码可读性
zzcr Apr 8, 2025
5fe42fb
feat: 增强表格事件处理模块,添加详细的事件处理函数注释,提升代码可读性和维护性
zzcr Apr 8, 2025
e18f63f
refactor: 移除冗余的函数文件,将 handleAllColumnPromises 函数整合至 utils/handleResol…
zzcr Apr 8, 2025
3542876
feat: 为表格方法添加详细的注释,提升代码可读性和维护性
zzcr Apr 8, 2025
713fca7
feat: 在表格排序方法中实现多字段排序功能,并添加详细注释以提升可读性
zzcr Apr 8, 2025
fb080bc
feat: 更新表格组件,添加 TypeScript 支持,优化排序和编辑方法,增强交叉观察器功能,提升代码可读性和维护性
zzcr Apr 8, 2025
a08e496
feat: 优化表格列配置组装逻辑,添加详细注释以提升可读性,增强插槽和列与表格的关联性
zzcr Apr 15, 2025
589db4e
feat: 优化事件处理逻辑,使用展开运算符提升代码可读性,添加详细注释以增强事件触发的清晰度
zzcr Apr 16, 2025
39481b8
feat: 更新表格组件,优化数据绑定逻辑,添加详细注释以提升可读性,支持 Vue2 和 Vue3 的数据变化监听
zzcr Apr 16, 2025
ec7c126
feat: 更新表格组件,优化渲染逻辑,添加详细注释以提升可读性
zzcr Apr 17, 2025
30575cd
feat: 更新表格组件,添加分页器支持,优化分页逻辑并增强注释以提升可读性
zzcr Apr 17, 2025
571722d
feat: 添加列锚点组件支持,优化表格渲染逻辑,提升代码可读性
zzcr Apr 17, 2025
d46424e
feat: 优化工具栏渲染逻辑,支持配置式和插槽式使用,增强列名处理逻辑以提升可读性
zzcr Apr 17, 2025
b268e58
feat: 更新工具栏组件,优化插槽使用方式,增强注释以提升可读性
zzcr Apr 17, 2025
4ee698c
feat: 优化表格组件,移除不必要的重新计算逻辑,增强代码可读性,添加加载中遮罩支持
zzcr Apr 23, 2025
23dcfe1
feat: 更新自适应列宽处理逻辑,统一参数命名,增强代码可读性
zzcr Apr 23, 2025
1225fc2
feat: 优化表格方法,移除不必要的 Promise 链接,增强代码简洁性
zzcr Apr 25, 2025
7cf9868
feat: 优化表格数据处理逻辑,使用展开运算符替代传统方法,提升代码简洁性和可读性
zzcr Apr 25, 2025
9cd0ff6
feat: 添加异步列插件,优化表格插件集成,增强代码可读性
zzcr Apr 25, 2025
348e44e
feat: 添加单选功能插件,优化复选框方法,增强获取选中数据逻辑
zzcr Apr 26, 2025
d1948d2
feat: 优化单元格和复选框方法,移除冗余代码,增强获取选中数据逻辑
zzcr Apr 26, 2025
bedfa08
feat: 重构代码结构,统一导入路径,移除冗余的许可证注释,提升代码可读性
zzcr Apr 26, 2025
aa19dd4
feat: 添加虚拟滚动插件,优化表格组件,增强滚动加载逻辑,提升代码可读性
zzcr Apr 26, 2025
8f593cb
feat: 将排序事件和相关方法移至独立模块,优化代码结构,提升可读性
zzcr Apr 26, 2025
cf0f8da
feat: 添加展开行插件,优化插件导入逻辑,更新异步列模块的导入路径,提升代码结构和可读性
zzcr Apr 26, 2025
95898e2
feat: 移除冗余许可证注释,优化导入逻辑,提升代码可读性
zzcr Apr 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit
# npx --no-install commitlint --edit
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
# npx lint-staged
24 changes: 23 additions & 1 deletion packages/renderless/src/grid/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,48 @@ export const emitEvent = (vm, type, args) => {
}
}

/**
* 组装列配置,这里很重要,会触发表格collectColumn的watch,从而刷新表格
* @param {Object} $table - 表格实例
* @returns {void}
*/
export const assemColumn = ($table) => {
// 用于存储收集到的所有列配置
const collectColumn = []

/**
* 递归组装列配置
* @param {Array} columnVms - 列虚拟节点数组
* @param {Array} columns - 用于存储组装后的列配置数组
*/
const assem = (columnVms, columns) => {
// 检查columnVms是否为数组
if (Array.isArray(columnVms)) {
// 遍历每个列虚拟节点
columnVms.forEach((columnVm) => {
// 获取列的配置信息
const column = columnVm.columnConfig
// 用于存储子列配置的数组
const children = []

// 如果存在列配置
if (column) {
// 将当前列配置添加到columns数组
columns.push(column)
// 递归处理子列,将结果存储到children数组
assem(columnVm.childColumns, children)
// 兼容旧实现,如果当前列没有子列,children 为 falsy 值
// 设置children属性:
// 1. 如果有子列,则设置为子列数组
// 2. 如果没有子列,则设置为null(兼容旧版本实现)
column.children = children.length > 0 ? children : null
}
})
}
}

// 从表格实例的childColumns开始递归组装列配置
assem($table.childColumns, collectColumn)
// 将组装好的列配置赋值给表格实例的collectColumn属性
$table.collectColumn = collectColumn
}

Expand Down
4 changes: 2 additions & 2 deletions packages/renderless/src/grid/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export const isPx = (val) => val && /^\d+(px)?$/.test(val)

export const isScale = (val) => val && /^\d+%$/.test(val)

export const updateCellTitle = (event) => {
const cellEl = event.currentTarget.querySelector(CELL_CLS)
export const updateCellTitle = (event, td) => {
const cellEl = td ? td.querySelector(CELL_CLS) : event.currentTarget.querySelector(CELL_CLS)
const content = cellEl.innerText

if (cellEl.getAttribute('title') !== content) {
Expand Down
6 changes: 6 additions & 0 deletions packages/theme-saas/src/grid/body.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
@apply border-b border-b-color-bg-3;
@apply overflow-y-auto;
@apply overflow-x-auto;

&.no-data {
@apply overflow-y-hidden;
@apply flex;
@apply flex-col;
}
}

.@{grid-prefix-cls}__borders {
Expand Down
53 changes: 0 additions & 53 deletions packages/theme-saas/src/grid/header.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
@grid-header-prefix-cls: ~'@{css-prefix}grid-header';
@grid-cell-prefix-cls: ~'@{css-prefix}grid-cell';
@grid-checkbox-prefix-cls: ~'@{css-prefix}grid-checkbox';
@header-suffix: ~'@{grid-prefix-cls}-cell__header-suffix';
@cell-tooltip: ~'@{grid-prefix-cls}-cell__tooltip';

.@{grid-prefix-cls}__header-wrapper {
@apply bg-color-fill-8;
Expand Down Expand Up @@ -167,57 +165,6 @@
}
}

.@{grid-prefix-cls}__header {
.@{header-suffix} {
@apply relative;
min-height: 16px;

.suffix-icon-1 {
@apply absolute;
@apply right-3;
}

.suffix-icon-0 {
@apply absolute;
@apply right-0;
}
}

.col__ellipsis {
&.is__editable.is__sortable.is__filter {
.@{header-suffix}.@{cell-tooltip} {
@apply pr-7;
}
}

&.is__editable.is__sortable:not(.is__filter),
&.is__editable.is__filter:not(.is__sortable) {
.@{header-suffix}.@{cell-tooltip} {
@apply ~'pr-3.5';
}
}

&:not(.is__sortable):not(.is__filter) {
.@{header-suffix}.@{cell-tooltip} {
@apply pr-2;
}
}

&.is__sortable.is__filter:not(.is__editable) {
.@{header-suffix}.@{cell-tooltip} {
padding-right: 26px;
}
}

&.is__sortable:not(.is__filter):not(.is__editable),
&.is__filter:not(.is__sortable):not(.is__editable) {
.@{header-suffix}.@{cell-tooltip} {
@apply pr-3;
}
}
}
}

.@{grid-prefix-cls} {
th.col__selection > .@{grid-cell-prefix-cls} {
@apply relative;
Expand Down
122 changes: 88 additions & 34 deletions packages/theme-saas/src/grid/table.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
@input-prefix-cls: ~'@{css-prefix}input';
@select-prefix-cls: ~'@{css-prefix}select';
@pager-prefix-cls: ~'@{css-prefix}pager';
@header-suffix: ~'@{grid-prefix-cls}-cell__header-suffix';
@cell-tooltip: ~'@{grid-prefix-cls}-cell__tooltip';

// table
.@{grid-prefix-cls} {
Expand Down Expand Up @@ -372,7 +374,7 @@
}

&&__group-saas {
.@{grid-prefix-cls}__header {
.@{grid-prefix-cls}__body thead {
@apply relative;

&::before {
Expand Down Expand Up @@ -418,7 +420,7 @@
}

&&__border-vertical {
.@{grid-prefix-cls}__body {
.@{grid-prefix-cls}__body tbody {
@apply relative;

&::before {
Expand Down Expand Up @@ -861,37 +863,12 @@
}

& &__empty-block {
@apply hidden;
@apply opacity-0;
@apply h-full;
@apply ~"min-h-[theme('spacing.16')]";
@apply py-16 px-0;
@apply justify-center;
@apply items-center;
@apply text-center;

&.is__visible {
@apply flex;
@apply flex-col;
@apply opacity-100;
&.is__center {
@apply opacity-0;
}
}
}

.empty-center-block {
@apply ~'z-[1]';
@apply flex;
@apply flex-col;
@apply justify-center;
@apply text-center;
@apply absolute;
@apply w-full;

.@{grid-prefix-cls}__empty-text {
@apply w-full;
}
@apply flex-auto;
@apply items-center;
@apply sticky;
@apply left-0;
}

& &__empty-img {
Expand All @@ -904,8 +881,8 @@

& &__empty-text {
@apply block;
@apply mt-2;
@apply ~'w-1/2';
@apply w-full;
@apply text-center;
}

& &-body__column {
Expand Down Expand Up @@ -1012,12 +989,12 @@
& &__body-wrapper {
&.body__wrapper.is__scrollload {
@apply overflow-y-hidden;
@apply static;
}
}
& .is__scrollload &-body__y-space {
@apply absolute;
@apply right-0;
@apply bottom-0;
@apply w-3;
@apply overflow-y-scroll;

Expand Down Expand Up @@ -1374,4 +1351,81 @@
}
}
}

.@{grid-prefix-cls}__body {
.tiny-grid-header__column {
@apply sticky;
/* --tiny-color-fill-8 真实对应 rgba(31, 85, 181, .05) */
background-color: var(--tiny-color-fill-8-solid, #f4f6fb);
}

.tiny-grid-header__column:last-child {
contain: layout;
}

.tiny-grid-header__column .tiny-grid-thead-partition,
.tiny-grid-header__column .tiny-grid-resizable {
transform: translateX(calc(50% - 1px));
}

.tiny-grid-custom-footer {
@apply w-full;
@apply sticky;
@apply bottom-0;
}

.tiny-grid-footer__column {
@apply sticky;
@apply bg-color-bg-1;
}

.@{header-suffix} {
@apply relative;
min-height: 16px;

.suffix-icon-1 {
@apply absolute;
@apply right-3;
}

.suffix-icon-0 {
@apply absolute;
@apply right-0;
}
}

.col__ellipsis {
&.is__editable.is__sortable.is__filter {
.@{header-suffix}.@{cell-tooltip} {
@apply pr-7;
}
}

&.is__editable.is__sortable:not(.is__filter),
&.is__editable.is__filter:not(.is__sortable) {
.@{header-suffix}.@{cell-tooltip} {
@apply ~'pr-3.5';
}
}

&:not(.is__sortable):not(.is__filter) {
.@{header-suffix}.@{cell-tooltip} {
@apply pr-2;
}
}

&.is__sortable.is__filter:not(.is__editable) {
.@{header-suffix}.@{cell-tooltip} {
padding-right: 26px;
}
}

&.is__sortable:not(.is__filter):not(.is__editable),
&.is__filter:not(.is__sortable):not(.is__editable) {
.@{header-suffix}.@{cell-tooltip} {
@apply pr-3;
}
}
}
}
}
6 changes: 6 additions & 0 deletions packages/theme/src/grid/body.less
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
.@{grid-prefix-cls}__fixed-right-body-wrapper {
overflow-y: auto;
overflow-x: auto;

&.no-data {
overflow-y: hidden;
display: flex;
flex-direction: column;
}
}

// 鼠标配置项开启后,选中单元格的边框样式(position:absolute)
Expand Down
2 changes: 0 additions & 2 deletions packages/theme/src/grid/header.less
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
@grid-header-prefix-cls: ~'@{css-prefix}grid-header';
@grid-cell-prefix-cls: ~'@{css-prefix}grid-cell';
@grid-checkbox-prefix-cls: ~'@{css-prefix}grid-checkbox';
@header-suffix: ~'@{grid-prefix-cls}-cell__header-suffix';
@cell-tooltip: ~'@{grid-prefix-cls}-cell__tooltip';

.@{grid-prefix-cls}__header-wrapper {
background-color: var(--tv-Grid-header-bg-color);
Expand Down
Loading