mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-07 14:16:52 +08:00
feat: header重构
This commit is contained in:
parent
7d8455165a
commit
21349034b9
@ -3,13 +3,19 @@ import React, { Component } from 'react'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
import { Link } from 'react-router-dom'
|
import { Link } from 'react-router-dom'
|
||||||
import { Icon, Layout, Menu, Dropdown, message } from 'antd'
|
import { Icon, Layout, Menu, Dropdown, message, Tooltip } from 'antd'
|
||||||
import { checkLoginState, logoutActions, loginTypeAction} from '../../reducer/modules/login'
|
import { checkLoginState, logoutActions, loginTypeAction} from '../../reducer/modules/login'
|
||||||
import { changeMenuItem } from '../../reducer/modules/menu'
|
import { changeMenuItem } from '../../reducer/modules/menu'
|
||||||
import { withRouter } from 'react-router';
|
import { withRouter } from 'react-router';
|
||||||
import Srch from './Search/Search'
|
import Srch from './Search/Search'
|
||||||
const { Header } = Layout;
|
const { Header } = Layout;
|
||||||
|
|
||||||
|
const headerStyle = {
|
||||||
|
'height': '.56rem',
|
||||||
|
'lineHeight': '.56rem',
|
||||||
|
'padding': 0
|
||||||
|
};
|
||||||
|
|
||||||
const MenuUser = (props) => (
|
const MenuUser = (props) => (
|
||||||
<Menu
|
<Menu
|
||||||
style={{
|
style={{
|
||||||
@ -24,19 +30,32 @@ const MenuUser = (props) => (
|
|||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</Menu>
|
</Menu>
|
||||||
);
|
);
|
||||||
|
|
||||||
MenuUser.propTypes={
|
MenuUser.propTypes={
|
||||||
user:PropTypes.string,
|
user: PropTypes.string,
|
||||||
msg:PropTypes.string,
|
msg: PropTypes.string,
|
||||||
uid: PropTypes.number,
|
uid: PropTypes.number,
|
||||||
relieveLink:PropTypes.func,
|
relieveLink: PropTypes.func,
|
||||||
logout:PropTypes.func
|
logout: PropTypes.func
|
||||||
}
|
}
|
||||||
|
|
||||||
const ToolUser = (props)=> (
|
const ToolUser = (props)=> (
|
||||||
<ul>
|
<ul>
|
||||||
<li className="toolbar-li">
|
<li className="toolbar-li item-search">
|
||||||
<Srch groupList={props.groupList}/>
|
<Srch groupList={props.groupList}/>
|
||||||
</li>
|
</li>
|
||||||
|
<Link to="/">
|
||||||
|
<Tooltip placement="bottom" title={'新建项目'}>
|
||||||
|
<li className="toolbar-li">
|
||||||
|
<Icon className="dropdown-link" style={{ fontSize: 16 }} type="plus-circle" />
|
||||||
|
</li>
|
||||||
|
</Tooltip>
|
||||||
|
</Link>
|
||||||
|
<Tooltip placement="bottom" title={'使用文档'}>
|
||||||
|
<li className="toolbar-li">
|
||||||
|
<a target="_blank" href="./doc/index.html"><Icon className="dropdown-link" style={{ fontSize: 16 }} type="question-circle" /></a>
|
||||||
|
</li>
|
||||||
|
</Tooltip>
|
||||||
<li className="toolbar-li">
|
<li className="toolbar-li">
|
||||||
<Dropdown
|
<Dropdown
|
||||||
placement = "bottomRight"
|
placement = "bottomRight"
|
||||||
@ -50,18 +69,18 @@ const ToolUser = (props)=> (
|
|||||||
/>
|
/>
|
||||||
}>
|
}>
|
||||||
<a className="dropdown-link">
|
<a className="dropdown-link">
|
||||||
<Icon type="solution" />
|
<Icon type="solution" /><span className="name">{props.user}</span>
|
||||||
</a>
|
</a>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
);
|
);
|
||||||
ToolUser.propTypes={
|
ToolUser.propTypes={
|
||||||
user:PropTypes.string,
|
user: PropTypes.string,
|
||||||
msg:PropTypes.string,
|
msg: PropTypes.string,
|
||||||
uid: PropTypes.number,
|
uid: PropTypes.number,
|
||||||
relieveLink:PropTypes.func,
|
relieveLink: PropTypes.func,
|
||||||
logout:PropTypes.func,
|
logout: PropTypes.func,
|
||||||
groupList: PropTypes.array
|
groupList: PropTypes.array
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -73,8 +92,7 @@ ToolUser.propTypes={
|
|||||||
user: state.login.userName,
|
user: state.login.userName,
|
||||||
uid: state.login.uid,
|
uid: state.login.uid,
|
||||||
msg: null,
|
msg: null,
|
||||||
login:state.login.isLogin,
|
login:state.login.isLogin
|
||||||
curKey: state.menu.curKey
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -95,7 +113,6 @@ export default class HeaderCom extends Component {
|
|||||||
msg: PropTypes.string,
|
msg: PropTypes.string,
|
||||||
uid: PropTypes.number,
|
uid: PropTypes.number,
|
||||||
login:PropTypes.bool,
|
login:PropTypes.bool,
|
||||||
curKey:PropTypes.string,
|
|
||||||
relieveLink:PropTypes.func,
|
relieveLink:PropTypes.func,
|
||||||
logoutActions:PropTypes.func,
|
logoutActions:PropTypes.func,
|
||||||
checkLoginState:PropTypes.func,
|
checkLoginState:PropTypes.func,
|
||||||
@ -147,43 +164,15 @@ export default class HeaderCom extends Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
const { login, user, msg, uid, curKey } = this.props;
|
const { login, user, msg, uid } = this.props;
|
||||||
const headerImgStyle = login?{}:{
|
|
||||||
'background': 'url(./image/header-bg-img.jpg) no-repeat',
|
|
||||||
'backgroundSize':'100% 100%'
|
|
||||||
};
|
|
||||||
const headerShadeStyle = login? {
|
|
||||||
'padding':'0'
|
|
||||||
}: {
|
|
||||||
'background': 'linear-gradient(to bottom,rgba(0,0,0,0.6),rgba(0,0,0,0.5))',
|
|
||||||
'padding':'0'
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
<acticle className={`header-box`} style={headerImgStyle}>
|
<Header className="header-box" style={headerStyle}>
|
||||||
<Header style={headerShadeStyle}>
|
<div className="content g-row">
|
||||||
<div className="content">
|
|
||||||
<div className="logo">
|
<div className="logo">
|
||||||
<Link to="/" onClick={this.relieveLink}>YAPI<span className="ui-badge"></span></Link>
|
<Link to="/" onClick={this.relieveLink}>
|
||||||
|
<img className="img" src="./image/logo_header@1x.png" /><span className="logo-name">YAPI<span className="ui-badge"></span></span>
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<Menu
|
|
||||||
mode="horizontal"
|
|
||||||
className="nav-toolbar"
|
|
||||||
theme="dark"
|
|
||||||
style={{
|
|
||||||
lineHeight : '.64rem',
|
|
||||||
backgroundColor:"transparent",
|
|
||||||
borderColor:"transparent"
|
|
||||||
}}
|
|
||||||
onClick={this.linkTo}
|
|
||||||
selectedKeys={[curKey]}
|
|
||||||
>
|
|
||||||
<Menu.Item key="/group">
|
|
||||||
<Link to="/group">项目广场</Link>
|
|
||||||
</Menu.Item>
|
|
||||||
<Menu.Item key="/doc">
|
|
||||||
<a target="_blank" href="./doc/index.html">使用文档</a>
|
|
||||||
</Menu.Item>
|
|
||||||
</Menu>
|
|
||||||
<div className="user-toolbar">
|
<div className="user-toolbar">
|
||||||
{login?
|
{login?
|
||||||
<ToolUser
|
<ToolUser
|
||||||
@ -197,7 +186,6 @@ export default class HeaderCom extends Component {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Header>
|
</Header>
|
||||||
</acticle>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,33 +6,28 @@ $color-blue : #108ee9;
|
|||||||
$color-blue-deeper: #34495E;
|
$color-blue-deeper: #34495E;
|
||||||
$color-grey-deep : #929aac;
|
$color-grey-deep : #929aac;
|
||||||
$color-black-light : #404040;
|
$color-black-light : #404040;
|
||||||
|
|
||||||
|
.nav-tooltip {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
/* .header-box.css */
|
/* .header-box.css */
|
||||||
.header-box {
|
.header-box {
|
||||||
@include wrap-width-limit;
|
|
||||||
display: block;
|
|
||||||
font-size: 0.14rem;
|
|
||||||
z-index: 99;
|
|
||||||
.content {
|
|
||||||
@include row-width-limit;
|
|
||||||
margin: 0 auto;
|
|
||||||
zoom: 1;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.logo {
|
.logo {
|
||||||
position: relative;
|
position: relative;
|
||||||
font-size: .3rem;
|
|
||||||
float: left;
|
float: left;
|
||||||
margin: 0 .2rem 0 0;
|
line-height: .54rem;
|
||||||
color: $color-white;
|
.logo-name {
|
||||||
//cursor: pointer;
|
|
||||||
a{
|
|
||||||
color: $color-white;
|
|
||||||
&:hover {
|
|
||||||
color: $color-white;
|
color: $color-white;
|
||||||
|
font-size: .24rem;
|
||||||
|
font-weight: 300;
|
||||||
|
margin-left: .38rem;
|
||||||
}
|
}
|
||||||
&:focus{
|
.img {
|
||||||
text-decoration: none;
|
position: absolute;
|
||||||
}
|
left: 0;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
}
|
}
|
||||||
.ui-badge {
|
.ui-badge {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -57,38 +52,30 @@ $color-black-light : #404040;
|
|||||||
|
|
||||||
.user-toolbar{
|
.user-toolbar{
|
||||||
float: right;
|
float: right;
|
||||||
height: .64rem;
|
height: .54rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
.item-search {
|
||||||
|
width: 2.4rem;
|
||||||
|
}
|
||||||
.toolbar-li{
|
.toolbar-li{
|
||||||
&:first-child{
|
|
||||||
width: 2rem;
|
|
||||||
}
|
|
||||||
float: left;
|
float: left;
|
||||||
margin: 0 0 0 .12rem;
|
font-size: .14rem;
|
||||||
font-size: .2rem;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: $color-white;
|
color: #ccc;
|
||||||
&:not(:last-child){
|
margin-left: .16rem;
|
||||||
margin: 0 .12rem;
|
transition: color .4s;
|
||||||
|
.dropdown-link {
|
||||||
|
color: #999;
|
||||||
|
transition: color .4s;
|
||||||
}
|
}
|
||||||
&:hover{
|
&:hover{
|
||||||
color: $color-blue;
|
.dropdown-link {
|
||||||
a{
|
color: #fff;
|
||||||
color: $color-blue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a{
|
.name {
|
||||||
color: $color-white;
|
margin-left: .08rem;
|
||||||
&:hover{
|
|
||||||
color: $color-blue;
|
|
||||||
}
|
|
||||||
&:focus{
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i{
|
|
||||||
margin-right: .03rem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,6 @@ export default class Srch extends Component{
|
|||||||
<AutoComplete
|
<AutoComplete
|
||||||
className="search-dropdown"
|
className="search-dropdown"
|
||||||
dataSource={dataSource}
|
dataSource={dataSource}
|
||||||
size="large"
|
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
defaultActiveFirstOption= {false}
|
defaultActiveFirstOption= {false}
|
||||||
onSelect={this.onSelect}
|
onSelect={this.onSelect}
|
||||||
@ -113,7 +112,6 @@ export default class Srch extends Component{
|
|||||||
>
|
>
|
||||||
<Input
|
<Input
|
||||||
prefix={<Icon type="search" className="srch-icon" />}
|
prefix={<Icon type="search" className="srch-icon" />}
|
||||||
size="large"
|
|
||||||
style={{}}
|
style={{}}
|
||||||
placeholder="搜索分组/项目"
|
placeholder="搜索分组/项目"
|
||||||
className="search-input"
|
className="search-input"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
$color-grey:#979DA7;
|
$color-grey:#979DA7;
|
||||||
|
|
||||||
.search-wrapper{
|
.search-wrapper{
|
||||||
|
cursor: auto;
|
||||||
.search-input{
|
.search-input{
|
||||||
width: 2rem;
|
width: 2rem;
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,15 @@ import QueueAnim from 'rc-queue-anim';
|
|||||||
const oneAnim = { y: '+=30', opacity: 0, type: 'from', ease: 'easeOutQuad' };
|
const oneAnim = { y: '+=30', opacity: 0, type: 'from', ease: 'easeOutQuad' };
|
||||||
const imgAnim = { y: '+=50', opacity: 0, type: 'from', ease: 'easeOutQuad', duration: '1500'};
|
const imgAnim = { y: '+=50', opacity: 0, type: 'from', ease: 'easeOutQuad', duration: '1500'};
|
||||||
const style = {
|
const style = {
|
||||||
// 'height':'100%',
|
|
||||||
// 'height':'7rem',
|
|
||||||
'width':'100%',
|
'width':'100%',
|
||||||
'background': 'url(./image/bg-img.jpg) no-repeat',
|
// 'background-image': 'linear-gradient(to right, #0063B3 0%, #2395F1 96%)',
|
||||||
|
'background-color': '#333',
|
||||||
'backgroundSize':'100% 100%'
|
'backgroundSize':'100% 100%'
|
||||||
}
|
}
|
||||||
const HomeGuest = (props) => (
|
const HomeGuest = (props) => (
|
||||||
<div>
|
<div>
|
||||||
<div className="main-one" style = {style}>
|
<div className="main-one" style = {style}>
|
||||||
<div style={{ background: "linear-gradient(to bottom,rgba(0,0,0,0.5),rgba(0,0,0,0.2))"}}>
|
<div>
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<Row>
|
<Row>
|
||||||
<Col span={24}>
|
<Col span={24}>
|
||||||
|
@ -60,3 +60,7 @@ em {
|
|||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 0 .24rem;
|
padding: 0 .24rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nav-tooltip {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
BIN
static/image/logo_header@1x.png
Normal file
BIN
static/image/logo_header@1x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
static/image/logo_header@2x.png
Normal file
BIN
static/image/logo_header@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
Loading…
Reference in New Issue
Block a user