|
|
@@ -23,6 +23,7 @@ interface IWidget {
|
|
|
const Token = ({ channelId, articleId, type }: IWidget) => {
|
|
|
const [text, setText] = useState("");
|
|
|
const [power, setPower] = useState<TPower>("readonly");
|
|
|
+ const [curr, setCurr] = useState(false);
|
|
|
const intl = useIntl();
|
|
|
|
|
|
useEffect(() => {
|
|
|
@@ -35,13 +36,13 @@ const Token = ({ channelId, articleId, type }: IWidget) => {
|
|
|
console.error("channels or book or para is undefined", channelId, id);
|
|
|
return;
|
|
|
}
|
|
|
- const _book = id[0];
|
|
|
+ const _book = parseInt(id[0] ?? "0");
|
|
|
const _para = id[1];
|
|
|
const payload: IPayload[] = [];
|
|
|
payload.push({
|
|
|
res_id: channelId,
|
|
|
res_type: "channel",
|
|
|
- book: parseInt(_book ?? 0),
|
|
|
+ book: curr ? _book : 0,
|
|
|
para_start: parseInt(_para),
|
|
|
para_end: parseInt(_para) + 100,
|
|
|
power: power,
|
|
|
@@ -55,14 +56,24 @@ const Token = ({ channelId, articleId, type }: IWidget) => {
|
|
|
setText(json.data.rows[0].token);
|
|
|
}
|
|
|
});
|
|
|
- }, [articleId, channelId, power, type]);
|
|
|
+ }, [articleId, channelId, curr, power, type]);
|
|
|
return (
|
|
|
<div>
|
|
|
<div style={{ textAlign: "center", padding: 20 }}>
|
|
|
+ <div>
|
|
|
+ <Segmented
|
|
|
+ key="power"
|
|
|
+ options={["readonly", "edit"]}
|
|
|
+ onChange={(value: SegmentedValue) => {
|
|
|
+ setPower(value as TPower);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
<Segmented
|
|
|
- options={["readonly", "edit"]}
|
|
|
- onChange={(value: SegmentedValue) => {
|
|
|
- setPower(value as TPower);
|
|
|
+ key="curr"
|
|
|
+ options={["current", "all"]}
|
|
|
+ onChange={(value) => {
|
|
|
+ setCurr(value === "current");
|
|
|
}}
|
|
|
/>
|
|
|
</div>
|