Commit 107b7d55 authored by wuhao's avatar wuhao 🎯

asd

parent c8e83cb9
/* eslint-disable react/jsx-key */ /* eslint-disable react/jsx-key */
import React, { useState, useEffect, useRef, memo } from 'react'; import React, { useState, useEffect, useRef, memo, cloneElement, createElement } from 'react';
import { RouteContext } from '@ant-design/pro-layout'; import { RouteContext } from '@ant-design/pro-layout';
import { history } from '@umijs/max'; import { Outlet, history } from '@umijs/max';
import Tags from './Tags'; import Tags from './Tags';
import styles from './index.less'; import styles from './index.less';
import { Scrollbars } from 'react-custom-scrollbars'; import { Scrollbars } from 'react-custom-scrollbars';
...@@ -13,7 +13,7 @@ function treeForeach(tree, func) { ...@@ -13,7 +13,7 @@ function treeForeach(tree, func) {
}); });
} }
const TagView = ({ children, home }) => { const TagView = ({ home }) => {
const [tagList, setTagList] = useState([]); const [tagList, setTagList] = useState([]);
const [currentPath, setCurrentPath] = useState(); const [currentPath, setCurrentPath] = useState();
...@@ -83,12 +83,10 @@ const TagView = ({ children, home }) => { ...@@ -83,12 +83,10 @@ const TagView = ({ children, home }) => {
tagsCopy.push({ tagsCopy.push({
title, title,
path, path,
children, children: <Outlet />,
refresh: 0, refresh: 0,
active: true, active: true,
}); });
await setrefresh(false);
setrefresh(true);
} }
return setTagList(tagsCopy); return setTagList(tagsCopy);
...@@ -125,19 +123,26 @@ const TagView = ({ children, home }) => { ...@@ -125,19 +123,26 @@ const TagView = ({ children, home }) => {
setTagList(tagsCopy); setTagList(tagsCopy);
}; };
const [refresh, setrefresh] = useState(true);
// 刷新选择的标签 // 刷新选择的标签
const handleRefreshTag = async (tag) => { const handleRefreshTag = async (tag) => {
// const tagsCopy = tagList.map((item) => { const tagsCopy0 = tagList.map((item) => {
// if (item.path === tag.path) { if (item.path === tag.path) {
// history.push({ pathname: tag?.path, query: tag?.query }); history.push({ pathname: tag?.path, query: tag?.query });
// return { ...item, refresh: item.refresh + 1, active: true }; return { ...item, refresh: item.refresh + 1, active: true, children: null };
// } }
// return { ...item, active: false }; return { ...item, active: false };
// }); });
// setTagList(tagsCopy); const tagsCopy = tagList.map((item) => {
await setrefresh(false); if (item.path === tag.path) {
setrefresh(true); history.push({ pathname: tag?.path, query: tag?.query });
return { ...item, refresh: item.refresh + 1, active: true, children: <Outlet /> };
}
return { ...item, active: false };
});
setTagList(tagsCopy0);
setTimeout(() => {
setTagList(tagsCopy);
}, 10);
}; };
return ( return (
<> <>
......
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