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" "@nocobase/schema": "0.21.2-alpha.4"
}, },
"changesets": [ "changesets": [
"five-walls-enjoy",
"hot-mugs-double", "hot-mugs-double",
"long-dolphins-sit", "long-dolphins-sit",
"pretty-wolves-allow", "pretty-wolves-allow",

View File

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

View File

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

View File

@ -1,7 +1,7 @@
{ {
"name": "@hera/plugin-rental", "name": "@hera/plugin-rental",
"displayName": "professional construction materials rental system - customized based on hera", "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.", "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": [ "keywords": [
"System management" "System management"