fix: 修复多标签页标题问题

Reviewed-on: daoyoucloud/tachycode#594
This commit is contained in:
sealday 2024-04-03 18:00:51 +08:00
parent 0a98e7e8f2
commit 93b7abbd30
5 changed files with 24 additions and 17 deletions

View File

@ -0,0 +1,5 @@
---
"@hera/plugin-core": patch
---
修复页面 tab 问题

View File

@ -95,6 +95,7 @@
"@nocobase/schema": "0.21.2-alpha.4"
},
"changesets": [
"five-walls-enjoy",
"hot-mugs-double",
"long-dolphins-sit",
"pretty-wolves-allow",

View File

@ -1,7 +1,7 @@
{
"name": "@hera/plugin-core",
"displayName": "Hera platform",
"version": "1.7.4-alpha.7",
"version": "1.7.4-alpha.8",
"description": "Hera platform as nocobase plugin.",
"keywords": [
"System management"

View File

@ -215,27 +215,28 @@ export const InternalAdminLayout = (props: any) => {
const params = useParams<{ name?: string }>();
const { token } = useToken();
const { render } = useAppSpin();
const { title } = useDocumentTitle();
const { title, setTitle } = useDocumentTitle();
const navigate = useNavigate();
const [items, setItems] = useState<TabsProps['items']>([]);
const pageStyle = usePageStyle();
useEffect(() => {
if (params.name && title && pageStyle === 'tab') {
setItems((items) => {
if (!items.find((value) => value.key === params.name)) {
return [
...items,
{
key: params.name,
label: title,
children: <MyRouteSchemaComponent name={params.name} />,
},
];
} else {
return items;
}
});
const targetItem = items.find((value) => value.key === params.name);
if (!targetItem) {
// 现有tab页数组里,不存在之前浏览的tab页面,添加新的tab页进数组
setItems([
...items,
{
key: params.name,
label: title,
children: <MyRouteSchemaComponent name={params.name} />,
},
]);
} else {
// 如果存在之前浏览的tab页面,只用更新页面标题
setTitle(targetItem.label);
}
}
}, [params.name, title]);

View File

@ -1,7 +1,7 @@
{
"name": "@hera/plugin-rental",
"displayName": "professional construction materials rental system - customized based on hera",
"version": "1.7.6-alpha.9",
"version": "1.7.6-alpha.10",
"description": "Offering a standardized leasing management system, encompassing comprehensive administration from materials to contracts to labor personnel, while providing a robust financial management mechanism, and real-time monitoring of the operational capacity of the leasing system.",
"keywords": [
"System management"