Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zuiqiangwanggong
vue-vben-admin
提交
9abf1763
V
vue-vben-admin
项目概览
zuiqiangwanggong
/
vue-vben-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-vben-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9abf1763
编写于
10月 30, 2020
作者:
V
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf(modal): optimize table embedding height calculation problem
上级
84c9d78f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
52 addition
and
34 deletion
+52
-34
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+5
-0
src/components/Modal/src/BasicModal.tsx
src/components/Modal/src/BasicModal.tsx
+3
-3
src/components/Modal/src/ModalWrapper.tsx
src/components/Modal/src/ModalWrapper.tsx
+19
-16
src/components/Modal/src/provideModal.ts
src/components/Modal/src/provideModal.ts
+11
-0
src/components/Table/src/hooks/useTableScroll.ts
src/components/Table/src/hooks/useTableScroll.ts
+14
-15
未找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
9abf1763
...
@@ -12,6 +12,11 @@
...
@@ -12,6 +12,11 @@
-
表单代码优化重构
-
表单代码优化重构
### ⚡ Performance Improvements
-
Modal slot 可以覆盖
-
优化表格嵌入高度计算问题
### 🎫 Chores
### 🎫 Chores
-
添加部分注释
-
添加部分注释
...
...
src/components/Modal/src/BasicModal.tsx
浏览文件 @
9abf1763
...
@@ -225,11 +225,11 @@ export default defineComponent({
...
@@ -225,11 +225,11 @@ export default defineComponent({
{
...{
...
attrs
,
...
props
,
...
unref
(
getProps
)
}
}
{
...{
...
attrs
,
...
props
,
...
unref
(
getProps
)
}
}
>
>
{
{
{
{
...
extendSlots
(
slots
,
[
'
default
'
]),
default
:
()
=>
renderContent
(),
closeIcon
:
()
=>
renderClose
(),
footer
:
()
=>
renderFooter
(),
footer
:
()
=>
renderFooter
(),
closeIcon
:
()
=>
renderClose
(),
title
:
()
=>
renderTitle
(),
title
:
()
=>
renderTitle
(),
...
extendSlots
(
slots
,
[
'
default
'
]),
default
:
()
=>
renderContent
(),
}
}
}
}
</
Modal
>
</
Modal
>
);
);
...
...
src/components/Modal/src/ModalWrapper.tsx
浏览文件 @
9abf1763
...
@@ -15,10 +15,12 @@ import {
...
@@ -15,10 +15,12 @@ import {
import
{
Spin
}
from
'
ant-design-vue
'
;
import
{
Spin
}
from
'
ant-design-vue
'
;
import
{
useWindowSizeFn
}
from
'
/@/hooks/event/useWindowSize
'
;
import
{
useWindowSizeFn
}
from
'
/@/hooks/event/useWindowSize
'
;
import
{
useTimeout
}
from
'
/@/hooks/core/useTimeout
'
;
//
import { useTimeout } from '/@/hooks/core/useTimeout';
import
{
getSlot
}
from
'
/@/utils/helper/tsxHelper
'
;
import
{
getSlot
}
from
'
/@/utils/helper/tsxHelper
'
;
import
{
useElResize
}
from
'
/@/hooks/event/useElResize
'
;
import
{
useElResize
}
from
'
/@/hooks/event/useElResize
'
;
import
{
provideModal
}
from
'
./provideModal
'
;
export
default
defineComponent
({
export
default
defineComponent
({
name
:
'
ModalWrapper
'
,
name
:
'
ModalWrapper
'
,
props
:
{
props
:
{
...
@@ -56,6 +58,11 @@ export default defineComponent({
...
@@ -56,6 +58,11 @@ export default defineComponent({
const
wrapperRef
=
ref
<
HTMLElement
|
null
>
(
null
);
const
wrapperRef
=
ref
<
HTMLElement
|
null
>
(
null
);
const
spinRef
=
ref
<
any
>
(
null
);
const
spinRef
=
ref
<
any
>
(
null
);
const
realHeightRef
=
ref
(
0
);
const
realHeightRef
=
ref
(
0
);
// 重试次数
// let tryCount = 0;
let
stopElResizeFn
:
Fn
=
()
=>
{};
provideModal
(
setModalHeight
);
const
wrapStyle
=
computed
(()
=>
{
const
wrapStyle
=
computed
(()
=>
{
return
{
return
{
...
@@ -65,10 +72,6 @@ export default defineComponent({
...
@@ -65,10 +72,6 @@ export default defineComponent({
};
};
});
});
// 重试次数
let
tryCount
=
0
;
let
stopElResizeFn
:
Fn
=
()
=>
{};
watchEffect
(()
=>
{
watchEffect
(()
=>
{
setModalHeight
();
setModalHeight
();
});
});
...
@@ -123,17 +126,17 @@ export default defineComponent({
...
@@ -123,17 +126,17 @@ export default defineComponent({
}
}
await
nextTick
();
await
nextTick
();
const
spinEl
=
unref
(
spinRef
);
const
spinEl
=
unref
(
spinRef
);
if
(
!
spinEl
)
{
//
if (!spinEl) {
useTimeout
(()
=>
{
//
useTimeout(() => {
// retry
//
// retry
if
(
tryCount
<
3
)
{
//
if (tryCount < 3) {
setModalHeight
();
//
setModalHeight();
}
//
}
tryCount
++
;
//
tryCount++;
},
10
);
//
}, 10);
return
;
//
return;
}
//
}
tryCount
=
0
;
//
tryCount = 0;
const
spinContainerEl
=
spinEl
.
$el
.
querySelector
(
'
.ant-spin-container
'
)
as
HTMLElement
;
const
spinContainerEl
=
spinEl
.
$el
.
querySelector
(
'
.ant-spin-container
'
)
as
HTMLElement
;
if
(
!
spinContainerEl
)
return
;
if
(
!
spinContainerEl
)
return
;
...
...
src/components/Modal/src/provideModal.ts
0 → 100644
浏览文件 @
9abf1763
import
{
provide
,
inject
}
from
'
vue
'
;
const
key
=
Symbol
(
'
basic-modal
'
);
export
function
provideModal
(
redoHeight
:
Fn
)
{
provide
(
key
,
redoHeight
);
}
export
function
injectModal
():
Fn
{
return
inject
(
key
)
as
Fn
;
}
src/components/Table/src/hooks/useTableScroll.ts
浏览文件 @
9abf1763
...
@@ -6,47 +6,44 @@ import { isBoolean } from '/@/utils/is';
...
@@ -6,47 +6,44 @@ import { isBoolean } from '/@/utils/is';
import
{
useTimeout
}
from
'
/@/hooks/core/useTimeout
'
;
import
{
useTimeout
}
from
'
/@/hooks/core/useTimeout
'
;
import
{
useWindowSizeFn
}
from
'
/@/hooks/event/useWindowSize
'
;
import
{
useWindowSizeFn
}
from
'
/@/hooks/event/useWindowSize
'
;
import
{
useProps
}
from
'
./useProps
'
;
import
{
useProps
}
from
'
./useProps
'
;
import
{
injectModal
}
from
'
/@/components/Modal/src/provideModal
'
;
export
function
useTableScroll
(
refProps
:
ComputedRef
<
BasicTableProps
>
,
tableElRef
:
Ref
<
any
>
)
{
export
function
useTableScroll
(
refProps
:
ComputedRef
<
BasicTableProps
>
,
tableElRef
:
Ref
<
any
>
)
{
const
{
propsRef
}
=
useProps
(
refProps
);
const
{
propsRef
}
=
useProps
(
refProps
);
const
tableHeightRef
:
Ref
<
number
|
null
>
=
ref
(
null
);
const
tableHeightRef
:
Ref
<
number
|
null
>
=
ref
(
null
);
const
redoModalHeight
=
injectModal
();
watch
(
watch
(
()
=>
unref
(
propsRef
).
canResize
,
()
=>
unref
(
propsRef
).
canResize
,
()
=>
{
()
=>
{
redoHeight
();
redoHeight
();
}
}
);
);
function
redoHeight
()
{
function
redoHeight
()
{
const
{
canResize
}
=
unref
(
propsRef
);
const
{
canResize
}
=
unref
(
propsRef
);
if
(
!
canResize
)
{
if
(
!
canResize
)
return
;
return
;
}
calcTableHeight
();
calcTableHeight
();
}
}
async
function
calcTableHeight
(
cb
?:
()
=>
void
)
{
async
function
calcTableHeight
(
cb
?:
()
=>
void
)
{
const
{
canResize
,
resizeHeightOffset
,
pagination
,
maxHeight
}
=
unref
(
propsRef
);
const
{
canResize
,
resizeHeightOffset
,
pagination
,
maxHeight
}
=
unref
(
propsRef
);
if
(
!
canResize
)
{
if
(
!
canResize
)
return
;
return
;
}
await
nextTick
();
await
nextTick
();
const
table
=
unref
(
tableElRef
)
as
any
;
const
table
=
unref
(
tableElRef
)
as
any
;
if
(
!
table
)
return
;
if
(
!
table
)
{
return
;
}
const
tableEl
:
Element
=
table
.
$el
;
const
tableEl
:
Element
=
table
.
$el
;
if
(
!
tableEl
)
{
if
(
!
tableEl
)
return
;
return
;
}
const
el
:
HTMLElement
|
null
=
tableEl
.
querySelector
(
'
.ant-table-thead
'
);
const
el
:
HTMLElement
|
null
=
tableEl
.
querySelector
(
'
.ant-table-thead
'
);
// const layoutMain: Element | null = document.querySelector('.default-layout__main ');
// const layoutMain: Element | null = document.querySelector('.default-layout__main ');
if
(
!
el
)
{
if
(
!
el
)
return
;
return
;
}
// 表格距离底部高度
// 表格距离底部高度
const
{
bottomIncludeBody
}
=
getViewportOffset
(
el
);
const
{
bottomIncludeBody
}
=
getViewportOffset
(
el
);
// 表格高度+距离底部高度-自定义偏移量
// 表格高度+距离底部高度-自定义偏移量
...
@@ -89,6 +86,8 @@ export function useTableScroll(refProps: ComputedRef<BasicTableProps>, tableElRe
...
@@ -89,6 +86,8 @@ export function useTableScroll(refProps: ComputedRef<BasicTableProps>, tableElRe
tableHeightRef
.
value
=
tableHeightRef
.
value
=
tableHeightRef
.
value
!
>
maxHeight
!
?
(
maxHeight
as
number
)
:
tableHeightRef
.
value
;
tableHeightRef
.
value
!
>
maxHeight
!
?
(
maxHeight
as
number
)
:
tableHeightRef
.
value
;
cb
&&
cb
();
cb
&&
cb
();
// 解决表格放modal内的时候,modal自适应高度计算问题
redoModalHeight
&&
redoModalHeight
();
},
0
);
},
0
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录