Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Jun 5, 2024
1 parent 5dafe53 commit d6af6c0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 294 deletions.
1 change: 1 addition & 0 deletions packages/canyon-platform/src/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export {}
declare global {
const Alert: typeof import('antd')['Alert']
const Breadcrumb: typeof import('antd')['Breadcrumb']
const Button: typeof import('antd')['Button']
const Card: typeof import('antd')['Card']
const ColorPicker: typeof import('antd')['ColorPicker']
Expand Down
215 changes: 0 additions & 215 deletions packages/canyon-platform/src/pages/index-copy.tsx

This file was deleted.

70 changes: 3 additions & 67 deletions packages/canyon-platform/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,64 +1,24 @@
import Icon, {
ArrowRightOutlined,
CreditCardOutlined,
DashboardOutlined,
FolderOutlined,
LineChartOutlined,
LogoutOutlined,
MoneyCollectOutlined,
MoreOutlined,
SettingOutlined,
} from '@ant-design/icons';
import { useQuery } from '@apollo/client';
import { useRequest } from 'ahooks';
import { Avatar, Breadcrumb, Dropdown, Menu, MenuProps, theme, Tooltip, Typography } from 'antd';
import axios from 'axios';
import { CanyonLayoutBase, CanyonModalGlobalSearch } from 'canyon-ui';
import { useEffect, useMemo, useRef, useState } from 'react';
import Marquee from 'react-fast-marquee';
import { useTranslation } from 'react-i18next';
import { Outlet, useLocation, useNavigate } from 'react-router-dom';

import book from '../assets/book.svg';
import lightLogoSvg from '../assets/light-logo.svg';
import logoSvg from '../assets/logo.svg';
import UilUsersAlt from '../assets/users-icon.tsx';
import AppFooter from '../components/app/footer.tsx';
import { MeDocument } from '../helpers/backend/gen/graphql.ts';
import { genBreadcrumbItems } from '../layouts/genBreadcrumbItems.tsx';
import ScrollBasedLayout from '../ScrollBasedLayout.tsx';
const { useToken } = theme;
const { Text, Title } = Typography;
type MenuItem = Required<MenuProps>['items'][number];

function getItem(
label: React.ReactNode,
key: React.Key,
icon?: React.ReactNode,
children?: MenuItem[],
): MenuItem {
return {
key,
icon,
children,
label,
} as MenuItem;
}

function Index() {
const { t } = useTranslation();
const items: MenuProps['items'] = [
{
label: t('menus.projects'),
key: 'projects',
icon: <FolderOutlined />,
},
{
label: t('menus.settings'),
key: 'settings',
icon: <SettingOutlined />,
},
];
useEffect(() => {
if (localStorage.getItem('token') === null) {
localStorage.clear();
Expand All @@ -77,7 +37,7 @@ function Index() {

try {
// @ts-ignore
if (meData?.me.username !== 'tzhangm') {
if (meData?.me.username && meData?.me.username !== 'tzhangm') {
// @ts-ignore
fetch(window.__canyon__.dsn, {
method: 'POST',
Expand All @@ -95,7 +55,7 @@ function Index() {
// @ts-ignore
instrumentCwd: window.__canyon__.instrumentCwd,
// @ts-ignore
reportID: `${meData?.me.username};${loc.pathname};${window.__canyon__.commitSha.slice(0, 8)}`,
reportID: `${meData?.me.username}|${loc.pathname}`,
// @ts-ignore
branch: window.__canyon__.branch,
}),
Expand All @@ -106,40 +66,19 @@ function Index() {
}
}, [loc.pathname]);

const selectedKey = useMemo(() => {
if (loc.pathname === '/') {
return 'projects';
} else {
return loc.pathname.replace('/', '');
}
}, [loc.pathname]);

useEffect(() => {
setMenuSelectedKey(loc.pathname.replace('/', ''));
}, [loc.pathname]);
const { token } = useToken();
const { data: meData } = useQuery(MeDocument);
const dropdownItems = [getItem(t('app.logout'), 'logout', <LogoutOutlined />)];
const dropdownClick = ({ key }: any) => {
if (key === 'logout') {
localStorage.clear();
window.location.href = '/login';
}
};
const { data: baseData } = useRequest(() => axios.get('/api/base').then(({ data }) => data), {
onSuccess(data) {
// console.log(data,'ss')
window.GITLAB_URL = data.GITLAB_URL;
},
});
const [menuSelectedKey, setMenuSelectedKey] = useState<string>('projects');
window.canyonModalGlobalSearchRef = useRef(null);
return (
<>
{/*<img src={UsageIcon} alt=""/>*/}
{/*<Button onClick={()=>{*/}
{/* window.canyonModalGlobalSearchRef.current.report();*/}
{/*}}>开启</Button>*/}
<CanyonLayoutBase
breadcrumb={
<div>
Expand All @@ -155,10 +94,8 @@ function Index() {
Logout
</div>
),
// icon: <ArrowRightOutlined />,
onClick: () => {
localStorage.clear();
// nav('/login');
window.location.href = '/login';
},
},
Expand All @@ -170,7 +107,7 @@ function Index() {
title={'Canyon'}
logo={
<div>
<img src='/logo.svg' alt='' className={'w-[30px]'} />
<img src='/logo.svg' alt='' className={'w-[28px]'} />
</div>
}
mainTitleRightNode={
Expand Down Expand Up @@ -198,7 +135,6 @@ function Index() {
}
menuSelectedKey={menuSelectedKey}
onSelectMenu={(selectInfo) => {
console.log(selectInfo);
setMenuSelectedKey(selectInfo.key);
nav(`/${selectInfo.key}`);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ const ProjectPage = () => {

<Input.Search
placeholder={t('projects.search_keywords')}
className={'w-[480px] mb-3'}
className={'w-[360px] mb-3'}
onSearch={(value) => {
setKeyword(value);
setCurrent(1);
Expand Down
Loading

0 comments on commit d6af6c0

Please sign in to comment.