github-actions[bot]
2 years ago
committed by
GitHub
17 changed files with 190 additions and 64 deletions
@ -0,0 +1,17 @@ |
|||||
|
import { startTransition, useState } from 'react'; |
||||
|
|
||||
|
const useLayoutState = <S>( |
||||
|
...args: Parameters<typeof useState<S>> |
||||
|
): ReturnType<typeof useState<S>> => { |
||||
|
const [state, setState] = useState<S>(...args); |
||||
|
|
||||
|
const setLayoutState: typeof setState = (...setStateArgs) => { |
||||
|
startTransition(() => { |
||||
|
setState(...setStateArgs); |
||||
|
}); |
||||
|
}; |
||||
|
|
||||
|
return [state, setLayoutState]; |
||||
|
}; |
||||
|
|
||||
|
export default useLayoutState; |
@ -0,0 +1,23 @@ |
|||||
|
name: 🤖 ChatGPT Code Review |
||||
|
|
||||
|
permissions: |
||||
|
contents: read |
||||
|
pull-requests: write |
||||
|
|
||||
|
on: |
||||
|
pull_request: |
||||
|
types: [opened, reopened, synchronize] |
||||
|
|
||||
|
jobs: |
||||
|
test: |
||||
|
runs-on: ubuntu-latest |
||||
|
steps: |
||||
|
- uses: anc95/ChatGPT-CodeReview@main |
||||
|
env: |
||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
||||
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
||||
|
# Optional |
||||
|
LANGUAGE: Chinese |
||||
|
MODEL: |
||||
|
top_p: 1 |
||||
|
temperature: 1 |
@ -1,37 +1,36 @@ |
|||||
import React from 'react'; |
import type { CountdownProps } from 'antd'; |
||||
import { Col, Row, Statistic } from 'antd'; |
import { Col, Row, Statistic } from 'antd'; |
||||
import type { StatisticProps } from 'antd'; |
import React from 'react'; |
||||
|
|
||||
const { Countdown } = Statistic; |
const { Countdown } = Statistic; |
||||
const deadline = Date.now() + 1000 * 60 * 60 * 24 * 2 + 1000 * 30; // Dayjs is also OK
|
|
||||
|
|
||||
const App: React.FC = () => { |
const deadline = Date.now() + 1000 * 60 * 60 * 24 * 2 + 1000 * 30; // Dayjs is also OK
|
||||
const onFinish = () => { |
|
||||
console.log('finished!'); |
|
||||
}; |
|
||||
|
|
||||
const onChange = (val: StatisticProps['value']) => { |
const onFinish: CountdownProps['onFinish'] = () => { |
||||
if (val && 4.95 * 1000 < val && val < 5 * 1000) { |
console.log('finished!'); |
||||
console.log('changed!'); |
}; |
||||
} |
|
||||
}; |
|
||||
|
|
||||
return ( |
const onChange: CountdownProps['onChange'] = (val) => { |
||||
<Row gutter={16}> |
if (typeof val === 'number' && 4.95 * 1000 < val && val < 5 * 1000) { |
||||
<Col span={12}> |
console.log('changed!'); |
||||
<Countdown title="Countdown" value={deadline} onFinish={onFinish} /> |
} |
||||
</Col> |
|
||||
<Col span={12}> |
|
||||
<Countdown title="Million Seconds" value={deadline} format="HH:mm:ss:SSS" /> |
|
||||
</Col> |
|
||||
<Col span={24} style={{ marginTop: 32 }}> |
|
||||
<Countdown title="Day Level" value={deadline} format="D 天 H 时 m 分 s 秒" /> |
|
||||
</Col> |
|
||||
<Col span={12}> |
|
||||
<Countdown title="Countdown" value={Date.now() + 10 * 1000} onChange={onChange} /> |
|
||||
</Col> |
|
||||
</Row> |
|
||||
); |
|
||||
}; |
}; |
||||
|
|
||||
|
const App: React.FC = () => ( |
||||
|
<Row gutter={16}> |
||||
|
<Col span={12}> |
||||
|
<Countdown title="Countdown" value={deadline} onFinish={onFinish} /> |
||||
|
</Col> |
||||
|
<Col span={12}> |
||||
|
<Countdown title="Million Seconds" value={deadline} format="HH:mm:ss:SSS" /> |
||||
|
</Col> |
||||
|
<Col span={24} style={{ marginTop: 32 }}> |
||||
|
<Countdown title="Day Level" value={deadline} format="D 天 H 时 m 分 s 秒" /> |
||||
|
</Col> |
||||
|
<Col span={12}> |
||||
|
<Countdown title="Countdown" value={Date.now() + 10 * 1000} onChange={onChange} /> |
||||
|
</Col> |
||||
|
</Row> |
||||
|
); |
||||
|
|
||||
export default App; |
export default App; |
||||
|
Loading…
Reference in new issue