Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Nov 8, 2023
1 parent d5284dd commit 75bae13
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/canyon-platform/src/layout/MainBox.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Icon, { DashboardOutlined } from '@ant-design/icons';
import { useQuery } from '@apollo/client';
import type { MenuProps } from 'antd';
import { Avatar, Dropdown, Layout, Menu, Space } from 'antd';
import { Avatar, Breadcrumb, Dropdown, Layout, Menu, Space } from 'antd';
import React, { useEffect, useMemo, useState } from 'react';
import { useLocation, useNavigate, useRoutes } from 'react-router-dom';

import routes from '~react-pages';

import { MeDocument } from '../helpers/backend/gen/graphql.ts';
import { genBreadcrumbItems } from './gen.tsx';
import Sv from './Sv';

const { Content, Sider } = Layout;

type MenuItem = Required<MenuProps>['items'][number];
Expand Down Expand Up @@ -62,7 +62,7 @@ const App: React.FC = () => {
}, [loc.pathname]);

const dropdownItems = [getItem('登出', 'logout')];
const dropdownClick = ({ key }:any) => {
const dropdownClick = ({ key }: any) => {
console.log(key);
localStorage.clear();
window.location.href = '/welcome';
Expand Down Expand Up @@ -102,8 +102,10 @@ const App: React.FC = () => {
</Sider>
<Layout>
<header className={'h-[48px] bg-white flex justify-between px-5'}>
<span></span>

<div>
{/*<div>{JSON.stringify(loc)}</div>*/}
<Breadcrumb className={'ml-3 mt-3'} items={genBreadcrumbItems(loc.pathname)} />
</div>
<Dropdown menu={{ items: dropdownItems, onClick: dropdownClick }}>
<Space
className={'flex items-center cursor-pointer'}
Expand All @@ -113,10 +115,6 @@ const App: React.FC = () => {
<span>{meData?.me.username}</span>
</Space>
</Dropdown>

{/*<Space >*/}

{/*</Space>*/}
</header>
<Content style={{ margin: '0 0' }}>
<div style={{ padding: 24, minHeight: 360 }}>{r}</div>
Expand Down
47 changes: 47 additions & 0 deletions packages/canyon-platform/src/layout/gen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { useNavigate } from 'react-router-dom';

export function genBreadcrumbItems(pathname:string) {
// eslint-disable-next-line react-hooks/rules-of-hooks
const nav = useNavigate();
console.log(pathname);
if (pathname.includes('overview')) {
return [
{
title: <span className={'cursor-pointer'}>Project</span>,
onClick() {
nav('/project');
},
},
{
title: 'Overview',
},
];
} else if (pathname.includes('commits')) {
return [
{
title: <span className={'cursor-pointer'}>Project</span>,
onClick() {
nav('/project');
},
},
{
title: <span className={'cursor-pointer'}>Overview</span>,
onClick() {
const regex = /\/project\/(\d+)\//;
const match = pathname.match(regex);
if (match) {
const projectId = match[1];
nav(`/project/${projectId}/overview`);
} else {
console.log('未找到匹配的项目ID');
}
},
},
{
title: 'Coverage Details',
},
];
} else {
return [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useNavigate } from 'react-router-dom';
import { GetProjectOverviewDocument } from '../../../helpers/backend/gen/graphql.ts';
const Xx = () => {
const pam = useParams();
console.log(pam)
const nav = useNavigate();
const { data } = useQuery(GetProjectOverviewDocument, {
variables: {
Expand Down

0 comments on commit 75bae13

Please sign in to comment.