Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
frontend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Schedules
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
h5-communicate
frontend
Commits
55024ab6
Commit
55024ab6
authored
Jun 10, 2020
by
熊成伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug
parent
080d5058
Pipeline
#15231
passed with stages
in 58 seconds
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
12 deletions
+53
-12
workspace.xml
.idea/workspace.xml
+0
-0
Backlog.jsx
src/pages/Backlog/Backlog.jsx
+8
-5
Notice.jsx
src/pages/Notice/Notice.jsx
+4
-3
WorkDetail.jsx
src/pages/Work/WorkDetail.jsx
+5
-4
useDebounce.js
src/useHooks/useDebounce.js
+18
-0
useThrottle.js
src/useHooks/useThrottle.js
+18
-0
No files found.
.idea/workspace.xml
View file @
55024ab6
This diff is collapsed.
Click to expand it.
src/pages/Backlog/Backlog.jsx
View file @
55024ab6
...
@@ -5,6 +5,7 @@ import TopSearch from '../../components/TopSearch';
...
@@ -5,6 +5,7 @@ import TopSearch from '../../components/TopSearch';
import
axiosRequest
from
'../../utils/request'
;
import
axiosRequest
from
'../../utils/request'
;
import
Document
from
'react-document-title'
import
Document
from
'react-document-title'
import
Empty
from
'../Empty'
import
Empty
from
'../Empty'
import
useDebounce
from
'../../useHooks/useDebounce'
const
Backlog
=
(
props
)
=>
{
const
Backlog
=
(
props
)
=>
{
const
[
current
,
setCurrent
]
=
useState
(
0
);
const
[
current
,
setCurrent
]
=
useState
(
0
);
...
@@ -27,15 +28,15 @@ const Backlog = (props) => {
...
@@ -27,15 +28,15 @@ const Backlog = (props) => {
}).
then
(
res
=>
{
}).
then
(
res
=>
{
setLoading
(
false
);
setLoading
(
false
);
let
result
=
end
&&
res
.
rows
?
data
.
concat
(
res
.
rows
)
:
data
;
let
result
=
end
&&
res
.
rows
?
data
.
concat
(
res
.
rows
)
:
data
;
res
.
rows
&&
res
.
rows
.
length
>=
10
?
setCurrent
(
current
+
1
)
:
Toast
.
info
(
'
已经到达底部
'
,
1
);
res
.
rows
&&
res
.
rows
.
length
>=
10
?
setCurrent
(
current
+
1
)
:
Toast
.
info
(
'
当前是最后一页
'
,
1
);
setEnd
(
res
.
rows
&&
res
.
rows
.
length
>=
10
)
setEnd
(
res
.
rows
&&
res
.
rows
.
length
>=
10
)
setData
(
result
);
setData
(
result
);
});
});
};
};
//下拉加载
//下拉加载
const
[
end
,
setEnd
]
=
useState
(
true
)
const
[
end
,
setEnd
]
=
useState
(
true
)
;
const
handleScroll
=
()
=>
{
const
handleScroll
=
useDebounce
(
()
=>
{
const
event
=
document
.
getElementById
(
"common-content"
)
const
event
=
document
.
getElementById
(
"common-content"
)
const
top
=
event
.
scrollTop
;
const
top
=
event
.
scrollTop
;
const
scrollHeight
=
event
.
scrollHeight
;
const
scrollHeight
=
event
.
scrollHeight
;
...
@@ -43,7 +44,7 @@ const Backlog = (props) => {
...
@@ -43,7 +44,7 @@ const Backlog = (props) => {
if
(
top
+
clientHeight
===
scrollHeight
)
{
if
(
top
+
clientHeight
===
scrollHeight
)
{
getData
()
getData
()
}
}
}
;
}
,
500
)
useEffect
(()
=>
{
useEffect
(()
=>
{
window
.
addEventListener
(
'scroll'
,
handleScroll
,
true
);
window
.
addEventListener
(
'scroll'
,
handleScroll
,
true
);
return
()
=>
window
.
removeEventListener
(
'scroll'
,
handleScroll
,
true
);
return
()
=>
window
.
removeEventListener
(
'scroll'
,
handleScroll
,
true
);
...
@@ -61,7 +62,9 @@ const Backlog = (props) => {
...
@@ -61,7 +62,9 @@ const Backlog = (props) => {
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
getData
()
getData
()
},
[
searchWord
])
},
[
searchWord
]);
console
.
log
(
current
)
return
(
return
(
<
Document
title=
"待办"
>
<
Document
title=
"待办"
>
<
WingBlank
>
<
WingBlank
>
...
...
src/pages/Notice/Notice.jsx
View file @
55024ab6
...
@@ -5,6 +5,7 @@ import TopNotice from '../../components/NoticeTab'
...
@@ -5,6 +5,7 @@ import TopNotice from '../../components/NoticeTab'
import
axiosRequest
from
'../../utils/request'
;
import
axiosRequest
from
'../../utils/request'
;
import
Document
from
'react-document-title'
import
Document
from
'react-document-title'
import
Empty
from
'../Empty'
import
Empty
from
'../Empty'
import
useDebounce
from
'../../useHooks/useDebounce'
const
Notice
=
(
props
)
=>
{
const
Notice
=
(
props
)
=>
{
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
...
@@ -22,7 +23,7 @@ const Notice = (props) => {
...
@@ -22,7 +23,7 @@ const Notice = (props) => {
}).
then
(
res
=>
{
}).
then
(
res
=>
{
setLoading
(
false
);
setLoading
(
false
);
let
result
=
end
&&
res
.
rows
?
data
.
concat
(
res
.
rows
)
:
data
;
let
result
=
end
&&
res
.
rows
?
data
.
concat
(
res
.
rows
)
:
data
;
res
.
rows
&&
res
.
rows
.
length
>=
10
?
setCurrent
(
current
+
1
)
:
Toast
.
info
(
'
已经到达底部
'
,
1
);
res
.
rows
&&
res
.
rows
.
length
>=
10
?
setCurrent
(
current
+
1
)
:
Toast
.
info
(
'
当前是最后一页
'
,
1
);
setEnd
(
res
.
rows
&&
res
.
rows
.
length
>=
10
)
setEnd
(
res
.
rows
&&
res
.
rows
.
length
>=
10
)
setData
(
result
);
setData
(
result
);
});
});
...
@@ -30,7 +31,7 @@ const Notice = (props) => {
...
@@ -30,7 +31,7 @@ const Notice = (props) => {
//下拉加载
//下拉加载
const
[
end
,
setEnd
]
=
useState
(
true
)
const
[
end
,
setEnd
]
=
useState
(
true
)
const
handleScroll
=
()
=>
{
const
handleScroll
=
useDebounce
(
()
=>
{
const
event
=
document
.
getElementById
(
"common-content"
)
const
event
=
document
.
getElementById
(
"common-content"
)
const
top
=
event
.
scrollTop
;
const
top
=
event
.
scrollTop
;
const
scrollHeight
=
event
.
scrollHeight
;
const
scrollHeight
=
event
.
scrollHeight
;
...
@@ -38,7 +39,7 @@ const Notice = (props) => {
...
@@ -38,7 +39,7 @@ const Notice = (props) => {
if
(
top
+
clientHeight
===
scrollHeight
)
{
if
(
top
+
clientHeight
===
scrollHeight
)
{
getData
()
getData
()
}
}
}
;
}
,
500
)
useEffect
(()
=>
{
useEffect
(()
=>
{
window
.
addEventListener
(
'scroll'
,
handleScroll
,
true
);
window
.
addEventListener
(
'scroll'
,
handleScroll
,
true
);
return
()
=>
window
.
removeEventListener
(
'scroll'
,
handleScroll
,
true
);
return
()
=>
window
.
removeEventListener
(
'scroll'
,
handleScroll
,
true
);
...
...
src/pages/Work/WorkDetail.jsx
View file @
55024ab6
...
@@ -5,6 +5,7 @@ import TopNotice from '../../components/NoticeTab'
...
@@ -5,6 +5,7 @@ import TopNotice from '../../components/NoticeTab'
import
axiosRequest
from
'../../utils/request'
;
import
axiosRequest
from
'../../utils/request'
;
import
'./index.less'
import
'./index.less'
import
Empty
from
'../Empty'
import
Empty
from
'../Empty'
import
useDebounce
from
'../../useHooks/useDebounce'
const
WorkDetail
=
(
props
)
=>
{
const
WorkDetail
=
(
props
)
=>
{
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
...
@@ -22,7 +23,7 @@ const WorkDetail = (props) => {
...
@@ -22,7 +23,7 @@ const WorkDetail = (props) => {
}).
then
(
res
=>
{
}).
then
(
res
=>
{
setLoading
(
false
);
setLoading
(
false
);
let
result
=
end
&&
res
.
rows
?
data
.
concat
(
res
.
rows
)
:
data
;
let
result
=
end
&&
res
.
rows
?
data
.
concat
(
res
.
rows
)
:
data
;
res
.
rows
&&
res
.
rows
.
length
>=
10
?
setCurrent
(
current
+
1
)
:
Toast
.
info
(
'
已经到达底部
'
,
1
);
res
.
rows
&&
res
.
rows
.
length
>=
10
?
setCurrent
(
current
+
1
)
:
Toast
.
info
(
'
当前是最后一页
'
,
1
);
setEnd
(
res
.
rows
&&
res
.
rows
.
length
>=
10
)
setEnd
(
res
.
rows
&&
res
.
rows
.
length
>=
10
)
setData
(
result
);
setData
(
result
);
});
});
...
@@ -30,15 +31,15 @@ const WorkDetail = (props) => {
...
@@ -30,15 +31,15 @@ const WorkDetail = (props) => {
//下拉加载
//下拉加载
const
[
end
,
setEnd
]
=
useState
(
true
)
const
[
end
,
setEnd
]
=
useState
(
true
)
const
handleScroll
=
()
=>
{
const
handleScroll
=
useDebounce
(
()
=>
{
const
event
=
document
.
getElementById
(
"
work
-content"
)
const
event
=
document
.
getElementById
(
"
common
-content"
)
const
top
=
event
.
scrollTop
;
const
top
=
event
.
scrollTop
;
const
scrollHeight
=
event
.
scrollHeight
;
const
scrollHeight
=
event
.
scrollHeight
;
const
clientHeight
=
event
.
clientHeight
;
const
clientHeight
=
event
.
clientHeight
;
if
(
top
+
clientHeight
===
scrollHeight
)
{
if
(
top
+
clientHeight
===
scrollHeight
)
{
getData
()
getData
()
}
}
}
;
}
,
500
)
useEffect
(()
=>
{
useEffect
(()
=>
{
window
.
addEventListener
(
'scroll'
,
handleScroll
,
true
);
window
.
addEventListener
(
'scroll'
,
handleScroll
,
true
);
return
()
=>
window
.
removeEventListener
(
'scroll'
,
handleScroll
,
true
);
return
()
=>
window
.
removeEventListener
(
'scroll'
,
handleScroll
,
true
);
...
...
src/useHooks/useDebounce.js
0 → 100644
View file @
55024ab6
import
{
useRef
,
useCallback
,
useEffect
}
from
'react'
;
const
UseDebounce
=
(
fn
,
delay
,
dep
=
[])
=>
{
const
{
current
}
=
useRef
({
fn
,
timer
:
null
});
useEffect
(()
=>
{
current
.
fn
=
fn
},
[
fn
])
return
useCallback
((...
args
)
=>
{
if
(
current
.
timer
)
{
clearTimeout
(
current
.
timer
)
}
current
.
timer
=
setTimeout
(()
=>
{
current
.
fn
.
call
(
this
,
...
args
)
},
delay
)
})
};
export
default
UseDebounce
;
src/useHooks/useThrottle.js
0 → 100644
View file @
55024ab6
import
{
useRef
,
useCallback
,
useEffect
}
from
'react'
;
const
UseThrottle
=
(
fn
,
delay
,
dep
=
[])
=>
{
const
{
current
}
=
useRef
({
fn
,
timer
:
null
});
useEffect
(()
=>
{
current
.
fn
=
fn
},
[
fn
])
return
useCallback
((...
args
)
=>
{
if
(
!
current
.
timer
)
{
current
.
timer
=
setTimeout
(()
=>
{
delete
current
.
timer
},
delay
);
current
.
fn
.
call
(
this
,
...
args
)
}
},
dep
)
};
export
default
UseThrottle
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment