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 @@
"rules": {
"react/jsx-space-before-closing":[0],
"generator-star-spacing": [0],
"semi":[0],
"no-console":[0],
"consistent-return": [0],
"react/forbid-prop-types": [0],
"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';
export default {
namespace: 'common',
state: {
client: '',
language: 'zh-CN',
messages: {},
},
......@@ -13,16 +14,28 @@ export default {
...state, ...action.payload,
};
},
changeLanguage(state, { payload: id }) {
localStorage.setItem('locale', id.id);
history.go(0);
return state;
},
},
effects: {},
subscriptions: {
setup({ dispatch }) {
let client;
const language = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0];
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 {
const token = localStorage.getItem('token');
if (token) {
dispatch({ type: 'getAuthUser', payload: { token } });
} else {
if(location.pathname == '/profiles') {
dispatch(routerRedux.replace('/signin'))
}
} else if (location.pathname === '/profiles') {
dispatch(routerRedux.replace('/signin'));
}
history.listen(({ pathname, query }) => {
if (pathname === '/') {
dispatch({ type: 'preLogin', payload: { token } });
}
if (pathname === '/reset' || pathname == "/activate"){
if (!query["key"]) {
message.error("缺少参数")
if (pathname === '/reset' || pathname === '/activate') {
if (!query.key) {
message.error('缺少参数');
}
}
});
......
......@@ -14,7 +14,7 @@ class Active extends React.Component {
render() {
const { loading } = this.props;
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}>
<Format id={'verify-email'}/>
</Button>
......
......@@ -35,7 +35,7 @@ class Login extends React.Component {
const { loading } = this.props;
const { intl: { messages } } = this.context;
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}>
<Form onSubmit={this.onSubmitLogin} className="login-form">
......
import { Layout, Menu } from 'antd';
import { Dropdown, Icon, Layout, Menu } from 'antd';
import { connect } from 'dva';
import { Link } from 'dva/router';
import React from 'react';
......@@ -122,11 +122,33 @@ const particleConfig = {
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 (
<div style={{ display: 'flex', flexDirection: 'column', flex: 1, minHeight: '100%' }}>
<DocumentTitle title={messages.title || 'Moe Cube'}/>
{client !== 'electron' &&
<Header style={{ display: 'flex', alignItems: 'center' }}>
<Link to="/" style={{ marginTop: '20px' }}>
<img alt="logo" src={logo} style={{ width: '140px', height: '44px' }}/>
......@@ -161,8 +183,21 @@ function Index({ children, messages, dispatch }) {
</div>
</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>
</Header>
}
<Particles
params={particleConfig}
......@@ -181,10 +216,11 @@ function Index({ children, messages, dispatch }) {
function mapStateToProps(state) {
const {
common: { messages },
common: { messages, client },
} = state;
return {
messages,
client,
};
}
......
......@@ -101,29 +101,31 @@ class Profiles extends React.Component {
<Form onSubmit={this.onUpdateSubmit}>
<FormItem style={{ display: 'flex', justifyContent: 'center' }}>
<div style={{ display: isUpload ? 'flex' : 'none', flexDirection: 'column'}}>
<div style={{ display: isUpload ? 'flex' : 'none', flexDirection: 'column' }}>
<Cropper
ref={cropper => {
ref={(cropper) => {
this.cropper = cropper;
}}
src={ imageUrl || defaultAvatar}
src={imageUrl || defaultAvatar}
style={{ height: '20vw', width: '20vw' }}
aspectRatio={1 / 1}
guides={true}
guides
/>
<Button type="primary" onClick={this.handleUpload}>
<Icon type="upload"/> upload
</Button>
</div>
<div style={{ display: !isUpload ? 'flex' : 'none', flexDirection: 'column'}}>
<img src={avatar || imageUrl || defaultAvatar}/>
<Button onClick={() => { dispatch({ type: 'upload/start' }) }}>
<div style={{ display: !isUpload ? 'flex' : 'none', flexDirection: 'column' }}>
<img alt="avatar" src={avatar || imageUrl || defaultAvatar}/>
<Button onClick={() => { dispatch({ type: 'upload/start' }); }}>
<label>
<Icon type="plus"/> Change Avatar
<input type="file" onChange={this.onGetFile} ref={file => {
this.file = file;
}} style={{ display: 'none' }}/>
<input
type="file" onChange={this.onGetFile} ref={(file) => {
this.file = file;
}} style={{ display: 'none' }}
/>
</label>
</Button>
</div>
......
......@@ -60,12 +60,12 @@ class Register extends React.Component {
const emailProps = {
hasFeedback: true,
validateStatus: checkEmail,
extra: isEmailExists ? messages['i_email_exists'] : '',
extra: isEmailExists ? messages.i_email_exists : '',
};
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,
};
......@@ -76,12 +76,12 @@ class Register extends React.Component {
};
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,
};
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}>
<Steps size="large" current={0}>
......
......@@ -51,7 +51,7 @@ class Reset extends React.Component {
const { intl: { messages } } = this.context;
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}>
<Form onSubmit={this.onSubmitReset} className="login-form">
<FormItem>
......
......@@ -69,7 +69,8 @@ class Verify extends React.Component {
return (
<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}>
<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