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;
|
||||
|
||||
.tocsWrap {
|
||||
height: 420px;
|
||||
height: 560px;
|
||||
overflow: auto;
|
||||
border: 1px solid var(--semi-color-border);
|
||||
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 { DataRender } from 'components/data-render';
|
||||
import { Resizeable } from 'components/resizeable';
|
||||
import { useWikiTocs } from 'data/wiki';
|
||||
import styles from './index.module.scss';
|
||||
|
||||
|
@ -32,7 +33,7 @@ const extractRelation = (treeData: Array<IDataNode>) => {
|
|||
});
|
||||
index++;
|
||||
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);
|
||||
}, [tocs]);
|
||||
|
||||
function onDrop(info) {
|
||||
const onDrop = useCallback(
|
||||
(info) => {
|
||||
const { dropToGap, node, dragNode } = info;
|
||||
const dropKey = node.key;
|
||||
const dragKey = dragNode.key;
|
||||
|
@ -98,15 +100,17 @@ export const WikiTocsManager: React.FC<IProps> = ({ wikiId }) => {
|
|||
}
|
||||
setTreeData(data);
|
||||
setChanged(true);
|
||||
}
|
||||
},
|
||||
[treeData]
|
||||
);
|
||||
|
||||
const submit = () => {
|
||||
const submit = useCallback(() => {
|
||||
const data = extractRelation(treeData);
|
||||
updateTocs(data).then(() => {
|
||||
setChanged(false);
|
||||
Toast.success('目录已更新');
|
||||
});
|
||||
};
|
||||
}, [treeData, updateTocs]);
|
||||
|
||||
return (
|
||||
<div className={styles.wrap}>
|
||||
|
|
Loading…
Reference in New Issue