Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): 右上角nav在生成portal及mis的 a 标签时不添加base path #1363

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/fast-kings-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@scow/portal-web": patch
"@scow/mis-web": patch
"@scow/lib-web": patch
---

右上角nav在生成portal及mis的 a 标签时不添加base path
2 changes: 2 additions & 0 deletions apps/mis-web/src/layouts/BaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const BaseLayout =
icon: <DesktopOutlined style={{ paddingRight: 2 }} />,
href: toCallbackPage(publicConfig.PORTAL_URL),
text: t("layouts.route.navLinkTextPortal"),
crossSystem: true,
});
}

Expand All @@ -62,6 +63,7 @@ export const BaseLayout =
icon: <RobotOutlined style={{ paddingRight: 2 }} />,
href: publicConfig.AI_URL,
text: t("layouts.route.navLinkTextAI"),
crossSystem: true,
});
}

Expand Down
2 changes: 2 additions & 0 deletions apps/portal-web/src/layouts/BaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const BaseLayout = ({ footerText, versionTag, initialLanguage, children }
icon: <MisIcon style={{ paddingRight: 2 }} />,
href: toCallbackPage(publicConfig.MIS_URL),
text: t("baseLayout.linkTextMis"),
crossSystem: true,
});
}

Expand All @@ -80,6 +81,7 @@ export const BaseLayout = ({ footerText, versionTag, initialLanguage, children }
icon: <RobotOutlined style={{ paddingRight: 2 }} />,
href: publicConfig.AI_URL,
text: t("baseLayout.linkTextAI"),
crossSystem: true,
});
}

Expand Down
39 changes: 31 additions & 8 deletions libs/web/src/layouts/base/header/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* See the Mulan PSL v2 for more details.
*/

import { Tooltip } from "antd";
import { Tooltip, Typography } from "antd";
import NextLink from "next/link";
import { useEffect, useRef, useState } from "react";
import { antdBreakpoints } from "src/layouts/base/constants";
Expand All @@ -36,6 +36,14 @@ const Link = styled(NextLink)`
align-items: center;
`;

const TypographyLink = styled(Typography.Link)`
font-size: 18px !important;
display: flex;
flex-wrap: wrap;
overflow: hidden;
align-items: center;
`;

export const TextSpan = styled.span`
`;

Expand All @@ -49,9 +57,10 @@ interface JumpToAnotherLinkProps {
href: string;
text: string;
hideText?: boolean;
crossSystem?: boolean;
}

export const JumpToAnotherLink: React.FC<JumpToAnotherLinkProps> = ({ href, icon, text, hideText }) => {
export const JumpToAnotherLink: React.FC<JumpToAnotherLinkProps> = ({ href, icon, text, hideText, crossSystem }) => {

const [isSmallScreen, setIsSmallScreen] = useState(false);

Expand All @@ -70,10 +79,9 @@ export const JumpToAnotherLink: React.FC<JumpToAnotherLinkProps> = ({ href, icon
};
}, []);

return (

<LinkItem>
<Link href={href} ref={linkRef}>
const content = () => {
return (
<>
{(hideText || isSmallScreen) ? (
<Tooltip title={text}>
<IconContainer>
Expand All @@ -89,8 +97,23 @@ export const JumpToAnotherLink: React.FC<JumpToAnotherLinkProps> = ({ href, icon
{text}
</TextSpan>
</>
)}
</Link>
)}</>
);
};

return (

<LinkItem>
{
crossSystem ? (
<TypographyLink href={href} ref={linkRef}>
{content()}
</TypographyLink>
) : (
<Link href={href} ref={linkRef}>
{content()}
</Link>
) }
</LinkItem>

);
Expand Down
2 changes: 2 additions & 0 deletions libs/web/src/layouts/base/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface HeaderNavbarLink {
icon: React.ReactNode;
href: string;
text: string;
crossSystem?: boolean;
};

interface Props {
Expand Down Expand Up @@ -107,6 +108,7 @@ export const Header: React.FC<Props> = ({
icon={x.icon}
href={x.href}
text={x.text}
crossSystem={x.crossSystem}
hideText={hideLinkText}
/>
);
Expand Down
Loading