Commit 107b7d55 authored by wuhao's avatar wuhao 🎯

asd

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