feat:打开文件夹

This commit is contained in:
shixiaohua 2024-02-06 10:11:26 +08:00
parent bac35b5f38
commit 9adb97e9f6
3 changed files with 16 additions and 22 deletions

View File

@ -9,7 +9,7 @@ import {useDispatch} from "react-redux";
function App() {
let navigateFunction = useNavigate();
let dispatch = useDispatch();
const dispatch = useDispatch();
function nativeTo(path){
navigateFunction(path)
}

View File

@ -87,14 +87,17 @@ const flushTree = (fileDirDate) => {
}
return defaultValueStateSet;
}
const ItemTree = () => {
const ItemTree = (prop) => {
console.log("prop.filePath:",prop.filePath)
const [expandedKeys, setExpandedKeys] = useState([]);
const [searchValue, setSearchValue] = useState('');
const dispatch = useDispatch()
const [autoExpandParent, setAutoExpandParent] = useState(true);
let filePath = useSelector(state => state.dirMessage.data);
const [defaultValueState, setDefaultValueState] = useState(flushTree(filePath));
// let filePath = useSelector(state => state.dirMessage.data);
const [defaultValueState, setDefaultValueState] = useState(flushTree(prop.filePath));
useEffect(() => {
setDefaultValueState(flushTree(prop.filePath))
}, [prop]);
const onExpand = (newExpandedKeys) => {
setExpandedKeys(newExpandedKeys);
setAutoExpandParent(false);

View File

@ -1,17 +1,15 @@
import React, {useEffect, useRef, useState} from 'react';
import React, {useRef, useState} from 'react';
import {
UserOutlined,
} from '@ant-design/icons';
import {Layout, Menu, Button, theme, Avatar, Tabs} from 'antd';
import {Layout, Avatar, Tabs} from 'antd';
import Hlexical from './Hlexical';
import ItemTree from "../../components/ItemTree";
import './index.less'
import {store} from "../../redux/store";
import {isEmpty} from "../../utils/ObjectUtils";
import {useSelector, useDispatch} from "react-redux";
import {addTableBarItem, removeTableBarItem, setActiveKey,updatedSavedFile} from "../../redux/tableBarItem_reducer"
const {Header, Sider, Content} = Layout;
const {Sider} = Layout;
const Note = () => {
const dispatch = useDispatch()
const [collapsed, setCollapsed] = useState(false);
@ -23,20 +21,13 @@ const Note = () => {
const activeKey=useSelector(state => state.tableBarItem.activeKey);
const items = useSelector(state => state.tableBarItem.data)
let filePath = useSelector(state => state.dirMessage.data);
const onChange = (newActiveKey) => {
console.log("setActiveKey(newActiveKey)",newActiveKey)
dispatch(setActiveKey({"activeKey":newActiveKey}));
};
const add = () => {
const newActiveKey = `newTab${newTabIndex.current++}`;
// const newPanes = [...items];
// newPanes.push({
// label: 'New Tab',
// children: <div className="HlexicalName"><Hlexical /></div>,
// key: newActiveKey,
// });
// setItems(newPanes);
dispatch(addTableBarItem(
{
label: 'New Tab',
@ -64,8 +55,6 @@ const Note = () => {
newActiveKey = newPanes[0].key;
}
}
console.log("remove = (newActiveKey):",newActiveKey)
// setItems(newPanes);
dispatch(setActiveKey({"activeKey":newActiveKey}));
};
const onEdit = (targetKey, action) => {
@ -87,7 +76,7 @@ const Note = () => {
</div>
</Sider>
<Sider trigger={null} collapsedWidth={0} collapsible collapsed={collapsed}>
<ItemTree></ItemTree>
<ItemTree filePath={filePath}></ItemTree>
</Sider>
<Layout>
<Tabs
@ -95,7 +84,9 @@ const Note = () => {
onChange={onChange}
activeKey={activeKey}
onEdit={onEdit}
items={items.map(item=>{return {label:item.label,children: <div className="HlexicalName"><Hlexical filePath={item.children}/></div>,key:item.key}})}
items={items.map(item=>{
return {label:item.label,children: <div className="HlexicalName"><Hlexical filePath={item.children}/></div>,key:item.key}
})}
/>
</Layout>
</Layout>