Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:Tencent/tdesign-react-starter in…
Browse files Browse the repository at this point in the history
…to main
  • Loading branch information
uyarn committed Mar 22, 2022
2 parents 46d8c89 + 6a5d8c3 commit 23ee49f
Show file tree
Hide file tree
Showing 26 changed files with 926 additions and 83 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = {
'import/no-unresolved': 'off',
'import/order': 'off',
'import/prefer-default-export': 'off',
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
// 关闭variable必须全部大写规则
'@typescript-eslint/naming-convention': [
'error',
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/issue-synchronize.temp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# force copy from tencent/tdesign
name: Issue Add Assigness

on:
issues:
types: [opened, reopened]

jobs:
mark-duplicate:
runs-on: ubuntu-latest
steps:
# https://docs.github.com/cn/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#issues
- uses: 94dreamer/create-report@main
with:
wxhook: ${{ secrets.WX_HOOK_URL }}
token: ${{ secrets.GITHUB_TOKEN }}
type: 'issue'
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"@types/lodash": "^4.14.178",
"@types/mockjs": "^1.0.6",
"@types/node": "^16.11.18",
"@types/qrcode.react": "^1.0.2",
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
"@types/react-router-dom": "^5.3.2",
Expand Down Expand Up @@ -49,6 +50,7 @@
"echarts-for-react": "^3.0.2",
"lodash": "^4.17.21",
"mockjs": "^1.1.0",
"qrcode.react": "^2.0.0",
"query-string": "^6.12.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
Binary file added src/assets/image/assets-login-bg-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/image/assets-login-bg-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions src/assets/svg/assets-logo-full.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion src/configs/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
LayersIcon,
CheckCircleIcon,
UserCircleIcon,
LogoutIcon,
RootListIcon,
} from 'tdesign-icons-react';

export interface IMenuItem {
Expand Down Expand Up @@ -154,10 +156,22 @@ export const menu: IMenuItem[] = [
},
],
},
{
key: 'login',
label: '登录页',
Icon: LogoutIcon,
children: [
{
key: '/login/index',
label: '登录中心',
path: '/login',
},
],
},
{
key: 'level1',
label: '一级菜单',
Icon: UserCircleIcon,
Icon: RootListIcon,
children: [
{
key: '/level1/level2',
Expand Down
7 changes: 7 additions & 0 deletions src/configs/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import Result403 from 'pages/Result/403';
import Result404 from 'pages/Result/404';
import Result500 from 'pages/Result/500';
import ResultBrowserIncompatible from 'pages/Result/BrowserIncompatible';
import Login from 'pages/Login';

interface IRouteItem {
key?: string;
path: string;
exact?: boolean;
isHome?: boolean;
Component: React.FC<BrowserRouterProps>;
isFullPage?: boolean;
}

export const routes: IRouteItem[] = [
Expand Down Expand Up @@ -106,4 +108,9 @@ export const routes: IRouteItem[] = [
path: '/result/browser-incompatible',
Component: ResultBrowserIncompatible,
},
{
path: '/login',
Component: Login,
isFullPage: true,
},
];
13 changes: 6 additions & 7 deletions src/layouts/components/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,37 @@ import React from 'react';
import { Layout } from 'tdesign-react';
import { ELayout } from 'modules/global';
import Header from './Header';
import Content from './Content';
import Footer from './Footer';
import Menu from './Menu';

import Style from './Content.module.less';

const SideLayout = React.memo(() => (
const SideLayout = React.memo(({ children }: { children: React.ReactNode }) => (
<Layout className={Style.sidePanel}>
<Menu showLogo showOperation />
<Layout className={Style.sideContainer}>
<Header />
<Content />
{children}
<Footer />
</Layout>
</Layout>
));

const TopLayout = React.memo(() => (
const TopLayout = React.memo(({ children }: { children: React.ReactNode }) => (
<Layout className={Style.topPanel}>
<Header showMenu={true} />
<Content />
{children}
<Footer />
</Layout>
));

const MixLayout = React.memo(() => (
const MixLayout = React.memo(({ children }: { children: React.ReactNode }) => (
<Layout className={Style.mixPanel}>
<Header />
<Layout className={Style.mixMain}>
<Menu />
<Layout className={Style.mixContent}>
<Content />
{children}
<Footer />
</Layout>
</Layout>
Expand Down
25 changes: 22 additions & 3 deletions src/layouts/components/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,40 @@ import React from 'react';
import { Switch, Route, Redirect } from 'react-router-dom';
import { Layout } from 'tdesign-react';
import { routes } from 'configs/routes';
import { useAppSelector } from 'modules/store';
import { selectGlobal } from 'modules/global';
import UnAuthorized from 'pages/Result/403';
import NotFound from 'pages/Result/404';
import ServerError from 'pages/Result/500';
import LayoutMap from './Container';

const { Content } = Layout;

export default React.memo(() => {
const home = routes.find((item) => item.isHome);
const globalState = useAppSelector(selectGlobal);
const Container = LayoutMap[globalState.layout];
return (
<Content>
<Switch>
{home && <Redirect path='/' exact to={home.path} />}
{routes.map((route, index) => (
<Route key={index} exact={route.exact} path={route.path} component={route.Component} />
))}
{routes.map((route, index) => {
const { Component } = route;
return route.isFullPage ? (
<Route key={index} exact={route.exact} path={route.path} component={Component} />
) : (
<Route
key={index}
exact={route.exact}
path={route.path}
render={() => (
<Container>
<Component />
</Container>
)}
/>
);
})}
<Route path='/403' component={UnAuthorized} />
<Route path='/500' component={ServerError} />
<Route path='*' component={NotFound} />
Expand Down
9 changes: 8 additions & 1 deletion src/layouts/components/HeaderIcon.module.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
.dropdown {
:global {
.t-dropdown__item {
max-width: none!important;
max-width: none !important;
width: 117px;
&-text {
display: flex;
align-items: center;
}
.t-icon {
margin-right: 8px;
}
}
}
}
Expand Down
44 changes: 31 additions & 13 deletions src/layouts/components/HeaderIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import React, { memo } from 'react';
import { useHistory } from 'react-router-dom';
import { Button, Popup, Badge, Dropdown, Row, Col } from 'tdesign-react';
import { Icon, LogoGithubIcon, MailIcon, HelpCircleIcon, SettingIcon } from 'tdesign-icons-react';
import {
Icon,
LogoGithubIcon,
MailIcon,
HelpCircleIcon,
SettingIcon,
PoweroffIcon,
UserCircleIcon,
} from 'tdesign-icons-react';
import { useAppDispatch } from 'modules/store';
import { toggleSetting } from 'modules/global';
import { logout } from 'modules/user';
import Style from './HeaderIcon.module.less';

const { DropdownMenu, DropdownItem } = Dropdown;

export default memo(() => {
const dispatch = useAppDispatch();
const history = useHistory();
Expand All @@ -18,22 +29,15 @@ export default memo(() => {
window.open('https://github.com/Tencent/tdesign-react-starter');
};

const options = [
{
content: '个人中心',
value: 1,
},
{
content: '退出登录',
value: 2,
},
];

const clickHandler = (data: any) => {
if (data.value === 1) {
history.push('/user/index');
}
};
const handleLogout = async () => {
await dispatch(logout());
history.push('/login/index');
};

return (
<Row align='middle' style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
Expand All @@ -59,14 +63,28 @@ export default memo(() => {
</Button>
</Col>
<Col>
<Dropdown className={Style.dropdown} options={options} trigger={'click'} onClick={clickHandler}>
<Dropdown className={Style.dropdown} trigger={'click'} onClick={clickHandler}>
<Button variant='text'>
<span style={{ display: 'inline-flex', justifyContent: 'center', alignItems: 'center' }}>
<Icon name='user-circle' size='20px' />
<span style={{ display: 'inline-block', margin: '0 5px' }}>Tencent</span>
<Icon name='chevron-down' size='20px' />
</span>
</Button>
<DropdownMenu>
<DropdownItem value={1}>
<>
<UserCircleIcon />
个人中心
</>
</DropdownItem>
<DropdownItem value={1} onClick={handleLogout}>
<>
<PoweroffIcon />
退出登录
</>
</DropdownItem>
</DropdownMenu>
</Dropdown>
</Col>
<Col>
Expand Down
6 changes: 2 additions & 4 deletions src/layouts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import throttle from 'lodash/throttle';
import { useAppSelector, useAppDispatch } from 'modules/store';
import { selectGlobal, toggleSetting, toggleMenu } from 'modules/global';
import Setting from './components/Setting';
import LayoutMap from './components/Container';
import Content from './components/Content';
import Style from './index.module.less';

export default memo(() => {
Expand All @@ -25,11 +25,9 @@ export default memo(() => {
};
}, []);

const Container = LayoutMap[globalState.layout];

return (
<Layout className={Style.mainPanel}>
<Container />
<Content />
<Drawer
destroyOnClose
visible={globalState.setting}
Expand Down
2 changes: 2 additions & 0 deletions src/modules/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { configureStore, combineReducers } from '@reduxjs/toolkit';
import { TypedUseSelectorHook, useSelector, useDispatch } from 'react-redux';

import global from './global';
import user from './user';
import listBase from './list/base';
import listSelect from './list/select';

const reducer = combineReducers({
global,
user,
listBase,
listSelect,
});
Expand Down
Loading

0 comments on commit 23ee49f

Please sign in to comment.