|
@@ -1,8 +1,18 @@
|
|
|
import React, { useState, useEffect } from 'react';
|
|
import React, { useState, useEffect } from 'react';
|
|
|
import { useParams } from 'react-router-dom';
|
|
import { useParams } from 'react-router-dom';
|
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
|
-import { Space, Row, Col, Button, Typography, Empty, message } from 'antd';
|
|
|
|
|
import {
|
|
import {
|
|
|
|
|
+ Result,
|
|
|
|
|
+ Space,
|
|
|
|
|
+ Row,
|
|
|
|
|
+ Col,
|
|
|
|
|
+ Button,
|
|
|
|
|
+ Typography,
|
|
|
|
|
+ Empty,
|
|
|
|
|
+ message,
|
|
|
|
|
+} from 'antd';
|
|
|
|
|
+import {
|
|
|
|
|
+ Loading3QuartersOutlined,
|
|
|
EyeOutlined,
|
|
EyeOutlined,
|
|
|
StarFilled,
|
|
StarFilled,
|
|
|
StarOutlined,
|
|
StarOutlined,
|
|
@@ -31,7 +41,7 @@ const MemoPage: React.FC = () => {
|
|
|
|
|
|
|
|
const { dictID = '' } = useParams();
|
|
const { dictID = '' } = useParams();
|
|
|
|
|
|
|
|
- const { data: { dict, words } = {} } = useGetDict({
|
|
|
|
|
|
|
+ const { data: { dict, words } = {}, loading } = useGetDict({
|
|
|
id: parseInt(dictID),
|
|
id: parseInt(dictID),
|
|
|
});
|
|
});
|
|
|
const updateWord = useUpdateWord();
|
|
const updateWord = useUpdateWord();
|
|
@@ -56,33 +66,34 @@ const MemoPage: React.FC = () => {
|
|
|
setShowExtra(false);
|
|
setShowExtra(false);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- if (!dict || !shuffledWords) {
|
|
|
|
|
- return <></>;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className={styles.wrapper}>
|
|
<div className={styles.wrapper}>
|
|
|
<Space className={styles.space} size="large" direction="vertical">
|
|
<Space className={styles.space} size="large" direction="vertical">
|
|
|
- <Row justify="space-around">
|
|
|
|
|
- <Col>
|
|
|
|
|
- <Button
|
|
|
|
|
- type={mode === Mode.ValueToMeaning ? 'primary' : 'default'}
|
|
|
|
|
- onClick={() => setMode(Mode.ValueToMeaning)}
|
|
|
|
|
- >
|
|
|
|
|
- {dict.value} → {dict.meaning}
|
|
|
|
|
- </Button>
|
|
|
|
|
- </Col>
|
|
|
|
|
- <Col>
|
|
|
|
|
- <Button
|
|
|
|
|
- type={mode === Mode.MeaningToValue ? 'primary' : 'default'}
|
|
|
|
|
- onClick={() => setMode(Mode.MeaningToValue)}
|
|
|
|
|
- >
|
|
|
|
|
- {dict.meaning} → {dict.value}
|
|
|
|
|
- </Button>
|
|
|
|
|
- </Col>
|
|
|
|
|
- </Row>
|
|
|
|
|
- {shuffledWords.length ? (
|
|
|
|
|
|
|
+ {loading ? (
|
|
|
|
|
+ <Result
|
|
|
|
|
+ icon={<Loading3QuartersOutlined spin />}
|
|
|
|
|
+ subTitle="加载中..."
|
|
|
|
|
+ />
|
|
|
|
|
+ ) : dict && shuffledWords?.length ? (
|
|
|
<>
|
|
<>
|
|
|
|
|
+ <Row justify="space-around">
|
|
|
|
|
+ <Col>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type={mode === Mode.ValueToMeaning ? 'primary' : 'default'}
|
|
|
|
|
+ onClick={() => setMode(Mode.ValueToMeaning)}
|
|
|
|
|
+ >
|
|
|
|
|
+ {dict.valueTitle} → {dict.meaningTitle}
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </Col>
|
|
|
|
|
+ <Col>
|
|
|
|
|
+ <Button
|
|
|
|
|
+ type={mode === Mode.MeaningToValue ? 'primary' : 'default'}
|
|
|
|
|
+ onClick={() => setMode(Mode.MeaningToValue)}
|
|
|
|
|
+ >
|
|
|
|
|
+ {dict.meaningTitle} → {dict.valueTitle}
|
|
|
|
|
+ </Button>
|
|
|
|
|
+ </Col>
|
|
|
|
|
+ </Row>
|
|
|
<Row justify="center">
|
|
<Row justify="center">
|
|
|
<Col className={styles.primaryText}>
|
|
<Col className={styles.primaryText}>
|
|
|
<Text strong>
|
|
<Text strong>
|
|
@@ -107,7 +118,9 @@ const MemoPage: React.FC = () => {
|
|
|
icon={<EyeOutlined />}
|
|
icon={<EyeOutlined />}
|
|
|
onClick={() => setShowValueOrMeaning(true)}
|
|
onClick={() => setShowValueOrMeaning(true)}
|
|
|
>
|
|
>
|
|
|
- {mode === Mode.MeaningToValue ? dict.value : dict.meaning}
|
|
|
|
|
|
|
+ {mode === Mode.MeaningToValue
|
|
|
|
|
+ ? dict.valueTitle
|
|
|
|
|
+ : dict.meaningTitle}
|
|
|
</Button>
|
|
</Button>
|
|
|
)}
|
|
)}
|
|
|
</Col>
|
|
</Col>
|
|
@@ -121,7 +134,7 @@ const MemoPage: React.FC = () => {
|
|
|
icon={<EyeOutlined />}
|
|
icon={<EyeOutlined />}
|
|
|
onClick={() => setShowExtra(true)}
|
|
onClick={() => setShowExtra(true)}
|
|
|
>
|
|
>
|
|
|
- {dict.extra}
|
|
|
|
|
|
|
+ {dict.extraTitle}
|
|
|
</Button>
|
|
</Button>
|
|
|
)}
|
|
)}
|
|
|
</Col>
|
|
</Col>
|
|
@@ -157,7 +170,6 @@ const MemoPage: React.FC = () => {
|
|
|
};
|
|
};
|
|
|
mutateWordsList(newWord, index);
|
|
mutateWordsList(newWord, index);
|
|
|
await updateWord(newWord);
|
|
await updateWord(newWord);
|
|
|
- void message.success('更新成功');
|
|
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
if (err instanceof Error) {
|
|
if (err instanceof Error) {
|
|
|
void message.error(err.message);
|
|
void message.error(err.message);
|