|
@@ -5,7 +5,6 @@ import {
|
|
|
Dropdown,
|
|
Dropdown,
|
|
|
type MenuProps,
|
|
type MenuProps,
|
|
|
Popover,
|
|
Popover,
|
|
|
- Skeleton,
|
|
|
|
|
Space,
|
|
Space,
|
|
|
Typography,
|
|
Typography,
|
|
|
} from "antd";
|
|
} from "antd";
|
|
@@ -19,7 +18,7 @@ import MyCreate from "./MyCreate";
|
|
|
import type { IUser } from "../../api/Auth";
|
|
import type { IUser } from "../../api/Auth";
|
|
|
import MdView from "../general/MdView";
|
|
import MdView from "../general/MdView";
|
|
|
|
|
|
|
|
-const { Title, Link, Text } = Typography;
|
|
|
|
|
|
|
+const { Link, Text } = Typography;
|
|
|
|
|
|
|
|
interface IItem<R> {
|
|
interface IItem<R> {
|
|
|
value: R;
|
|
value: R;
|
|
@@ -39,7 +38,6 @@ interface IWidget {
|
|
|
}
|
|
}
|
|
|
const CommunityWidget = ({ word }: IWidget) => {
|
|
const CommunityWidget = ({ word }: IWidget) => {
|
|
|
const intl = useIntl();
|
|
const intl = useIntl();
|
|
|
- const [loaded, setLoaded] = useState(false);
|
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
const [loading, setLoading] = useState(false);
|
|
|
const [wordData, setWordData] = useState<IWord>();
|
|
const [wordData, setWordData] = useState<IWord>();
|
|
|
const [showCreate, setShowCreate] = useState(false);
|
|
const [showCreate, setShowCreate] = useState(false);
|
|
@@ -142,7 +140,7 @@ const CommunityWidget = ({ word }: IWidget) => {
|
|
|
});
|
|
});
|
|
|
_data.editor.sort((a, b) => b.score - a.score);
|
|
_data.editor.sort((a, b) => b.score - a.score);
|
|
|
setWordData(_data);
|
|
setWordData(_data);
|
|
|
- setLoaded(_data.editor.length > 0);
|
|
|
|
|
|
|
+ setLoading(_data.editor.length > 0);
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error(error);
|
|
console.error(error);
|
|
|
} finally {
|
|
} finally {
|
|
@@ -181,7 +179,12 @@ const CommunityWidget = ({ word }: IWidget) => {
|
|
|
return (
|
|
return (
|
|
|
<Space key={id}>
|
|
<Space key={id}>
|
|
|
{name}
|
|
{name}
|
|
|
- <Badge color="geekblue" size="small" count={score} />
|
|
|
|
|
|
|
+ <Badge
|
|
|
|
|
+ color="geekblue"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ count={score}
|
|
|
|
|
+ style={{ display: "none" }}
|
|
|
|
|
+ />
|
|
|
</Space>
|
|
</Space>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
@@ -209,127 +212,106 @@ const CommunityWidget = ({ word }: IWidget) => {
|
|
|
) : undefined;
|
|
) : undefined;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <Card>
|
|
|
|
|
- <Title level={5} id={`community`}>
|
|
|
|
|
- {"社区字典"}
|
|
|
|
|
- </Title>
|
|
|
|
|
- {loading ? (
|
|
|
|
|
- <Skeleton />
|
|
|
|
|
- ) : loaded ? (
|
|
|
|
|
- <div>
|
|
|
|
|
- <div key="meaning">
|
|
|
|
|
- <Space style={{ flexWrap: "wrap" }}>
|
|
|
|
|
- <Text strong>{"意思:"}</Text>
|
|
|
|
|
- {wordData?.meaning
|
|
|
|
|
- .filter((value, index: number) => isShow(value.score, index))
|
|
|
|
|
- .map((item, id) => {
|
|
|
|
|
- return (
|
|
|
|
|
- <Space key={id}>
|
|
|
|
|
- {item.value}
|
|
|
|
|
- <Badge color="geekblue" size="small" count={item.score} />
|
|
|
|
|
- </Space>
|
|
|
|
|
- );
|
|
|
|
|
- })}
|
|
|
|
|
- {meaningLow && meaningLow.length > 0 ? (
|
|
|
|
|
- <Popover
|
|
|
|
|
- content={<Space>{meaningExtra}</Space>}
|
|
|
|
|
- placement="bottom"
|
|
|
|
|
- >
|
|
|
|
|
- <Link>
|
|
|
|
|
- <Space>
|
|
|
|
|
- {intl.formatMessage({
|
|
|
|
|
- id: `buttons.more`,
|
|
|
|
|
- })}
|
|
|
|
|
- <DownOutlined />
|
|
|
|
|
- </Space>
|
|
|
|
|
- </Link>
|
|
|
|
|
- </Popover>
|
|
|
|
|
- ) : undefined}
|
|
|
|
|
- </Space>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div key="grammar">
|
|
|
|
|
- <Space style={{ flexWrap: "wrap" }}>
|
|
|
|
|
- <Text strong>{"语法:"}</Text>
|
|
|
|
|
- {wordData?.grammar
|
|
|
|
|
- .filter((value) => value.score >= minScore)
|
|
|
|
|
- .map((item, id) => {
|
|
|
|
|
- const grammar = item.value.split("$");
|
|
|
|
|
- const grammarGuide = grammar.map((item, id) => {
|
|
|
|
|
- const strCase = item.replaceAll(".", "");
|
|
|
|
|
|
|
+ <Card title="社区字典" loading={loading}>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <div key="meaning">
|
|
|
|
|
+ <Space style={{ flexWrap: "wrap" }}>
|
|
|
|
|
+ <Text strong>{"意思:"}</Text>
|
|
|
|
|
+ {wordData?.meaning
|
|
|
|
|
+ .filter((value, index: number) => isShow(value.score, index))
|
|
|
|
|
+ .map((item) => item.value)}
|
|
|
|
|
+ {meaningLow && meaningLow.length > 0 ? (
|
|
|
|
|
+ <Popover
|
|
|
|
|
+ content={<Space>{meaningExtra}</Space>}
|
|
|
|
|
+ placement="bottom"
|
|
|
|
|
+ >
|
|
|
|
|
+ <Link>
|
|
|
|
|
+ {intl.formatMessage({
|
|
|
|
|
+ id: `buttons.more`,
|
|
|
|
|
+ })}
|
|
|
|
|
+ </Link>
|
|
|
|
|
+ </Popover>
|
|
|
|
|
+ ) : undefined}
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div key="grammar">
|
|
|
|
|
+ <Space style={{ flexWrap: "wrap" }}>
|
|
|
|
|
+ <Text strong>{"语法:"}</Text>
|
|
|
|
|
+ {wordData?.grammar
|
|
|
|
|
+ .filter((value) => value.score >= minScore)
|
|
|
|
|
+ .map((item, id) => {
|
|
|
|
|
+ const grammar = item.value.split("$");
|
|
|
|
|
+ const grammarGuide = grammar.map((item, id) => {
|
|
|
|
|
+ const strCase = item.replaceAll(".", "");
|
|
|
|
|
|
|
|
- return strCase.length > 0 ? (
|
|
|
|
|
- <GrammarPop
|
|
|
|
|
- key={id}
|
|
|
|
|
- gid={strCase}
|
|
|
|
|
- text={intl.formatMessage({
|
|
|
|
|
- id: `dict.fields.type.${strCase}.label`,
|
|
|
|
|
- defaultMessage: strCase,
|
|
|
|
|
- })}
|
|
|
|
|
- />
|
|
|
|
|
- ) : undefined;
|
|
|
|
|
- });
|
|
|
|
|
- return (
|
|
|
|
|
- <Space key={id}>
|
|
|
|
|
- <Space
|
|
|
|
|
- style={{
|
|
|
|
|
- backgroundColor: "rgba(0.5,0.5,0.5,0.2)",
|
|
|
|
|
- borderRadius: 5,
|
|
|
|
|
- paddingLeft: 5,
|
|
|
|
|
- paddingRight: 5,
|
|
|
|
|
- }}
|
|
|
|
|
- >
|
|
|
|
|
- {grammarGuide}
|
|
|
|
|
- </Space>
|
|
|
|
|
- <Badge color="geekblue" size="small" count={item.score} />
|
|
|
|
|
- </Space>
|
|
|
|
|
- );
|
|
|
|
|
- })}
|
|
|
|
|
- </Space>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div key="base">
|
|
|
|
|
- <Space style={{ flexWrap: "wrap" }}>
|
|
|
|
|
- <Text strong>{"词干:"}</Text>
|
|
|
|
|
- {wordData?.parent
|
|
|
|
|
- .filter((value) => value.score >= minScore)
|
|
|
|
|
- .map((item, id) => {
|
|
|
|
|
- return (
|
|
|
|
|
- <Space key={id}>
|
|
|
|
|
- {item.value}
|
|
|
|
|
- <Badge color="geekblue" size="small" count={item.score} />
|
|
|
|
|
|
|
+ return strCase.length > 0 ? (
|
|
|
|
|
+ <GrammarPop
|
|
|
|
|
+ key={id}
|
|
|
|
|
+ gid={strCase}
|
|
|
|
|
+ text={intl.formatMessage({
|
|
|
|
|
+ id: `dict.fields.type.${strCase}.label`,
|
|
|
|
|
+ defaultMessage: strCase,
|
|
|
|
|
+ })}
|
|
|
|
|
+ />
|
|
|
|
|
+ ) : undefined;
|
|
|
|
|
+ });
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Space key={id}>
|
|
|
|
|
+ <Space
|
|
|
|
|
+ style={{
|
|
|
|
|
+ backgroundColor: "rgba(0.5,0.5,0.5,0.2)",
|
|
|
|
|
+ borderRadius: 5,
|
|
|
|
|
+ paddingLeft: 5,
|
|
|
|
|
+ paddingRight: 5,
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ {grammarGuide}
|
|
|
</Space>
|
|
</Space>
|
|
|
- );
|
|
|
|
|
- })}
|
|
|
|
|
- </Space>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div key="collaborator">
|
|
|
|
|
- <Space style={{ flexWrap: "wrap" }}>
|
|
|
|
|
- <Text strong>{"贡献者:"}</Text>
|
|
|
|
|
- {wordData?.editor
|
|
|
|
|
- .filter((_value, index) => index < mainCollaboratorNum)
|
|
|
|
|
- .map((item, id) => {
|
|
|
|
|
- return collaboratorRender(
|
|
|
|
|
- item.value.nickName,
|
|
|
|
|
- id,
|
|
|
|
|
- item.score
|
|
|
|
|
- );
|
|
|
|
|
- })}
|
|
|
|
|
- {more}
|
|
|
|
|
- </Space>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ );
|
|
|
|
|
+ })}
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div key="base">
|
|
|
|
|
+ <Space style={{ flexWrap: "wrap" }}>
|
|
|
|
|
+ <Text strong>{"词干:"}</Text>
|
|
|
|
|
+ {wordData?.parent
|
|
|
|
|
+ .filter((value) => value.score >= minScore)
|
|
|
|
|
+ .map((item, id) => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Space key={id}>
|
|
|
|
|
+ {item.value}
|
|
|
|
|
+ <Badge color="geekblue" size="small" count={item.score} />
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ );
|
|
|
|
|
+ })}
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div key="collaborator">
|
|
|
|
|
+ <Space style={{ flexWrap: "wrap" }}>
|
|
|
|
|
+ <Text strong>{"贡献者:"}</Text>
|
|
|
|
|
+ {wordData?.editor
|
|
|
|
|
+ .filter((_value, index) => index < mainCollaboratorNum)
|
|
|
|
|
+ .map((item, id) => {
|
|
|
|
|
+ return collaboratorRender(item.value.nickName, id, item.score);
|
|
|
|
|
+ })}
|
|
|
|
|
+ {more}
|
|
|
|
|
+ </Space>
|
|
|
|
|
+ </div>
|
|
|
|
|
|
|
|
- <div key="note">
|
|
|
|
|
- <Text strong>{"注释:"}</Text>
|
|
|
|
|
- <div>
|
|
|
|
|
- {wordData?.note
|
|
|
|
|
- .filter((value) => value.score >= minScore)
|
|
|
|
|
- .slice(0, 1)
|
|
|
|
|
- .map((item, id) => {
|
|
|
|
|
- return <MdView html={item.value} key={id} />;
|
|
|
|
|
- })}
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <div key="note">
|
|
|
|
|
+ <Text strong>{"注释:"}</Text>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ {wordData?.note
|
|
|
|
|
+ .filter((value) => value.score >= minScore)
|
|
|
|
|
+ .slice(0, 1)
|
|
|
|
|
+ .map((item, id) => {
|
|
|
|
|
+ return <MdView html={item.value} key={id} />;
|
|
|
|
|
+ })}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- ) : showCreate ? (
|
|
|
|
|
|
|
+ </div>
|
|
|
|
|
+ {showCreate ? (
|
|
|
<MyCreate
|
|
<MyCreate
|
|
|
word={word}
|
|
word={word}
|
|
|
onSave={() => {
|
|
onSave={() => {
|