Commit d317d3ca authored by nano's avatar nano

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/routes/Index.js
parent db292f14
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
"rules": { "rules": {
"react/jsx-space-before-closing":[0], "react/jsx-space-before-closing":[0],
"generator-star-spacing": [0], "generator-star-spacing": [0],
"semi":[0],
"no-console":[0],
"consistent-return": [0], "consistent-return": [0],
"react/forbid-prop-types": [0], "react/forbid-prop-types": [0],
"react/jsx-filename-extension": [1, { "extensions": [".js"] }], "react/jsx-filename-extension": [1, { "extensions": [".js"] }],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
language: node_js
node_js: node
env:
NODE_ENV: development
global:
secure: NObcZ6fY1VQuoDfxRxKVOZ+p7g3LTDkonG4Ow4HIbx2g8wJ24mMqs9gN0J3Asbdbz68isDMpkKy7IW1mK9+N9fM0pBauqD1YMbglnEv+HhYjhiEsQdRdDM2nzDIjS4PCwavI1Da5TLhaUjSAM4lrHx7bVOK4YsvF3s8JEApS54QgSlbeJgvSbPcCiapl0VwwaL36cGndChc3tawq4xseuk4bP2NrTEd7ifYZMt+iojId+UuhRQk4w0HUlBhEDKiT/fLxeQDwMRv2WIdIPW7D7+Wo01iX+T0Ti629QhQBe/S76affkG6G085HIPin3VvXDQaiYbK4ALbc79O+9jqSxEFd9nwG8xbp2jezzvclUSXPhIyZe7VSRS6z1MdevlyQa56AUEP7My7IMqj8j7NPoUgrnVlKtR8WPHQacfAVkrcOIX+Tzwl2IMOCqonamDtJjUNX5xpYB+IEj+INvQmRqT2NicExGWj9LZp3L3kscwq1u+0hPzgoQ9yovE+OvLFNE/R5AE90GIaSlwXw4MqOeB+8l+ou2JzNZFJhHBvAsOFwQTloFz/pu7ichJ+P0KsMPteLFA4Btuo6bBu31K7R310CmlIdYJIeeybMuM6e6bG8IkbVcMq5skg9LNa64KuDG46oopwGLiWkdRwDzG3VmXGwVm+OF2EWZi/B0wIcTwY=
script: npm run build
before_deploy:
- curl --location --retry 5 --output ossutil 'https://github.com/mycard/ossutil/releases/download/1.0.0.Beta2/ossutil'
- chmod +x ossutil
- ./ossutil config --endpoint oss-cn-hangzhou.aliyuncs.com --access-key-id $ALIYUN_ID
--access-key-secret $ALIYUN_SECRET
deploy:
provider: script
script: ./ossutil cp -rf dist oss://mycard/accounts
skip_cleanup: true
on:
branch: master
...@@ -4,6 +4,7 @@ import i18n from '../../i18n.json'; ...@@ -4,6 +4,7 @@ import i18n from '../../i18n.json';
export default { export default {
namespace: 'common', namespace: 'common',
state: { state: {
client: '',
language: 'zh-CN', language: 'zh-CN',
messages: {}, messages: {},
}, },
...@@ -13,16 +14,28 @@ export default { ...@@ -13,16 +14,28 @@ export default {
...state, ...action.payload, ...state, ...action.payload,
}; };
}, },
changeLanguage(state, { payload: id }) {
localStorage.setItem('locale', id.id);
history.go(0);
return state;
},
}, },
effects: {}, effects: {},
subscriptions: { subscriptions: {
setup({ dispatch }) { setup({ dispatch }) {
let client;
const language = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage; const language = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0]; const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0];
const messages = i18n[languageWithoutRegionCode]; const messages = i18n[languageWithoutRegionCode];
dispatch({ type: 'init', payload: { language: languageWithoutRegionCode, messages } }); const { userAgent } = navigator;
if (userAgent.includes('Electron')) {
client = 'electron';
}
dispatch({ type: 'init', payload: { language: languageWithoutRegionCode, messages, client } });
}, },
}, },
}; };
...@@ -204,19 +204,17 @@ export default { ...@@ -204,19 +204,17 @@ export default {
const token = localStorage.getItem('token'); const token = localStorage.getItem('token');
if (token) { if (token) {
dispatch({ type: 'getAuthUser', payload: { token } }); dispatch({ type: 'getAuthUser', payload: { token } });
} else { } else if (location.pathname === '/profiles') {
if(location.pathname == '/profiles') { dispatch(routerRedux.replace('/signin'));
dispatch(routerRedux.replace('/signin'))
}
} }
history.listen(({ pathname, query }) => { history.listen(({ pathname, query }) => {
if (pathname === '/') { if (pathname === '/') {
dispatch({ type: 'preLogin', payload: { token } }); dispatch({ type: 'preLogin', payload: { token } });
} }
if (pathname === '/reset' || pathname == "/activate"){ if (pathname === '/reset' || pathname === '/activate') {
if (!query["key"]) { if (!query.key) {
message.error("缺少参数") message.error('缺少参数');
} }
} }
}); });
......
...@@ -14,7 +14,7 @@ class Active extends React.Component { ...@@ -14,7 +14,7 @@ class Active extends React.Component {
render() { render() {
const { loading } = this.props; const { loading } = this.props;
return ( return (
<div style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}> <div style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}>
<Button type="primary" icon="poweroff" loading={loading} onClick={this.handleClick}> <Button type="primary" icon="poweroff" loading={loading} onClick={this.handleClick}>
<Format id={'verify-email'}/> <Format id={'verify-email'}/>
</Button> </Button>
......
...@@ -35,7 +35,7 @@ class Login extends React.Component { ...@@ -35,7 +35,7 @@ class Login extends React.Component {
const { loading } = this.props; const { loading } = this.props;
const { intl: { messages } } = this.context; const { intl: { messages } } = this.context;
return ( return (
<div style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}> <div style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}>
<Spin spinning={loading} delay={100}> <Spin spinning={loading} delay={100}>
<Form onSubmit={this.onSubmitLogin} className="login-form"> <Form onSubmit={this.onSubmitLogin} className="login-form">
......
import { Layout, Menu } from 'antd'; import { Dropdown, Icon, Layout, Menu } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import { Link } from 'dva/router'; import { Link } from 'dva/router';
import React from 'react'; import React from 'react';
...@@ -122,11 +122,33 @@ const particleConfig = { ...@@ -122,11 +122,33 @@ const particleConfig = {
retina_detect: true, retina_detect: true,
}; };
function Index({ children, messages, dispatch }) { function Index({ children, messages, dispatch, client }) {
const language = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage || navigator.browserLanguage || 'zh-CN';
const menu = (
<Menu style={{ transform: 'translateX(-16px)' }}>
<Menu.Item key="0">
<a
onClick={() => {
dispatch({ type: 'common/changeLanguage', payload: { id: 'en-US' } });
}}
>
&nbsp;English</a>
</Menu.Item>
<Menu.Item key="1">
<a
onClick={() => {
dispatch({ type: 'common/changeLanguage', payload: { id: 'zh-EN' } });
}}
>
&nbsp;中文</a>
</Menu.Item>
</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' &&
<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' }}/>
...@@ -161,8 +183,21 @@ function Index({ children, messages, dispatch }) { ...@@ -161,8 +183,21 @@ function Index({ children, messages, dispatch }) {
</div> </div>
</Menu.Item>) : ('') </Menu.Item>) : ('')
} }
<Menu.Item key="2">
<Dropdown overlay={menu} trigger={['click']}>
{language === 'en-US' ?
<a className="ant-dropdown-link changelanguage">
&nbsp;English <Icon type="down" className="flag"/>
</a> : <a className="ant-dropdown-link changelanguage">
&nbsp;中文 <Icon type="down" className="flag"/>
</a>
}
</Dropdown>
</Menu.Item>
</Menu> </Menu>
</Header> </Header>
}
<Particles <Particles
params={particleConfig} params={particleConfig}
...@@ -181,10 +216,11 @@ function Index({ children, messages, dispatch }) { ...@@ -181,10 +216,11 @@ function Index({ children, messages, dispatch }) {
function mapStateToProps(state) { function mapStateToProps(state) {
const { const {
common: { messages }, common: { messages, client },
} = state; } = state;
return { return {
messages, messages,
client,
}; };
} }
......
...@@ -101,29 +101,31 @@ class Profiles extends React.Component { ...@@ -101,29 +101,31 @@ class Profiles extends React.Component {
<Form onSubmit={this.onUpdateSubmit}> <Form onSubmit={this.onUpdateSubmit}>
<FormItem style={{ display: 'flex', justifyContent: 'center' }}> <FormItem style={{ display: 'flex', justifyContent: 'center' }}>
<div style={{ display: isUpload ? 'flex' : 'none', flexDirection: 'column'}}> <div style={{ display: isUpload ? 'flex' : 'none', flexDirection: 'column' }}>
<Cropper <Cropper
ref={cropper => { ref={(cropper) => {
this.cropper = cropper; this.cropper = cropper;
}} }}
src={ imageUrl || defaultAvatar} src={imageUrl || defaultAvatar}
style={{ height: '20vw', width: '20vw' }} style={{ height: '20vw', width: '20vw' }}
aspectRatio={1 / 1} aspectRatio={1 / 1}
guides={true} guides
/> />
<Button type="primary" onClick={this.handleUpload}> <Button type="primary" onClick={this.handleUpload}>
<Icon type="upload"/> upload <Icon type="upload"/> upload
</Button> </Button>
</div> </div>
<div style={{ display: !isUpload ? 'flex' : 'none', flexDirection: 'column'}}> <div style={{ display: !isUpload ? 'flex' : 'none', flexDirection: 'column' }}>
<img src={avatar || imageUrl || defaultAvatar}/> <img alt="avatar" src={avatar || imageUrl || defaultAvatar}/>
<Button onClick={() => { dispatch({ type: 'upload/start' }) }}> <Button onClick={() => { dispatch({ type: 'upload/start' }); }}>
<label> <label>
<Icon type="plus"/> Change Avatar <Icon type="plus"/> Change Avatar
<input type="file" onChange={this.onGetFile} ref={file => { <input
this.file = file; type="file" onChange={this.onGetFile} ref={(file) => {
}} style={{ display: 'none' }}/> this.file = file;
}} style={{ display: 'none' }}
/>
</label> </label>
</Button> </Button>
</div> </div>
......
...@@ -60,12 +60,12 @@ class Register extends React.Component { ...@@ -60,12 +60,12 @@ class Register extends React.Component {
const emailProps = { const emailProps = {
hasFeedback: true, hasFeedback: true,
validateStatus: checkEmail, validateStatus: checkEmail,
extra: isEmailExists ? messages['i_email_exists'] : '', extra: isEmailExists ? messages.i_email_exists : '',
}; };
const emailInputProps = { const emailInputProps = {
onBlur: () => !form.getFieldError("email") && dispatch({ type: 'auth/checkEmail', payload: { ...form.getFieldsValue() } }), onBlur: () => !form.getFieldError('email') && dispatch({ type: 'auth/checkEmail', payload: { ...form.getFieldsValue() } }),
placeholder: messages.email, placeholder: messages.email,
}; };
...@@ -76,12 +76,12 @@ class Register extends React.Component { ...@@ -76,12 +76,12 @@ class Register extends React.Component {
}; };
const usernameInputProps = { const usernameInputProps = {
onBlur: () => !form.getFieldError("username") && dispatch({ type: 'auth/checkUsername', payload: { ...form.getFieldsValue() } }), onBlur: () => !form.getFieldError('username') && dispatch({ type: 'auth/checkUsername', payload: { ...form.getFieldsValue() } }),
placeholder: messages.username, placeholder: messages.username,
}; };
return ( return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}> <div style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}>
<Spin spinning={loading} delay={100}> <Spin spinning={loading} delay={100}>
<Steps size="large" current={0}> <Steps size="large" current={0}>
......
...@@ -51,7 +51,7 @@ class Reset extends React.Component { ...@@ -51,7 +51,7 @@ class Reset extends React.Component {
const { intl: { messages } } = this.context; const { intl: { messages } } = this.context;
return ( return (
<div style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}> <div style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}>
<Spin spinning={isResetSubmit} delay={100}> <Spin spinning={isResetSubmit} delay={100}>
<Form onSubmit={this.onSubmitReset} className="login-form"> <Form onSubmit={this.onSubmitReset} className="login-form">
<FormItem> <FormItem>
......
...@@ -69,7 +69,8 @@ class Verify extends React.Component { ...@@ -69,7 +69,8 @@ class Verify extends React.Component {
return ( return (
<div <div
style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}> style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}
>
<Spin spinning={loading} delay={100}> <Spin spinning={loading} delay={100}>
<Steps size="large" current={1}> <Steps size="large" current={1}>
......
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