Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Simoje丶
vue-vben-admin
提交
9bb75147
V
vue-vben-admin
项目概览
Simoje丶
/
vue-vben-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
9bb75147
编写于
12月 08, 2020
作者:
V
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf: tsx use useExpose
上级
29461a85
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
63 addition
and
55 deletion
+63
-55
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+4
-0
src/components/Container/src/ScrollContainer.vue
src/components/Container/src/ScrollContainer.vue
+10
-6
src/components/Form/src/BasicForm.vue
src/components/Form/src/BasicForm.vue
+1
-11
src/components/Scrollbar/index.ts
src/components/Scrollbar/index.ts
+7
-1
src/components/Scrollbar/src/Scrollbar.tsx
src/components/Scrollbar/src/Scrollbar.tsx
+4
-4
src/components/Scrollbar/src/types.d.ts
src/components/Scrollbar/src/types.d.ts
+4
-0
src/components/Table/src/BasicTable.vue
src/components/Table/src/BasicTable.vue
+4
-1
src/components/Tree/src/BasicTree.tsx
src/components/Tree/src/BasicTree.tsx
+14
-13
src/components/Verify/src/DragVerify.tsx
src/components/Verify/src/DragVerify.tsx
+3
-3
src/components/Verify/src/ImgRotate.tsx
src/components/Verify/src/ImgRotate.tsx
+2
-2
src/hooks/core/useExpose.ts
src/hooks/core/useExpose.ts
+1
-1
src/types/global.d.ts
src/types/global.d.ts
+0
-4
src/views/demo/comp/verify/index.vue
src/views/demo/comp/verify/index.vue
+7
-7
src/views/demo/tree/ActionTree.vue
src/views/demo/tree/ActionTree.vue
+2
-2
未找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
9bb75147
...
...
@@ -13,6 +13,10 @@
-
打包代码拆分(试验)
-
提取上传地址到全局变量,打包可以动态配置
### ✨ Refactor
-
tree 组件 ref 函数调用删除
`$`
### ⚡ Performance Improvements
-
页面切换 loading 逻辑修改。对于已经加载过的页面不管有没有关闭,再次打开不会在显示 loading(已经打开过的页面再次打开速度比较快,可以不需要 loading,同理顶部进度条逻辑也一样),刷新后恢复。
...
...
src/components/Container/src/ScrollContainer.vue
浏览文件 @
9bb75147
...
...
@@ -11,7 +11,7 @@
<
script
lang=
"ts"
>
import
{
defineComponent
,
ref
,
unref
,
nextTick
}
from
'
vue
'
;
import
{
Scrollbar
}
from
'
/@/components/Scrollbar
'
;
import
{
Scrollbar
,
ScrollbarType
}
from
'
/@/components/Scrollbar
'
;
import
{
useScrollTo
}
from
'
/@/hooks/event/useScrollTo
'
;
...
...
@@ -19,15 +19,17 @@
name
:
'
ScrollContainer
'
,
components
:
{
Scrollbar
},
setup
()
{
const
scrollbarRef
=
ref
<
RefInstanceType
<
any
>>
(
null
);
const
scrollbarRef
=
ref
<
Nullable
<
ScrollbarType
>>
(
null
);
function
scrollTo
(
to
:
number
,
duration
=
500
)
{
const
scrollbar
=
unref
(
scrollbarRef
);
if
(
!
scrollbar
)
return
;
nextTick
(()
=>
{
const
wrap
=
unref
(
scrollbar
.
wrap
);
if
(
!
wrap
)
return
;
const
{
start
}
=
useScrollTo
({
el
:
unref
(
scrollbar
.
$
.
wrap
)
,
el
:
wrap
,
to
,
duration
,
});
...
...
@@ -38,7 +40,7 @@
function
getScrollWrap
()
{
const
scrollbar
=
unref
(
scrollbarRef
);
if
(
!
scrollbar
)
return
null
;
return
scrollbar
.
$
.
wrap
;
return
scrollbar
.
wrap
;
}
function
scrollBottom
()
{
...
...
@@ -46,9 +48,11 @@
if
(
!
scrollbar
)
return
;
nextTick
(()
=>
{
const
scrollHeight
=
scrollbar
.
$
.
wrap
.
scrollHeight
as
number
;
const
wrap
=
unref
(
scrollbar
.
wrap
);
if
(
!
wrap
)
return
;
const
scrollHeight
=
wrap
.
scrollHeight
as
number
;
const
{
start
}
=
useScrollTo
({
el
:
unref
(
scrollbar
.
$
.
wrap
)
,
el
:
wrap
,
to
:
scrollHeight
,
});
start
();
...
...
src/components/Form/src/BasicForm.vue
浏览文件 @
9bb75147
...
...
@@ -31,17 +31,7 @@
import
type
{
Ref
,
WatchStopHandle
}
from
'
vue
'
;
import
type
{
ValidateFields
}
from
'
ant-design-vue/lib/form/interface
'
;
import
{
defineComponent
,
reactive
,
ref
,
computed
,
unref
,
toRef
,
onMounted
,
watch
,
toRefs
,
}
from
'
vue
'
;
import
{
defineComponent
,
reactive
,
ref
,
computed
,
unref
,
onMounted
,
watch
,
toRefs
}
from
'
vue
'
;
import
{
Form
,
Row
}
from
'
ant-design-vue
'
;
import
FormItem
from
'
./FormItem
'
;
import
{
basicProps
}
from
'
./props
'
;
...
...
src/components/Scrollbar/index.ts
浏览文件 @
9bb75147
...
...
@@ -2,4 +2,10 @@
* copy from element-ui
*/
export
{
default
as
Scrollbar
}
from
'
./src/Scrollbar
'
;
import
Scrollbar
from
'
./src/Scrollbar
'
;
import
{
withInstall
}
from
'
../util
'
;
withInstall
(
Scrollbar
);
export
{
Scrollbar
};
export
type
{
ScrollbarType
}
from
'
./src/types
'
;
src/components/Scrollbar/src/Scrollbar.tsx
浏览文件 @
9bb75147
...
...
@@ -15,8 +15,9 @@ import {
onBeforeUnmount
,
}
from
'
vue
'
;
import
{
getSlot
}
from
'
/@/utils/helper/tsxHelper
'
;
import
{
tryTsxEmit
}
from
'
/@/utils/helper/vueHelper
'
;
import
'
./index.less
'
;
import
{
useExpose
}
from
'
/@/hooks/core/useExpose
'
;
import
{
ScrollbarType
}
from
'
./types
'
;
export
default
defineComponent
({
name
:
'
Scrollbar
'
,
...
...
@@ -65,10 +66,9 @@ export default defineComponent({
}
onMounted
(()
=>
{
tryTsxEmit
<
any
>
((
instance
)
=>
{
instance
.
wrap
=
unref
(
wrapElRef
);
useExpose
<
ScrollbarType
>
(
{
wrap
:
unref
(
wrapElRef
),
});
const
{
native
,
noresize
}
=
props
;
const
resizeEl
=
unref
(
resizeRef
);
const
warpEl
=
unref
(
wrapElRef
);
...
...
src/components/Scrollbar/src/types.d.ts
浏览文件 @
9bb75147
...
...
@@ -12,3 +12,7 @@ export interface BarMap {
vertical
:
BarMapItem
;
horizontal
:
BarMapItem
;
}
export
interface
ScrollbarType
{
wrap
:
ElRef
;
}
src/components/Table/src/BasicTable.vue
浏览文件 @
9bb75147
...
...
@@ -69,6 +69,7 @@
import
{
basicProps
}
from
'
./props
'
;
import
{
ROW_KEY
}
from
'
./const
'
;
import
'
./style/index.less
'
;
import
{
useExpose
}
from
'
/@/hooks/core/useExpose
'
;
export
default
defineComponent
({
props
:
basicProps
,
components
:
{
Table
,
BasicForm
},
...
...
@@ -309,6 +310,8 @@
wrapRef
,
});
useExpose
<
TableActionType
>
(
tableAction
);
emit
(
'
register
'
,
tableAction
);
return
{
tableElRef
,
...
...
@@ -322,7 +325,7 @@
getRowClassName
,
wrapRef
,
tableAction
,
...
tableAction
,
redoHeight
,
};
},
});
...
...
src/components/Tree/src/BasicTree.tsx
浏览文件 @
9bb75147
...
...
@@ -11,10 +11,10 @@ import { useContextMenu, ContextMenuItem } from '/@/hooks/web/useContextMenu';
import
{
isFunction
}
from
'
/@/utils/is
'
;
import
{
omit
}
from
'
lodash-es
'
;
import
{
extendSlots
}
from
'
/@/utils/helper/tsxHelper
'
;
import
{
tryTsxEmit
}
from
'
/@/utils/helper/vueHelper
'
;
import
{
basicProps
}
from
'
./props
'
;
import
{
useTree
}
from
'
./useTree
'
;
import
{
useExpose
}
from
'
/@/hooks/core/useExpose
'
;
interface
State
{
expandedKeys
:
Keys
;
...
...
@@ -182,20 +182,21 @@ export default defineComponent({
state
.
checkedKeys
=
props
.
checkedKeys
;
});
tryTsxEmit
<
TreeActionType
>
((
currentInstance
)
=>
{
currentInstance
.
setExpandedKeys
=
setExpandedKeys
;
currentInstance
.
getExpandedKeys
=
getExpandedKeys
;
currentInstance
.
setSelectedKeys
=
setSelectedKeys
;
currentInstance
.
getSelectedKeys
=
getSelectedKeys
;
currentInstance
.
setCheckedKeys
=
setCheckedKeys
;
currentInstance
.
getCheckedKeys
=
getCheckedKeys
;
currentInstance
.
insertNodeByKey
=
insertNodeByKey
;
currentInstance
.
deleteNodeByKey
=
deleteNodeByKey
;
currentInstance
.
updateNodeByKey
=
updateNodeByKey
;
currentInstance
.
filterByLevel
=
(
level
:
number
)
=>
{
useExpose
<
TreeActionType
>
(
{
setExpandedKeys
,
getExpandedKeys
,
setSelectedKeys
,
getSelectedKeys
,
setCheckedKeys
,
getCheckedKeys
,
insertNodeByKey
,
deleteNodeByKey
,
updateNodeByKey
,
filterByLevel
:
(
level
:
number
)
=>
{
state
.
expandedKeys
=
filterByLevel
(
level
);
}
;
}
,
});
return
()
=>
{
return
(
<
Tree
{
...
unref
(
getBindValues
)
}
class
=
{
prefixCls
}
>
...
...
src/components/Verify/src/DragVerify.tsx
浏览文件 @
9bb75147
...
...
@@ -5,8 +5,8 @@ import { basicProps } from './props';
import
{
getSlot
}
from
'
/@/utils/helper/tsxHelper
'
;
import
'
./DragVerify.less
'
;
import
{
CheckOutlined
,
DoubleRightOutlined
}
from
'
@ant-design/icons-vue
'
;
import
{
tryTsxEmit
}
from
'
/@/utils/helper/vueHelper
'
;
import
type
{
DragVerifyActionType
}
from
'
./types
'
;
import
{
useExpose
}
from
'
/@/hooks/core/useExpose
'
;
export
default
defineComponent
({
name
:
'
BaseDargVerify
'
,
props
:
basicProps
,
...
...
@@ -211,8 +211,8 @@ export default defineComponent({
contentEl
.
style
.
width
=
unref
(
getContentStyleRef
).
width
;
}
tryTsxEmit
<
DragVerifyActionType
>
((
instance
)
=>
{
instance
.
resume
=
resume
;
useExpose
<
DragVerifyActionType
>
(
{
resume
,
});
return
()
=>
{
...
...
src/components/Verify/src/ImgRotate.tsx
浏览文件 @
9bb75147
...
...
@@ -18,7 +18,7 @@ export default defineComponent({
props
:
rotateProps
,
emits
:
[
'
success
'
,
'
change
'
,
'
update:value
'
],
setup
(
props
,
{
emit
,
attrs
})
{
const
basicRef
=
ref
<
RefInstanceTyp
e
<
DragVerifyActionType
>>
(
null
);
const
basicRef
=
ref
<
Nullabl
e
<
DragVerifyActionType
>>
(
null
);
const
state
=
reactive
({
showTip
:
false
,
isPassing
:
false
,
...
...
@@ -113,7 +113,7 @@ export default defineComponent({
}
state
.
isPassing
=
false
;
basicEl
.
$
.
resume
();
basicEl
.
resume
();
handleImgOnLoad
();
}
...
...
src/hooks/core/useExpose.ts
浏览文件 @
9bb75147
import
{
getCurrentInstance
}
from
'
vue
'
;
// expose public api
export
function
useExpose
(
apis
:
Record
<
string
,
any
>
)
{
export
function
useExpose
<
T
>
(
apis
:
T
)
{
const
instance
=
getCurrentInstance
();
if
(
instance
)
{
Object
.
assign
(
instance
.
proxy
,
apis
);
...
...
src/types/global.d.ts
浏览文件 @
9bb75147
...
...
@@ -19,10 +19,6 @@ declare type Dictionary<T> = Record<string, T>;
declare
type
Nullable
<
T
>
=
T
|
null
;
declare
type
RefInstanceType
<
T
>
=
{
$
:
T
;
}
|
null
;
declare
type
RefType
<
T
>
=
T
|
null
;
declare
type
CustomizedHTMLElement
<
T
>
=
HTMLElement
&
T
;
...
...
src/views/demo/comp/verify/index.vue
浏览文件 @
9bb75147
...
...
@@ -59,22 +59,22 @@
components
:
{
BasicDragVerify
,
BugOutlined
,
RightOutlined
},
setup
()
{
const
{
createMessage
}
=
useMessage
();
const
el1
=
ref
<
RefInstanceTyp
e
<
DragVerifyActionType
>>
(
null
);
const
el2
=
ref
<
RefInstanceTyp
e
<
DragVerifyActionType
>>
(
null
);
const
el3
=
ref
<
RefInstanceTyp
e
<
DragVerifyActionType
>>
(
null
);
const
el4
=
ref
<
RefInstanceTyp
e
<
DragVerifyActionType
>>
(
null
);
const
el5
=
ref
<
RefInstanceTyp
e
<
DragVerifyActionType
>>
(
null
);
const
el1
=
ref
<
Nullabl
e
<
DragVerifyActionType
>>
(
null
);
const
el2
=
ref
<
Nullabl
e
<
DragVerifyActionType
>>
(
null
);
const
el3
=
ref
<
Nullabl
e
<
DragVerifyActionType
>>
(
null
);
const
el4
=
ref
<
Nullabl
e
<
DragVerifyActionType
>>
(
null
);
const
el5
=
ref
<
Nullabl
e
<
DragVerifyActionType
>>
(
null
);
function
handleSuccess
(
data
:
PassingData
)
{
const
{
time
}
=
data
;
createMessage
.
success
(
`校验成功,耗时
${
time
}
秒`
);
}
function
handleBtnClick
(
elRef
:
RefInstanceTyp
e
<
DragVerifyActionType
>
)
{
function
handleBtnClick
(
elRef
:
Nullabl
e
<
DragVerifyActionType
>
)
{
if
(
!
elRef
)
{
return
;
}
elRef
.
$
.
resume
();
elRef
.
resume
();
}
return
{
handleSuccess
,
...
...
src/views/demo/tree/ActionTree.vue
浏览文件 @
9bb75147
...
...
@@ -32,14 +32,14 @@
export
default
defineComponent
({
components
:
{
BasicTree
,
CollapseContainer
},
setup
()
{
const
treeRef
=
ref
<
RefInstanceTyp
e
<
TreeActionType
>>
(
null
);
const
treeRef
=
ref
<
Nullabl
e
<
TreeActionType
>>
(
null
);
const
{
createMessage
}
=
useMessage
();
function
getTree
()
{
const
tree
=
unref
(
treeRef
);
if
(
!
tree
)
{
throw
new
Error
(
'
tree is null!
'
);
}
return
tree
.
$
;
return
tree
;
}
function
handleLevel
(
level
:
number
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录