mirror of https://github.com/fantasticit/think.git
fix: fix reorder documnets
This commit is contained in:
parent
2a6a82936f
commit
e6ef6df7d5
|
@ -2,7 +2,7 @@
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
|
|
||||||
.tocsWrap {
|
.tocsWrap {
|
||||||
height: 420px;
|
height: 560px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
border: 1px solid var(--semi-color-border);
|
border: 1px solid var(--semi-color-border);
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
import { Banner, Tree, Button, Toast, Typography } from '@douyinfe/semi-ui';
|
import { Banner, Tree, Button, Toast, Typography } from '@douyinfe/semi-ui';
|
||||||
import { DataRender } from 'components/data-render';
|
import { DataRender } from 'components/data-render';
|
||||||
|
import { Resizeable } from 'components/resizeable';
|
||||||
import { useWikiTocs } from 'data/wiki';
|
import { useWikiTocs } from 'data/wiki';
|
||||||
import styles from './index.module.scss';
|
import styles from './index.module.scss';
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ const extractRelation = (treeData: Array<IDataNode>) => {
|
||||||
});
|
});
|
||||||
index++;
|
index++;
|
||||||
if (node.children && node.children.length) {
|
if (node.children && node.children.length) {
|
||||||
data.push(...node.children.map((sub, j) => ({ ...sub, index: j })));
|
data.push(...node.children.map((sub, j) => ({ ...sub, index: j, parentDocumentId: node.id })));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +51,8 @@ export const WikiTocsManager: React.FC<IProps> = ({ wikiId }) => {
|
||||||
setTreeData(tocs);
|
setTreeData(tocs);
|
||||||
}, [tocs]);
|
}, [tocs]);
|
||||||
|
|
||||||
function onDrop(info) {
|
const onDrop = useCallback(
|
||||||
|
(info) => {
|
||||||
const { dropToGap, node, dragNode } = info;
|
const { dropToGap, node, dragNode } = info;
|
||||||
const dropKey = node.key;
|
const dropKey = node.key;
|
||||||
const dragKey = dragNode.key;
|
const dragKey = dragNode.key;
|
||||||
|
@ -98,15 +100,17 @@ export const WikiTocsManager: React.FC<IProps> = ({ wikiId }) => {
|
||||||
}
|
}
|
||||||
setTreeData(data);
|
setTreeData(data);
|
||||||
setChanged(true);
|
setChanged(true);
|
||||||
}
|
},
|
||||||
|
[treeData]
|
||||||
|
);
|
||||||
|
|
||||||
const submit = () => {
|
const submit = useCallback(() => {
|
||||||
const data = extractRelation(treeData);
|
const data = extractRelation(treeData);
|
||||||
updateTocs(data).then(() => {
|
updateTocs(data).then(() => {
|
||||||
setChanged(false);
|
setChanged(false);
|
||||||
Toast.success('目录已更新');
|
Toast.success('目录已更新');
|
||||||
});
|
});
|
||||||
};
|
}, [treeData, updateTocs]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
|
|
Loading…
Reference in New Issue