Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
44173606
Commit
44173606
authored
Oct 17, 2017
by
afc163
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove Countdown
parent
36fbfbe7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
137 deletions
+0
-137
src/components/Countdown/demo/simple.md
src/components/Countdown/demo/simple.md
+0
-16
src/components/Countdown/index.js
src/components/Countdown/index.js
+0
-105
src/components/Countdown/index.md
src/components/Countdown/index.md
+0
-16
No files found.
src/components/Countdown/demo/simple.md
deleted
100644 → 0
View file @
36fbfbe7
---
order
:
0
title
:
Simple
---
简单的页头。
````
jsx
import
CountDown
from
'
ant-design-pro/lib/CountDown
'
;
const
targetTime
=
new
Date
().
getTime
()
+
3900000
;
ReactDOM
.
render
(
<
CountDown
target
=
{
targetTime
}
/>
,
mountNode
);
````
src/components/Countdown/index.js
deleted
100644 → 0
View file @
36fbfbe7
import
React
,
{
Component
}
from
'
react
'
;
function
fixedZero
(
val
)
{
return
val
*
1
<
10
?
`0
${
val
}
`
:
val
;
}
class
CountDown
extends
Component
{
constructor
(
props
)
{
super
(
props
);
const
{
lastTime
}
=
this
.
initTime
(
props
);
this
.
state
=
{
lastTime
,
};
}
componentDidMount
()
{
this
.
tick
();
}
componentWillReceiveProps
(
nextProps
)
{
if
(
this
.
props
.
target
!==
nextProps
.
target
)
{
const
{
lastTime
}
=
this
.
initTime
(
nextProps
);
this
.
setState
({
lastTime
,
});
}
}
componentWillUnmount
()
{
clearTimeout
(
this
.
timer
);
}
timer
=
0
;
interval
=
1000
;
initTime
=
(
props
)
=>
{
let
lastTime
=
0
;
let
targetTime
=
0
;
try
{
if
(
Object
.
prototype
.
toString
.
call
(
props
.
target
)
===
'
[object Date]
'
)
{
targetTime
=
props
.
target
.
getTime
();
}
else
{
targetTime
=
new
Date
(
props
.
target
).
getTime
();
}
}
catch
(
e
)
{
throw
new
Error
(
'
invalid target prop
'
,
e
);
}
lastTime
=
targetTime
-
new
Date
().
getTime
();
return
{
lastTime
,
};
}
// defaultFormat = time => (
// <span>{moment(time).format('hh:mm:ss')}</span>
// );
defaultFormat
=
(
time
)
=>
{
const
hours
=
60
*
60
*
1000
;
const
minutes
=
60
*
1000
;
const
h
=
fixedZero
(
Math
.
floor
(
time
/
hours
));
const
m
=
fixedZero
(
Math
.
floor
((
time
-
(
h
*
hours
))
/
minutes
));
const
s
=
fixedZero
(
Math
.
floor
((
time
-
(
h
*
hours
)
-
(
m
*
minutes
))
/
1000
));
return
(
<
span
>
{
h
}:{
m
}:{
s
}
<
/span
>
);
}
tick
=
()
=>
{
const
{
onEnd
}
=
this
.
props
;
let
{
lastTime
}
=
this
.
state
;
this
.
timer
=
setTimeout
(()
=>
{
if
(
lastTime
<
this
.
interval
)
{
clearTimeout
(
this
.
timer
);
this
.
setState
({
lastTime
:
0
,
});
if
(
onEnd
)
{
onEnd
();
}
}
else
{
lastTime
-=
this
.
interval
;
this
.
setState
({
lastTime
,
});
this
.
tick
();
}
},
this
.
interval
);
}
render
()
{
const
{
format
=
this
.
defaultFormat
}
=
this
.
props
;
const
{
lastTime
}
=
this
.
state
;
const
result
=
format
(
lastTime
);
return
result
;
}
}
export
default
CountDown
;
src/components/Countdown/index.md
deleted
100644 → 0
View file @
36fbfbe7
---
category
:
Components
type
:
General
title
:
CountDown
subtitle
:
倒计时
cols
:
1
---
倒计时组件。
## API
| 参数 | 说明 | 类型 | 默认值 |
|----------|------------------------------------------|-------------|-------|
| format | 时间格式化显示显示 | Function(time) | |
| target | 目标时间 | Date | - |
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