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() { function App() {
let navigateFunction = useNavigate(); let navigateFunction = useNavigate();
let dispatch = useDispatch(); const dispatch = useDispatch();
function nativeTo(path){ function nativeTo(path){
navigateFunction(path) navigateFunction(path)
} }

View File

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

View File

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