easy-three-utils 0.0.384 → 0.0.385

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import Timeline from './react/Timeline/index.tsx'
2
2
  import TerrainLine from './react/TerrainLine/index.tsx'
3
3
  import ProFileEcharts from './react/ProFileEcharts/index.tsx'
4
4
  import SunshineLine from './react/SunshineLine/index.tsx'
5
+ import CurrentTIme from './react/CurrentTime/index.tsx'
5
6
 
6
7
  const components = {
7
8
  vue: {
@@ -10,7 +11,8 @@ const components = {
10
11
  Timeline,
11
12
  TerrainLine,
12
13
  ProFileEcharts,
13
- SunshineLine
14
+ SunshineLine,
15
+ CurrentTIme
14
16
  }
15
17
  }
16
18
 
@@ -0,0 +1,26 @@
1
+ import { useEffect, useState } from 'react'
2
+ import dayjs from 'dayjs'
3
+
4
+ const CurrentTime: React.FC<{
5
+ type?: string | 'YYYY-MM-DD HH:mm:ss' | 'HH:mm:ss' | 'YYYY-MM-DD';
6
+ interval?: number;
7
+ }> = (props) => {
8
+
9
+ const { type, interval } = props
10
+
11
+ const [currentTime, setCurrentTime] = useState(dayjs().format(type || 'YYYY-MM-DD HH:mm:ss'))
12
+
13
+ useEffect(() => {
14
+ const timer = setInterval(() => {
15
+ setCurrentTime(dayjs().format(type || 'YYYY-MM-DD HH:mm:ss'))
16
+ }, interval || 1000)
17
+
18
+ return () => {
19
+ clearInterval(timer)
20
+ }
21
+ }, [currentTime])
22
+
23
+ return (<div>{currentTime}</div>)
24
+ }
25
+
26
+ export default CurrentTime
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-three-utils",
3
- "version": "0.0.384",
3
+ "version": "0.0.385",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -8,5 +8,5 @@
8
8
  "author": "",
9
9
  "license": "ISC",
10
10
  "types": "./index.d.ts",
11
- "description": "新增根据id获取实体"
11
+ "description": "新增时间组件"
12
12
  }