Commit b974d3db by zhaochengxiang

路径调整问题

parent 4113de53
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState, useRef } from 'react';
import { useMount, useUnmount } from 'ahooks'; import { useMount, useUnmount } from 'ahooks';
import {Card, Spin, Tooltip, Tree, Input, Dropdown, Menu, Modal} from 'antd'; import {Card, Spin, Tooltip, Tree, Input, Dropdown, Menu, Modal} from 'antd';
import { PlusOutlined, ImportOutlined,EditOutlined,DeleteOutlined,ExportOutlined,ReloadOutlined, SettingOutlined, ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons'; import { PlusOutlined, ImportOutlined,EditOutlined,DeleteOutlined,ExportOutlined,ReloadOutlined, SettingOutlined, ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons';
...@@ -36,6 +36,9 @@ const AssetTree = (props) => { ...@@ -36,6 +36,9 @@ const AssetTree = (props) => {
const timestamp = getQueryParam(AnchorTimestamp, props?.location?.search); const timestamp = getQueryParam(AnchorTimestamp, props?.location?.search);
const id = getQueryParam(AnchorId, props?.location?.search); const id = getQueryParam(AnchorId, props?.location?.search);
const treeDataRef = useRef([]);
const dataListRef = useRef([]);
useMount(() => { useMount(() => {
window?.addEventListener("storage", storageChange); window?.addEventListener("storage", storageChange);
}) })
...@@ -136,6 +139,9 @@ const AssetTree = (props) => { ...@@ -136,6 +139,9 @@ const AssetTree = (props) => {
setDataList(_dataList); setDataList(_dataList);
setGroupIds(_groupIds); setGroupIds(_groupIds);
treeDataRef.current = newData;
dataListRef.current = _dataList;
let defaultItem = null; let defaultItem = null;
function recursion(subCatalogs) { function recursion(subCatalogs) {
...@@ -213,14 +219,14 @@ const AssetTree = (props) => { ...@@ -213,14 +219,14 @@ const AssetTree = (props) => {
} }
if ((did||'') !== '') { if ((did||'') !== '') {
recursion(treeData); recursion(treeDataRef.current);
} }
if (defaultItem) { if (defaultItem) {
const expandedKeys = (dataList||[]) const expandedKeys = (dataListRef.current||[])
.map(item => { .map(item => {
if (item.key.indexOf(did) > -1) { if (item.key.indexOf(did) > -1) {
return getParentKey(item.key, treeData); return getParentKey(item.key, treeDataRef.current);
} }
return null; return null;
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment