Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
company_app
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
毛细亚
company_app
Commits
188e64a2
提交
188e64a2
authored
6月 26, 2025
作者:
毛细亚
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'release' into 6.2
上级
01e2d8f6
d407787c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
39 行增加
和
18 行删除
+39
-18
works.js
src/api/works.js
+1
-2
scroll.js
src/directive/scroll/scroll.js
+38
-16
没有找到文件。
src/api/works.js
浏览文件 @
188e64a2
...
@@ -258,4 +258,4 @@ export function shareInfoDel(data) {
...
@@ -258,4 +258,4 @@ export function shareInfoDel(data) {
method
:
'post'
,
method
:
'post'
,
data
data
})
})
}
}
\ No newline at end of file
src/directive/scroll/scroll.js
浏览文件 @
188e64a2
...
@@ -32,15 +32,21 @@ const InfiniteScroll = {
...
@@ -32,15 +32,21 @@ const InfiniteScroll = {
},
},
unbind
(
el
)
{
unbind
(
el
)
{
// 解绑事件
// 解绑事件
- 添加安全检查
if
(
el
.
__infinite_scroll_container
&&
el
.
__infinite_scroll_handler
)
{
if
(
el
.
__infinite_scroll_container
&&
el
.
__infinite_scroll_handler
)
{
unbindEvents
(
el
,
el
.
__infinite_scroll_container
,
el
.
__infinite_scroll_handler
);
unbindEvents
(
el
,
el
.
__infinite_scroll_container
,
el
.
__infinite_scroll_handler
);
}
}
// 清理引用
// 清理引用 - 确保安全清理
delete
el
.
__infinite_scroll_container
;
if
(
el
.
__infinite_scroll_container
)
{
delete
el
.
__infinite_scroll_handler
;
delete
el
.
__infinite_scroll_container
;
delete
el
.
__infinite_scroll_options
;
}
if
(
el
.
__infinite_scroll_handler
)
{
delete
el
.
__infinite_scroll_handler
;
}
if
(
el
.
__infinite_scroll_options
)
{
delete
el
.
__infinite_scroll_options
;
}
}
}
};
};
...
@@ -61,15 +67,21 @@ function createScrollHandler(el, binding, vnode) {
...
@@ -61,15 +67,21 @@ function createScrollHandler(el, binding, vnode) {
return
function
()
{
return
function
()
{
const
options
=
el
.
__infinite_scroll_options
;
const
options
=
el
.
__infinite_scroll_options
;
// 添加完整的安全检查 - 确保 options 存在
if
(
!
options
)
return
;
// 检查是否禁用
// 检查是否禁用
if
(
options
&&
options
.
disabled
)
return
;
if
(
options
.
disabled
)
return
;
if
(
el
&&
el
.
__infinite_scroll_container
){
const
scrollContainer
=
el
.
__infinite_scroll_container
;
const
scrollContainer
=
el
.
__infinite_scroll_container
;
const
isBottom
=
isScrollBottom
(
scrollContainer
,
el
,
options
.
distance
);
// 确保滚动容器存在
if
(
isBottom
)
{
if
(
!
scrollContainer
)
return
;
// 调用加载函数
options
.
loadMore
();
const
isBottom
=
isScrollBottom
(
scrollContainer
,
el
,
options
.
distance
||
30
);
}
if
(
isBottom
&&
typeof
options
.
loadMore
===
'function'
)
{
// 调用加载函数
options
.
loadMore
();
}
}
};
};
...
@@ -116,18 +128,28 @@ function getScrollContainer(el) {
...
@@ -116,18 +128,28 @@ function getScrollContainer(el) {
// 判断是否滚动到底部
// 判断是否滚动到底部
function
isScrollBottom
(
scrollContainer
,
el
,
distance
=
30
)
{
function
isScrollBottom
(
scrollContainer
,
el
,
distance
=
30
)
{
// 添加安全检查
if
(
!
scrollContainer
||
!
el
)
return
false
;
// 确保 distance 是数字
const
safeDistance
=
typeof
distance
===
'number'
?
distance
:
30
;
// window情况
// window情况
if
(
scrollContainer
===
window
)
{
if
(
scrollContainer
===
window
)
{
return
(
return
(
Math
.
ceil
(
window
.
innerHeight
+
window
.
pageYOffset
)
>=
Math
.
ceil
(
window
.
innerHeight
+
window
.
pageYOffset
)
>=
document
.
documentElement
.
scrollHeight
-
d
istance
document
.
documentElement
.
scrollHeight
-
safeD
istance
);
);
}
}
// DOM元素情况
// DOM元素情况 - 添加安全检查
if
(
!
scrollContainer
.
scrollTop
&&
scrollContainer
.
scrollTop
!==
0
)
return
false
;
if
(
!
scrollContainer
.
clientHeight
)
return
false
;
if
(
!
scrollContainer
.
scrollHeight
)
return
false
;
return
(
return
(
Math
.
ceil
(
scrollContainer
.
scrollTop
+
scrollContainer
.
clientHeight
)
>=
Math
.
ceil
(
scrollContainer
.
scrollTop
+
scrollContainer
.
clientHeight
)
>=
scrollContainer
.
scrollHeight
-
d
istance
scrollContainer
.
scrollHeight
-
safeD
istance
);
);
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论