Commit 54fe97c3 authored by 2breakegg's avatar 2breakegg

Merge branch 'master' of https://github.com/moecube/moecube-accounts-web

# Conflicts:
#	.idea/workspace.xml
parents 728d7e35 6da91abd
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
# misc # misc
.DS_Store .DS_Store
*.log* npm-debug.log*
/utils/config.js /utils/config.js
.idea/workspace.xml
This diff is collapsed.
let publicPath = 'https://cdn01.moecube.com/accounts/';
let publicPath = 'https://cdn01.moecube.com/accounts/'
const API_ROOT = { const API_ROOT = {
test: 'http://192.168.1.9:3000', development: 'http://192.168.1.9:3000',
dev: 'http://114.215.243.95:8082', test: 'http://114.215.243.95:8082',
prod: 'https://api.moeube.com/accounts' production: 'https://api.moeube.com/accounts'
} };
let defineConf = { let defineConf = {
apiRoot: API_ROOT[process.env["ENV"]], apiRoot: API_ROOT[process.env['ENV']],
} };
export default { export default {
"entry": "src/index.js", 'entry': 'src/index.js',
publicPath, publicPath,
define: {...defineConf}, define: { ...defineConf },
"env": { 'env': {
"development": { 'development': {
"extraBabelPlugins": [ 'extraBabelPlugins': [
"dva-hmr", 'dva-hmr',
"transform-runtime", 'transform-runtime',
["import", { "libraryName": "antd", "style": "css" }] ['import', { 'libraryName': 'antd', 'style': 'css' }]
] ]
}, },
"production": { 'production': {
"extraBabelPlugins": [ 'extraBabelPlugins': [
"transform-runtime", 'transform-runtime',
["import", { "libraryName": "antd", "style": "css" }] ['import', { 'libraryName': 'antd', 'style': 'css' }]
] ]
} }
} }
} };
language: node_js language: node_js
node_js: node node_js: node
env: env:
NODE_ENV: development
global: global:
secure: NObcZ6fY1VQuoDfxRxKVOZ+p7g3LTDkonG4Ow4HIbx2g8wJ24mMqs9gN0J3Asbdbz68isDMpkKy7IW1mK9+N9fM0pBauqD1YMbglnEv+HhYjhiEsQdRdDM2nzDIjS4PCwavI1Da5TLhaUjSAM4lrHx7bVOK4YsvF3s8JEApS54QgSlbeJgvSbPcCiapl0VwwaL36cGndChc3tawq4xseuk4bP2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5skg9LNa64KuDG46oopwGLiWkdRwDzG3VmXGwVm+OF2EWZi/B0wIcTwY=
script: npm run build script: npm run build:test
before_deploy: before_deploy:
- curl --location --retry 5 --output ossutil 'https://github.com/mycard/ossutil/releases/download/1.0.0.Beta2/ossutil' - curl --location --retry 5 --output ossutil 'https://github.com/mycard/ossutil/releases/download/1.0.0.Beta2/ossutil'
- chmod +x ossutil - chmod +x ossutil
......
{ {
"private": true, "private": true,
"scripts": { "scripts": {
"start": "cross-env ENV=test roadhog server", "start": "cross-env ENV=development roadhog server",
"build:dev": "cross-env ENV=dev roadhog build", "build:test": "cross-env ENV=test roadhog build",
"build": "cross-env ENV=prod roadhog build", "build": "cross-env ENV=production roadhog build",
"lint": "eslint --ext .js src test", "lint": "eslint --ext .js src test",
"precommit": "npm run lint" "precommit": "npm run lint"
}, },
......
import { Dropdown, Menu } from 'antd';
import { connect } from 'dva';
import { Link } from 'dva/router';
import React from 'react';
import { FormattedMessage as Format } from 'react-intl';
const defaultAvatar = require('../../public/default_avatar.jpg');
function UserPanel({ dispatch, user, token }) {
const { avatar } = user;
const menu = (
<Menu trigger={['click']}>
<Menu.Item>
{
// i18n
token ? <Link to="/profiles">个人中心</Link> : <Link to="/signin">登录</Link>
}
</Menu.Item>
<Menu.Divider/>
{
token &&
<Menu.Item >
<div
onClick={() => {
dispatch({ type: 'auth/signOut' });
}}
>
<Format id="sign-out"/>
</div>
</Menu.Item>
}
</Menu>
);
return (
<Dropdown overlay={menu} placement="bottomCenter">
<div className="ant-dropdown-link" style={{ display: 'flex', alignItems: 'center' }}>
<img
alt="avatar" src={avatar || defaultAvatar}
style={{ borderRadius: '40px', height: '40px', weight: 'auto' }}
/>
</div>
</Dropdown>
);
}
function mapStateToProps(state) {
const {
common: { messages, client, language },
user: { user, token },
} = state;
return {
token,
user,
language,
messages,
client,
};
}
export default connect(mapStateToProps)(UserPanel);
...@@ -17,6 +17,7 @@ import Reset from './routes/Reset.js'; ...@@ -17,6 +17,7 @@ import Reset from './routes/Reset.js';
import Verify from './routes/Verify.js'; import Verify from './routes/Verify.js';
function RouterConfig({ history }) { function RouterConfig({ history }) {
return ( return (
<Router history={history}> <Router history={history}>
......
...@@ -6,11 +6,12 @@ import DocumentTitle from 'react-document-title'; ...@@ -6,11 +6,12 @@ import DocumentTitle from 'react-document-title';
import { FormattedMessage as Format } from 'react-intl'; import { FormattedMessage as Format } from 'react-intl';
import Particles from 'react-particles-js'; import Particles from 'react-particles-js';
import logo from '../assets/MoeCube.png'; import logo from '../assets/MoeCube.png';
import UserPanel from '../components/UserPanel';
const languageMap = { const languageMap = {
'zh-CN': '中文', 'zh-CN': '中文',
'en-US': 'English', 'en-US': 'English',
} };
const { Header, Footer } = Layout; const { Header, Footer } = Layout;
const particleConfig = { const particleConfig = {
...@@ -127,30 +128,34 @@ const particleConfig = { ...@@ -127,30 +128,34 @@ const particleConfig = {
retina_detect: true, retina_detect: true,
}; };
function Index({ children, messages, dispatch, client, token, language }) { function Index({ children, messages, dispatch, client, language }) {
const menu = ( const menu = (
<Menu style={{ transform: 'translateX(-16px)' }}> <Menu style={{ transform: 'translateX(-16px)' }}>
{ {
Object.keys(languageMap).map((lan, i) => { Object.keys(languageMap).map((lan, i) => {
return ( return (
<Menu.Item key={i}> <Menu.Item key={i}>
<a onClick={() => { dispatch({ type: 'common/changeLanguage', payload: { language: lan } }) }}> <a
onClick={() => {
dispatch({ type: 'common/changeLanguage', payload: { language: lan } });
}}
>
{languageMap[lan]} {languageMap[lan]}
</a> </a>
</Menu.Item> </Menu.Item>
) );
}) })
} }
</Menu> </Menu>
); );
return ( return (
<div style={{ display: 'flex', flexDirection: 'column', flex: 1, minHeight: '100%' }}> <div style={{ display: 'flex', flexDirection: 'column', flex: 1, minHeight: '100%' }}>
<DocumentTitle title={messages.title || 'Moe Cube'} /> <DocumentTitle title={messages.title || 'Moe Cube'}/>
{client !== 'electron' && {client !== 'electron' &&
<Header style={{ display: 'flex', alignItems: 'center' }}> <Header style={{ display: 'flex', alignItems: 'center' }}>
<Link to="/" style={{ marginTop: '20px' }}> <Link to="/" style={{ marginTop: '20px' }}>
<img alt="logo" src={logo} style={{ width: '140px', height: '44px' }} /> <img alt="logo" src={logo} style={{ width: '140px', height: '44px' }}/>
</Link> </Link>
<Menu <Menu
...@@ -161,29 +166,14 @@ function Index({ children, messages, dispatch, client, token, language }) { ...@@ -161,29 +166,14 @@ function Index({ children, messages, dispatch, client, token, language }) {
> >
<Menu.Item key="1"> <Menu.Item key="1">
<Link to="/"> <Link to="/">
<Format id="Home" /> <Format id="Home"/>
</Link> </Link>
</Menu.Item> </Menu.Item>
</Menu> </Menu>
<Menu <div style={{ position: 'absolute', right: '40px' }}>
theme="dark" <UserPanel />
mode="horizontal"
defaultSelectedKeys={['1']}
style={{ lineHeight: '64px', position: 'absolute', right: '50px' }}
>
{token && (<Menu.Item key="1">
<div
onClick={() => {
dispatch({ type: 'auth/signOut' });
}}
>
<Format id="sign-out" />
</div> </div>
</Menu.Item>)
}
</Menu>
</Header> </Header>
} }
...@@ -198,7 +188,7 @@ function Index({ children, messages, dispatch, client, token, language }) { ...@@ -198,7 +188,7 @@ function Index({ children, messages, dispatch, client, token, language }) {
<Footer style={{ width: '100%', justifyContent: 'space-between', display: 'flex', zIndex: 100 }}> <Footer style={{ width: '100%', justifyContent: 'space-between', display: 'flex', zIndex: 100 }}>
<div><Dropdown overlay={menu} trigger={['click']}> <div><Dropdown overlay={menu} trigger={['click']}>
<a className="ant-dropdown-link changelanguage"> <a className="ant-dropdown-link changelanguage">
{languageMap[language]} <Icon type="down" className="flag" /> {languageMap[language]} <Icon type="down" className="flag"/>
</a> </a>
</Dropdown></div> </Dropdown></div>
<div>© MoeCube 2017 all right reserved.</div> <div>© MoeCube 2017 all right reserved.</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment