Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Commit

Permalink
feat delayed jump
Browse files Browse the repository at this point in the history
  • Loading branch information
suxiaoshao committed Oct 17, 2020
1 parent 8313c3a commit 4f479fc
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 11 deletions.
2 changes: 1 addition & 1 deletion blogHomework.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ if __name__ == '__main__':

- 沈帅的回答

> 我在这次任务中承担任务比较轻松 并且感觉学习速度较慢 希望在团队作业中能改善(沈帅)
> 苏炜杰表达能力有待提高
- 苏炜杰的回答

Expand Down
1 change: 1 addition & 0 deletions game/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"dependencies": {
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.56",
"dayjs": "^1.9.3",
"fontsource-roboto": "^3.0.3",
"react": "^16.13.1",
Expand Down
40 changes: 31 additions & 9 deletions game/src/view/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import Info from '../components/info';
import { imageList } from '../util/config';
import { useHistory, useLocation } from 'react-router-dom';
import GameBase from '../components/gameBase';
import { Button } from '@material-ui/core';
import { Button, Snackbar } from '@material-ui/core';
import { Alert } from '@material-ui/lab';
import { getRandomItem } from '../util/gameData';
import { addGameRecord } from '../util/store';
import { getSteps } from '../util/prompt';
Expand Down Expand Up @@ -34,6 +35,8 @@ export default function Game(): JSX.Element {
const [tipOpen, setTipOpen] = useState<boolean>(false);
// record dialog 是否打开
const [recordOpen, setRecordOpen] = useState<boolean>(false);
// 成功
const [successOpen, setSuccessOpen] = useState<boolean>(false);
// 路由数据
const myLocation = useLocation<GameData>();
// 路由控制器
Expand Down Expand Up @@ -87,18 +90,13 @@ export default function Game(): JSX.Element {
window.clearInterval(timeId);
setTimeId(undefined);
}
addGameRecord({
serialNumber: myLocation.state.serialNumber,
steps: steps,
useTime: useTime,
src: src,
timeStamp: new Date().getTime(),
});
myHistory.push('/record');
setSuccessOpen(true);
window.clearInterval(timeId);
}
}, [serialNumber]);
return (
<div className="game">
{/* 提示按钮对话框 */}
<TipDialog
serialNumber={serialNumber}
src={src}
Expand All @@ -107,13 +105,36 @@ export default function Game(): JSX.Element {
setTipOpen(false);
}}
/>
{/* 战绩按钮对话框 */}
<RecordDialog
open={recordOpen}
onClose={() => {
setRecordOpen(false);
}}
/>
{/* 成功消息条 */}
<Snackbar
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
open={successOpen}
autoHideDuration={2000}
onClose={() => {
addGameRecord({
serialNumber: myLocation.state.serialNumber,
steps: steps,
useTime: useTime,
src: src,
timeStamp: new Date().getTime(),
});
myHistory.push('/record');
}}
>
<Alert elevation={6} variant="filled" severity="success">
成功挑战本题,将会跳转至战绩页
</Alert>
</Snackbar>
{/* 游戏上方页面信息 */}
<Info useTime={useTime} src={emptySrc} stepsNum={steps.length} />
{/* 游戏主要区域 */}
<GameBase
serialNumber={serialNumber}
src={src}
Expand All @@ -129,6 +150,7 @@ export default function Game(): JSX.Element {
setSteps((value) => value + stepKey);
}}
/>
{/* 按钮组 */}
<div className="button-group">
{timeId !== undefined ? (
<Button
Expand Down
11 changes: 11 additions & 0 deletions game/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,17 @@
dependencies:
"@babel/runtime" "^7.4.4"

"@material-ui/lab@^4.0.0-alpha.56":
version "4.0.0-alpha.56"
resolved "https://registry.npm.taobao.org/@material-ui/lab/download/@material-ui/lab-4.0.0-alpha.56.tgz#ff63080949b55b40625e056bbda05e130d216d34"
integrity sha1-/2MICUm1W0BiXgVrvaBeEw0hbTQ=
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/utils" "^4.10.2"
clsx "^1.0.4"
prop-types "^15.7.2"
react-is "^16.8.0"

"@material-ui/styles@^4.10.0":
version "4.10.0"
resolved "https://registry.npm.taobao.org/@material-ui/styles/download/@material-ui/styles-4.10.0.tgz#2406dc23aa358217aa8cc772e6237bd7f0544071"
Expand Down
2 changes: 1 addition & 1 deletion ss.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ if __name__ == '__main__':

- 沈帅的回答

> 我在这次任务中承担任务比较轻松 并且感觉学习速度较慢 希望在团队作业中能改善(沈帅)
> 苏炜杰表达能力有待提高
- 苏炜杰的回答

Expand Down

0 comments on commit 4f479fc

Please sign in to comment.