-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update the latest time through the ref attribute
- Loading branch information
wb-gp529739
committed
Nov 28, 2024
1 parent
6540de1
commit b30ba64
Showing
3 changed files
with
69 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useState, useRef } from 'react'; | ||
import { DateRanger } from '@oceanbase/ui'; | ||
import { Divider, Flex, Button } from '@oceanbase/design'; | ||
import dayjs from 'dayjs'; | ||
|
||
type TimeRangeRef = { | ||
updateCurrentTime: () => void; | ||
}; | ||
|
||
export default () => { | ||
const ref = useRef<TimeRangeRef>(); | ||
const [timeRange, setTimeRange] = useState([]); | ||
return ( | ||
<div> | ||
<Flex gap="middle" align="center"> | ||
<Button | ||
onClick={() => { | ||
console.log('ref: ', ref); | ||
ref.current.updateCurrentTime(); | ||
}} | ||
> | ||
更新最新时间 | ||
</Button> | ||
{timeRange.length && ( | ||
<span> | ||
{`${dayjs(timeRange[0]).format('YYYY-MM-DD HH:mm:ss')} ~ ${dayjs(timeRange[1]).format( | ||
'YYYY-MM-DD HH:mm:ss' | ||
)}`} | ||
</span> | ||
)} | ||
</Flex> | ||
|
||
<Divider children="preview" /> | ||
<DateRanger | ||
ref={ref} | ||
onChange={setTimeRange} | ||
defaultQuickValue={DateRanger.NEAR_30_MINUTES.name} | ||
hasRewind={false} | ||
hasForward={false} | ||
hasSync={false} | ||
/> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters