Commit 117ab072 authored by duanledexianxianxian's avatar duanledexianxianxian

sync code

parent fd05c0a9
......@@ -4,17 +4,17 @@ import slash from 'slash2';
import { IPlugin, IConfig } from 'umi-types';
import defaultSettings from './defaultSettings';
import webpackPlugin from './plugin.config'; // webpack相关配置
import routes from './routes.config';
import theme from './theme.config';
const path = require('path');
const { pwa } = defaultSettings;
const path = require('path');
// preview.pro.ant.design only do not use in your production ;
const { pwa } = defaultSettings; // preview.pro.ant.design only do not use in your production ;
// preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, TEST, NODE_ENV } = process.env;
// 插件设置
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, TEST, NODE_ENV } = process.env; // 插件设置
const plugins: IPlugin[] = [
[
'umi-plugin-react',
......@@ -88,7 +88,6 @@ const uglifyJSOptions =
},
}
: {};
export default {
// add for transfer to umi
plugins,
......@@ -106,7 +105,102 @@ export default {
// 打包后源码 umi已经根据不同环境有默认的源码生成规则
devtool: false,
// 路由配置
routes,
routes: [
{
path: '/',
component: '../layouts/BlankLayout',
routes: [
{
path: '/user',
component: '../layouts/UserLayout',
routes: [
{
path: '/user',
redirect: '/user/login',
},
{
name: 'login',
path: '/user/login',
component: './user/login',
},
],
},
{
path: '/',
component: '../layouts/BasicLayout',
Routes: ['src/pages/Authorized'],
authority: ['admin', 'user'],
routes: [
{
path: '/dashboard',
name: 'dashboard',
icon: 'dashboard',
routes: [],
},
{
path: '/form',
icon: 'form',
name: 'form',
routes: [],
},
{
path: '/list',
icon: 'table',
name: 'list',
routes: [
{
path: '/list/search',
name: 'search-list',
component: './list/search',
routes: [
{
path: '/list/search',
redirect: '/list/search/articles',
},
],
},
],
},
{
path: '/profile',
name: 'profile',
icon: 'profile',
routes: [],
},
{
name: 'result',
icon: 'check-circle-o',
path: '/result',
routes: [],
},
{
name: 'exception',
icon: 'warning',
path: '/exception',
routes: [],
},
{
name: 'account',
icon: 'user',
path: '/account',
routes: [],
},
{
name: 'editor',
icon: 'highlight',
path: '/editor',
routes: [],
},
{
path: '/',
redirect: '/dashboard/analysis',
authority: ['admin', 'user'],
},
],
},
],
},
],
// Theme for antd
// https://ant.design/docs/react/customize-theme-cn
theme,
......@@ -129,7 +223,7 @@ export default {
resourcePath: string;
},
localIdentName: string,
localName: string,
localName: string
) => {
if (
context.resourcePath.includes('node_modules') ||
......
......@@ -36,8 +36,7 @@
"tslint:fix": "tslint --fix 'src/**/*.ts*'"
},
"husky": {
"hooks": {
}
"hooks": {}
},
"lint-staged": {
"**/*.less": "stylelint --syntax less",
......@@ -59,10 +58,12 @@
"antd": "^3.16.1",
"classnames": "^2.2.6",
"dva": "^2.4.0",
"hash.js": "^1.1.5",
"lodash": "^4.17.10",
"lodash-decorators": "^6.0.0",
"memoize-one": "^5.0.0",
"moment": "^2.22.2",
"nzh": "^1.0.3",
"omit.js": "^1.0.0",
"path-to-regexp": "^3.0.0",
"prop-types": "^15.7.2",
......@@ -75,6 +76,7 @@
"react-dom": "^16.7.0",
"react-media": "^1.9.2",
"react-media-hook2": "^1.0.2",
"redux": "^4.0.1",
"umi": "^2.7.0-beta.2",
"umi-plugin-ga": "^1.1.3",
"umi-plugin-locale": "^2.8.0-beta.1",
......@@ -102,13 +104,13 @@
"eslint": "^5.13.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.1.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-compat": "^3.1.1",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-markdown": "^1.0.0",
"eslint-plugin-react": "^7.12.4",
"eslint-import-resolver-alias":"^1.1.2",
"express": "^4.16.4",
"gh-pages": "^2.0.1",
"husky": "^2.2.0",
......
......@@ -5,37 +5,33 @@ import { ClickParam } from 'antd/es/menu';
import classNames from 'classnames';
import HeaderDropdown from '../HeaderDropdown';
import styles from './index.less';
interface localesProps {
label: string;
key: string;
icon: string;
}
interface SelectLangProps {
className?: string;
locales?: Array<localesProps>;
}
const SelectLang: React.FC<SelectLangProps> = props => {
const { className } = props;
const { className, locales } = props;
// 获取当前语言
const selectedLang = getLocale();
const changeLang = ({ key }: ClickParam) => setLocale(key, false);
const locales = ['zh-CN', 'zh-TW', 'en-US', 'pt-BR'];
const languageLabels = {
'zh-CN': '简体中文',
'zh-TW': '繁体中文',
'en-US': 'English',
'pt-BR': 'Português',
};
const languageIcons = {
'zh-CN': '🇨🇳',
'zh-TW': '🇭🇰',
'en-US': '🇬🇧',
'pt-BR': '🇧🇷',
};
const langMenu = (
<Menu className={styles.menu} selectedKeys={[selectedLang]} onClick={changeLang}>
{locales.map(locale => (
<Menu.Item key={locale}>
<span role="img" aria-label={languageLabels[locale]}>
{languageIcons[locale]}
</span>{' '}
{languageLabels[locale]}
</Menu.Item>
))}
{locales &&
locales.map(({ label, key, icon }) => (
<Menu.Item key={key}>
<span role="img" aria-label={label}>
{icon}
</span>{' '}
{label}
</Menu.Item>
))}
</Menu>
);
return (
......
/**
* app相关配置
*/
console.log(process.env.name);
console.log(process.env.APP_NAME);
export default {
appName: process.env.APP_NAME,
locales: [
{
lable: '简体中文',
key: 'zh-CN',
icon: '🇨🇳',
},
{
lable: 'English',
key: 'en-US',
icon: '🇬🇧',
},
],
};
......@@ -9,7 +9,7 @@ import Link from 'umi/link';
import logo from '../assets/logo.svg';
import styles from './UserLayout.less';
import { MenuDataItem, getPageTitle, getMenuData } from '@ant-design/pro-layout';
import config from '@/config';
const links = [
{
key: 'help',
......@@ -59,7 +59,7 @@ class UserLayout extends Component<UserLayoutProps> {
>
<div className={styles.container}>
<div className={styles.lang}>
<SelectLang />
<SelectLang locales={config.locales} />
</div>
<div className={styles.content}>
<div className={styles.top}>
......
import globalHeader from './pt-BR/globalHeader';
import menu from './pt-BR/menu';
import settingDrawer from './pt-BR/settingDrawer';
import settings from './pt-BR/settings';
import pwa from './pt-BR/pwa';
import component from './pt-BR/component';
export default {
'navBar.lang': 'Idiomas',
'layout.user.link.help': 'ajuda',
'layout.user.link.privacy': 'política de privacidade',
'layout.user.link.terms': 'termos de serviços',
'app.preview.down.block': 'Download this page to your local project',
...globalHeader,
...menu,
...settingDrawer,
...settings,
...pwa,
...component,
};
export default {
'component.tagSelect.expand': 'Expandir',
'component.tagSelect.collapse': 'Diminuir',
'component.tagSelect.all': 'Todas',
};
export default {
'component.globalHeader.search': 'Busca',
'component.globalHeader.search.example1': 'Exemplo de busca 1',
'component.globalHeader.search.example2': 'Exemplo de busca 2',
'component.globalHeader.search.example3': 'Exemplo de busca 3',
'component.globalHeader.help': 'Ajuda',
'component.globalHeader.notification': 'Notificação',
'component.globalHeader.notification.empty': 'Você visualizou todas as notificações.',
'component.globalHeader.message': 'Mensagem',
'component.globalHeader.message.empty': 'Você visualizou todas as mensagens.',
'component.globalHeader.event': 'Evento',
'component.globalHeader.event.empty': 'Você visualizou todos os eventos.',
'component.noticeIcon.clear': 'Limpar',
'component.noticeIcon.cleared': 'Limpo',
'component.noticeIcon.empty': 'Sem notificações',
'component.noticeIcon.loaded': 'Carregado',
'component.noticeIcon.view-more': 'Veja mais',
};
export default {
'menu.welcome': 'Welcome',
'menu.more-blocks': 'More Blocks',
'menu.home': 'Início',
'menu.login': 'Login',
'menu.register': 'Registro',
'menu.register.result': 'Resultado de registro',
'menu.dashboard': 'Dashboard',
'menu.dashboard.analysis': 'Análise',
'menu.dashboard.monitor': 'Monitor',
'menu.dashboard.workplace': 'Ambiente de Trabalho',
'menu.exception.403': '403',
'menu.exception.404': '404',
'menu.exception.500': '500',
'menu.form': 'Formulário',
'menu.form.basic-form': 'Formulário Básico',
'menu.form.step-form': 'Formulário Assistido',
'menu.form.step-form.info': 'Formulário Assistido(gravar informações de transferência)',
'menu.form.step-form.confirm': 'Formulário Assistido(confirmar informações de transferência)',
'menu.form.step-form.result': 'Formulário Assistido(finalizado)',
'menu.form.advanced-form': 'Formulário Avançado',
'menu.list': 'Lista',
'menu.list.table-list': 'Tabela de Busca',
'menu.list.basic-list': 'Lista Básica',
'menu.list.card-list': 'Lista de Card',
'menu.list.search-list': 'Lista de Busca',
'menu.list.search-list.articles': 'Lista de Busca(artigos)',
'menu.list.search-list.projects': 'Lista de Busca(projetos)',
'menu.list.search-list.applications': 'Lista de Busca(aplicações)',
'menu.profile': 'Perfil',
'menu.profile.basic': 'Perfil Básico',
'menu.profile.advanced': 'Perfil Avançado',
'menu.result': 'Resultado',
'menu.result.success': 'Sucesso',
'menu.result.fail': 'Falha',
'menu.exception': 'Exceção',
'menu.exception.not-permission': '403',
'menu.exception.not-find': '404',
'menu.exception.server-error': '500',
'menu.exception.trigger': 'Disparar',
'menu.account': 'Conta',
'menu.account.center': 'Central da Conta',
'menu.account.settings': 'Configurar Conta',
'menu.account.trigger': 'Disparar Erro',
'menu.account.logout': 'Sair',
'menu.editor': 'Graphic Editor',
'menu.editor.flow': 'Flow Editor',
'menu.editor.mind': 'Mind Editor',
'menu.editor.koni': 'Koni Editor',
};
export default {
'app.pwa.offline': 'Você está offline agora',
'app.pwa.serviceworker.updated': 'Novo conteúdo está disponível',
'app.pwa.serviceworker.updated.hint':
'Por favor, pressione o botão "Atualizar" para recarregar a página atual',
'app.pwa.serviceworker.updated.ok': 'Atualizar',
};
export default {
'app.setting.pagestyle': 'Configuração de estilo da página',
'app.setting.pagestyle.dark': 'Dark style',
'app.setting.pagestyle.light': 'Light style',
'app.setting.content-width': 'Largura do conteúdo',
'app.setting.content-width.fixed': 'Fixo',
'app.setting.content-width.fluid': 'Fluido',
'app.setting.themecolor': 'Cor do Tema',
'app.setting.themecolor.dust': 'Dust Red',
'app.setting.themecolor.volcano': 'Volcano',
'app.setting.themecolor.sunset': 'Sunset Orange',
'app.setting.themecolor.cyan': 'Cyan',
'app.setting.themecolor.green': 'Polar Green',
'app.setting.themecolor.daybreak': 'Daybreak Blue (default)',
'app.setting.themecolor.geekblue': 'Geek Glue',
'app.setting.themecolor.purple': 'Golden Purple',
'app.setting.navigationmode': 'Modo de Navegação',
'app.setting.sidemenu': 'Layout do Menu Lateral',
'app.setting.topmenu': 'Layout do Menu Superior',
'app.setting.fixedheader': 'Cabeçalho fixo',
'app.setting.fixedsidebar': 'Barra lateral fixa',
'app.setting.fixedsidebar.hint': 'Funciona no layout do menu lateral',
'app.setting.hideheader': 'Esconder o cabeçalho quando rolar',
'app.setting.hideheader.hint': 'Funciona quando o esconder cabeçalho está abilitado',
'app.setting.othersettings': 'Outras configurações',
'app.setting.weakmode': 'Weak Mode',
'app.setting.copy': 'Copiar Configuração',
'app.setting.copyinfo':
'copiado com sucesso,por favor trocar o defaultSettings em src/models/setting.js',
'app.setting.production.hint':
'O painel de configuração apenas é exibido no ambiente de desenvolvimento, por favor modifique manualmente o',
};
export default {
'app.settings.menuMap.basic': 'Configurações Básicas',
'app.settings.menuMap.security': 'Configurações de Segurança',
'app.settings.menuMap.binding': 'Vinculação de Conta',
'app.settings.menuMap.notification': 'Mensagens de Notificação',
'app.settings.basic.avatar': 'Avatar',
'app.settings.basic.change-avatar': 'Alterar avatar',
'app.settings.basic.email': 'Email',
'app.settings.basic.email-message': 'Por favor insira seu email!',
'app.settings.basic.nickname': 'Nome de usuário',
'app.settings.basic.nickname-message': 'Por favor insira seu nome de usuário!',
'app.settings.basic.profile': 'Perfil pessoal',
'app.settings.basic.profile-message': 'Por favor insira seu perfil pessoal!',
'app.settings.basic.profile-placeholder': 'Breve introdução sua',
'app.settings.basic.country': 'País/Região',
'app.settings.basic.country-message': 'Por favor insira país!',
'app.settings.basic.geographic': 'Província, estado ou cidade',
'app.settings.basic.geographic-message': 'Por favor insira suas informações geográficas!',
'app.settings.basic.address': 'Endereço',
'app.settings.basic.address-message': 'Por favor insira seu endereço!',
'app.settings.basic.phone': 'Número de telefone',
'app.settings.basic.phone-message': 'Por favor insira seu número de telefone!',
'app.settings.basic.update': 'Atualizar Informações',
'app.settings.security.strong': 'Forte',
'app.settings.security.medium': 'Média',
'app.settings.security.weak': 'Fraca',
'app.settings.security.password': 'Senha da Conta',
'app.settings.security.password-description': 'Força da senha',
'app.settings.security.phone': 'Telefone de Seguraça',
'app.settings.security.phone-description': 'Telefone vinculado',
'app.settings.security.question': 'Pergunta de Segurança',
'app.settings.security.question-description':
'A pergunta de segurança não está definida e a política de segurança pode proteger efetivamente a segurança da conta',
'app.settings.security.email': 'Email de Backup',
'app.settings.security.email-description': 'Email vinculado',
'app.settings.security.mfa': 'Dispositivo MFA',
'app.settings.security.mfa-description':
'O dispositivo MFA não vinculado, após a vinculação, pode ser confirmado duas vezes',
'app.settings.security.modify': 'Modificar',
'app.settings.security.set': 'Atribuir',
'app.settings.security.bind': 'Vincular',
'app.settings.binding.taobao': 'Vincular Taobao',
'app.settings.binding.taobao-description': 'Atualmente não vinculado à conta Taobao',
'app.settings.binding.alipay': 'Vincular Alipay',
'app.settings.binding.alipay-description': 'Atualmente não vinculado à conta Alipay',
'app.settings.binding.dingding': 'Vincular DingTalk',
'app.settings.binding.dingding-description': 'Atualmente não vinculado à conta DingTalk',
'app.settings.binding.bind': 'Vincular',
'app.settings.notification.password': 'Senha da Conta',
'app.settings.notification.password-description':
'Mensagens de outros usuários serão notificadas na forma de uma estação de letra',
'app.settings.notification.messages': 'Mensagens de Sistema',
'app.settings.notification.messages-description':
'Mensagens de sistema serão notificadas na forma de uma estação de letra',
'app.settings.notification.todo': 'Notificação de To-do',
'app.settings.notification.todo-description':
'A lista de to-do será notificada na forma de uma estação de letra',
'app.settings.open': 'Aberto',
'app.settings.close': 'Fechado',
};
import globalHeader from './zh-TW/globalHeader';
import menu from './zh-TW/menu';
import settingDrawer from './zh-TW/settingDrawer';
import settings from './zh-TW/settings';
import pwa from './zh-TW/pwa';
import component from './zh-TW/component';
export default {
'navBar.lang': '語言',
'layout.user.link.help': '幫助',
'layout.user.link.privacy': '隱私',
'layout.user.link.terms': '條款',
'app.preview.down.block': '下載此頁面到本地項目',
...globalHeader,
...menu,
...settingDrawer,
...settings,
...pwa,
...component,
};
export default {
'component.tagSelect.expand': '展開',
'component.tagSelect.collapse': '收起',
'component.tagSelect.all': '全部',
};
export default {
'component.globalHeader.search': '站內搜索',
'component.globalHeader.search.example1': '搜索提示壹',
'component.globalHeader.search.example2': '搜索提示二',
'component.globalHeader.search.example3': '搜索提示三',
'component.globalHeader.help': '使用手冊',
'component.globalHeader.notification': '通知',
'component.globalHeader.notification.empty': '妳已查看所有通知',
'component.globalHeader.message': '消息',
'component.globalHeader.message.empty': '您已讀完所有消息',
'component.globalHeader.event': '待辦',
'component.globalHeader.event.empty': '妳已完成所有待辦',
'component.noticeIcon.clear': '清空',
'component.noticeIcon.cleared': '清空了',
'component.noticeIcon.empty': '暫無資料',
'component.noticeIcon.view-more': '查看更多',
};
export default {
'menu.welcome': '歡迎',
'menu.more-blocks': '更多區塊',
'menu.home': '首頁',
'menu.login': '登錄',
'menu.exception.403': '403',
'menu.exception.404': '404',
'menu.exception.500': '500',
'menu.register': '註冊',
'menu.register.resultt': '註冊結果',
'menu.dashboard': 'Dashboard',
'menu.dashboard.analysis': '分析頁',
'menu.dashboard.monitor': '監控頁',
'menu.dashboard.workplace': '工作臺',
'menu.form': '表單頁',
'menu.form.basic-form': '基礎表單',
'menu.form.step-form': '分步表單',
'menu.form.step-form.info': '分步表單(填寫轉賬信息)',
'menu.form.step-form.confirm': '分步表單(確認轉賬信息)',
'menu.form.step-form.result': '分步表單(完成)',
'menu.form.advanced-form': '高級表單',
'menu.list': '列表頁',
'menu.list.table-list': '查詢表格',
'menu.list.basic-list': '標淮列表',
'menu.list.card-list': '卡片列表',
'menu.list.search-list': '搜索列表',
'menu.list.search-list.articles': '搜索列表(文章)',
'menu.list.search-list.projects': '搜索列表(項目)',
'menu.list.search-list.applications': '搜索列表(應用)',
'menu.profile': '詳情頁',
'menu.profile.basic': '基礎詳情頁',
'menu.profile.advanced': '高級詳情頁',
'menu.result': '結果頁',
'menu.result.success': '成功頁',
'menu.result.fail': '失敗頁',
'menu.account': '個人頁',
'menu.account.center': '個人中心',
'menu.account.settings': '個人設置',
'menu.account.trigger': '觸發報錯',
'menu.account.logout': '退出登錄',
'menu.exception': '异常页',
'menu.exception.not-permission': '403',
'menu.exception.not-find': '404',
'menu.exception.server-error': '500',
'menu.exception.trigger': '触发错误',
'menu.editor': '圖形編輯器',
'menu.editor.flow': '流程編輯器',
'menu.editor.mind': '腦圖編輯器',
'menu.editor.koni': '拓撲編輯器',
};
export default {
'app.pwa.offline': '當前處於離線狀態',
'app.pwa.serviceworker.updated': '有新內容',
'app.pwa.serviceworker.updated.hint': '請點擊“刷新”按鈕或者手動刷新頁面',
'app.pwa.serviceworker.updated.ok': '刷新',
};
export default {
'app.setting.pagestyle': '整體風格設置',
'app.setting.pagestyle.dark': '暗色菜單風格',
'app.setting.pagestyle.light': '亮色菜單風格',
'app.setting.content-width': '內容區域寬度',
'app.setting.content-width.fixed': '定寬',
'app.setting.content-width.fluid': '流式',
'app.setting.themecolor': '主題色',
'app.setting.themecolor.dust': '薄暮',
'app.setting.themecolor.volcano': '火山',
'app.setting.themecolor.sunset': '日暮',
'app.setting.themecolor.cyan': '明青',
'app.setting.themecolor.green': '極光綠',
'app.setting.themecolor.daybreak': '拂曉藍(默認)',
'app.setting.themecolor.geekblue': '極客藍',
'app.setting.themecolor.purple': '醬紫',
'app.setting.navigationmode': '導航模式',
'app.setting.sidemenu': '側邊菜單布局',
'app.setting.topmenu': '頂部菜單布局',
'app.setting.fixedheader': '固定 Header',
'app.setting.fixedsidebar': '固定側邊菜單',
'app.setting.fixedsidebar.hint': '側邊菜單布局時可配置',
'app.setting.hideheader': '下滑時隱藏 Header',
'app.setting.hideheader.hint': '固定 Header 時可配置',
'app.setting.othersettings': '其他設置',
'app.setting.weakmode': '色弱模式',
'app.setting.copy': '拷貝設置',
'app.setting.copyinfo': '拷貝成功,請到 src/defaultSettings.js 中替換默認配置',
'app.setting.production.hint':
'配置欄只在開發環境用於預覽,生產環境不會展現,請拷貝後手動修改配置文件',
};
export default {
'app.settings.menuMap.basic': '基本設置',
'app.settings.menuMap.security': '安全設置',
'app.settings.menuMap.binding': '賬號綁定',
'app.settings.menuMap.notification': '新消息通知',
'app.settings.basic.avatar': '頭像',
'app.settings.basic.change-avatar': '更換頭像',
'app.settings.basic.email': '郵箱',
'app.settings.basic.email-message': '請輸入您的郵箱!',
'app.settings.basic.nickname': '昵稱',
'app.settings.basic.nickname-message': '請輸入您的昵稱!',
'app.settings.basic.profile': '個人簡介',
'app.settings.basic.profile-message': '請輸入個人簡介!',
'app.settings.basic.profile-placeholder': '個人簡介',
'app.settings.basic.country': '國家/地區',
'app.settings.basic.country-message': '請輸入您的國家或地區!',
'app.settings.basic.geographic': '所在省市',
'app.settings.basic.geographic-message': '請輸入您的所在省市!',
'app.settings.basic.address': '街道地址',
'app.settings.basic.address-message': '請輸入您的街道地址!',
'app.settings.basic.phone': '聯系電話',
'app.settings.basic.phone-message': '請輸入您的聯系電話!',
'app.settings.basic.update': '更新基本信息',
'app.settings.security.strong': '',
'app.settings.security.medium': '',
'app.settings.security.weak': '',
'app.settings.security.password': '賬戶密碼',
'app.settings.security.password-description': '當前密碼強度',
'app.settings.security.phone': '密保手機',
'app.settings.security.phone-description': '已綁定手機',
'app.settings.security.question': '密保問題',
'app.settings.security.question-description': '未設置密保問題,密保問題可有效保護賬戶安全',
'app.settings.security.email': '備用郵箱',
'app.settings.security.email-description': '已綁定郵箱',
'app.settings.security.mfa': 'MFA 設備',
'app.settings.security.mfa-description': '未綁定 MFA 設備,綁定後,可以進行二次確認',
'app.settings.security.modify': '修改',
'app.settings.security.set': '設置',
'app.settings.security.bind': '綁定',
'app.settings.binding.taobao': '綁定淘寶',
'app.settings.binding.taobao-description': '當前未綁定淘寶賬號',
'app.settings.binding.alipay': '綁定支付寶',
'app.settings.binding.alipay-description': '當前未綁定支付寶賬號',
'app.settings.binding.dingding': '綁定釘釘',
'app.settings.binding.dingding-description': '當前未綁定釘釘賬號',
'app.settings.binding.bind': '綁定',
'app.settings.notification.password': '賬戶密碼',
'app.settings.notification.password-description': '其他用戶的消息將以站內信的形式通知',
'app.settings.notification.messages': '系統消息',
'app.settings.notification.messages-description': '系統消息將以站內信的形式通知',
'app.settings.notification.todo': '待辦任務',
'app.settings.notification.todo-description': '待辦任務將以站內信的形式通知',
'app.settings.open': '',
'app.settings.close': '',
};
function getFakeCaptcha(req: any, res: { json: (arg0: string) => void }) {
return res.json('captcha-xxx');
}
export default {
'POST /api/login/account': (
req: { body: { password: any; userName: any; type: any } },
res: {
send: (data: any) => void;
},
) => {
const { password, userName, type } = req.body;
if (password === 'ant.design' && userName === 'admin') {
res.send({
status: 'ok',
type,
currentAuthority: 'admin',
});
return;
}
if (password === 'ant.design' && userName === 'user') {
res.send({
status: 'ok',
type,
currentAuthority: 'user',
});
return;
}
res.send({
status: 'error',
type,
currentAuthority: 'guest',
});
},
'GET /api/login/captcha': getFakeCaptcha,
};
import { createContext } from 'react';
export interface LoginContextProps {
tabUtil?: {
addTab: (id: string) => void;
removeTab: (id: string) => void;
};
updateActive?: (activeItem: { [key: string]: string } | string) => void;
}
const LoginContext: React.Context<LoginContextProps> = createContext({});
export default LoginContext;
import { Button, Col, Form, Input, Row } from 'antd';
import React, { Component } from 'react';
import { FormComponentProps } from 'antd/es/form';
import omit from 'omit.js';
import ItemMap from './map';
import LoginContext, { LoginContextProps } from './LoginContext';
import styles from './index.less';
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export type WrappedLoginItemProps = Omit<LoginItemProps, 'form' | 'type' | 'updateActive'>;
export type LoginItemKeyType = keyof typeof ItemMap;
export interface LoginItemType {
UserName: React.FC<WrappedLoginItemProps>;
Password: React.FC<WrappedLoginItemProps>;
Mobile: React.FC<WrappedLoginItemProps>;
Captcha: React.FC<WrappedLoginItemProps>;
}
export interface LoginItemProps {
name?: string;
rules?: any[];
style?: React.CSSProperties;
onGetCaptcha?: (event?: MouseEvent) => void | Promise<any> | false;
placeholder?: string;
buttonText?: React.ReactNode;
onPressEnter?: (e: any) => void;
countDown?: number;
getCaptchaButtonText?: string;
getCaptchaSecondText?: string;
updateActive?: LoginContextProps['updateActive'];
type?: string;
defaultValue?: string;
form?: FormComponentProps['form'];
customProps?: { [key: string]: any };
onChange?: (e: any) => void;
tabUtil?: any;
}
interface LoginItemState {
count: number;
}
const FormItem = Form.Item;
class WrapFormItem extends Component<LoginItemProps, LoginItemState> {
static defaultProps = {
getCaptchaButtonText: 'captcha',
getCaptchaSecondText: 'second',
};
interval: number | undefined = undefined;
constructor(props: LoginItemProps) {
super(props);
this.state = {
count: 0,
};
}
componentDidMount() {
const { updateActive, name = '' } = this.props;
if (updateActive) {
updateActive(name);
}
}
componentWillUnmount() {
clearInterval(this.interval);
}
onGetCaptcha = () => {
const { onGetCaptcha } = this.props;
const result = onGetCaptcha ? onGetCaptcha() : null;
if (result === false) {
return;
}
if (result instanceof Promise) {
result.then(this.runGetCaptchaCountDown);
} else {
this.runGetCaptchaCountDown();
}
};
getFormItemOptions = ({ onChange, defaultValue, customProps = {}, rules }: LoginItemProps) => {
const options: {
rules?: any[];
onChange?: LoginItemProps['onChange'];
initialValue?: LoginItemProps['defaultValue'];
} = {
rules: rules || customProps.rules,
};
if (onChange) {
options.onChange = onChange;
}
if (defaultValue) {
options.initialValue = defaultValue;
}
return options;
};
runGetCaptchaCountDown = () => {
const { countDown } = this.props;
let count = countDown || 59;
this.setState({ count });
this.interval = window.setInterval(() => {
count -= 1;
this.setState({ count });
if (count === 0) {
clearInterval(this.interval);
}
}, 1000);
};
render() {
const { count } = this.state;
// 这么写是为了防止restProps中 带入 onChange, defaultValue, rules props tabUtil
const {
onChange,
customProps,
defaultValue,
rules,
name,
getCaptchaButtonText,
getCaptchaSecondText,
updateActive,
type,
form,
tabUtil,
...restProps
} = this.props;
if (!name) {
return null;
}
if (!form) {
return null;
}
const { getFieldDecorator } = form;
// get getFieldDecorator props
const options = this.getFormItemOptions(this.props);
const otherProps = restProps || {};
if (type === 'Captcha') {
const inputProps = omit(otherProps, ['onGetCaptcha', 'countDown']);
return (
<FormItem>
<Row gutter={8}>
<Col span={16}>
{getFieldDecorator(name, options)(<Input {...customProps} {...inputProps} />)}
</Col>
<Col span={8}>
<Button
disabled={!!count}
className={styles.getCaptcha}
size="large"
onClick={this.onGetCaptcha}
>
{count ? `${count} ${getCaptchaSecondText}` : getCaptchaButtonText}
</Button>
</Col>
</Row>
</FormItem>
);
}
return (
<FormItem>
{getFieldDecorator(name, options)(<Input {...customProps} {...otherProps} />)}
</FormItem>
);
}
}
const LoginItem: Partial<LoginItemType> = {};
Object.keys(ItemMap).forEach(key => {
const item = ItemMap[key];
LoginItem[key] = (props: LoginItemProps) => (
<LoginContext.Consumer>
{context => (
<WrapFormItem
customProps={item.props}
rules={item.rules}
{...props}
type={key}
{...context}
updateActive={context.updateActive}
/>
)}
</LoginContext.Consumer>
);
});
export default LoginItem as LoginItemType;
import { Button, Form } from 'antd';
import { ButtonProps } from 'antd/es/button';
import React from 'react';
import classNames from 'classnames';
import styles from './index.less';
const FormItem = Form.Item;
interface LoginSubmitProps extends ButtonProps {
className?: string;
}
const LoginSubmit: React.SFC<LoginSubmitProps> = ({ className, ...rest }) => {
const clsString = classNames(styles.submit, className);
return (
<FormItem>
<Button size="large" className={clsString} type="primary" htmlType="submit" {...rest} />
</FormItem>
);
};
export default LoginSubmit;
import React, { Component } from 'react';
import { TabPaneProps } from 'antd/es/tabs';
import { Tabs } from 'antd';
import LoginContext, { LoginContextProps } from './LoginContext';
const { TabPane } = Tabs;
const generateId = (() => {
let i = 0;
return (prefix = '') => {
i += 1;
return `${prefix}${i}`;
};
})();
interface LoginTabProps extends TabPaneProps {
tabUtil: LoginContextProps['tabUtil'];
}
class LoginTab extends Component<LoginTabProps> {
uniqueId: string = '';
constructor(props: LoginTabProps) {
super(props);
this.uniqueId = generateId('login-tab-');
}
componentDidMount() {
const { tabUtil } = this.props;
if (tabUtil) {
tabUtil.addTab(this.uniqueId);
}
}
render() {
const { children } = this.props;
return <TabPane {...this.props}>{children}</TabPane>;
}
}
const WrapContext: React.SFC<TabPaneProps> & {
typeName: string;
} = props => (
<LoginContext.Consumer>
{value => <LoginTab tabUtil={value.tabUtil} {...props} />}
</LoginContext.Consumer>
);
// 标志位 用来判断是不是自定义组件
WrapContext.typeName = 'LoginTab';
export default WrapContext;
@import '~antd/es/style/themes/default.less';
.login {
:global {
.ant-tabs .ant-tabs-bar {
margin-bottom: 24px;
text-align: center;
border-bottom: 0;
}
.ant-form-item {
margin: 0 2px 24px;
}
}
.getCaptcha {
display: block;
width: 100%;
}
.icon {
margin-left: 16px;
color: rgba(0, 0, 0, 0.2);
font-size: 24px;
vertical-align: middle;
cursor: pointer;
transition: color 0.3s;
&:hover {
color: @primary-color;
}
}
.other {
margin-top: 24px;
line-height: 22px;
text-align: left;
.register {
float: right;
}
}
.prefixIcon {
color: @disabled-color;
font-size: @font-size-base;
}
.submit {
width: 100%;
margin-top: 24px;
}
}
import { Form, Tabs } from 'antd';
import React, { Component } from 'react';
import { FormComponentProps } from 'antd/es/form';
import classNames from 'classnames';
import LoginContext, { LoginContextProps } from './LoginContext';
import LoginItem, { LoginItemProps } from './LoginItem';
import LoginSubmit from './LoginSubmit';
import LoginTab from './LoginTab';
import styles from './index.less';
export interface LoginProps {
defaultActiveKey?: string;
onTabChange?: (key: string) => void;
style?: React.CSSProperties;
onSubmit?: (error: any, values: any) => void;
className?: string;
form: FormComponentProps['form'];
children: React.ReactElement<LoginTab>[];
}
interface LoginState {
tabs?: string[];
type?: string;
active?: { [key: string]: any[] };
}
class Login extends Component<LoginProps, LoginState> {
public static Tab = LoginTab;
public static Submit = LoginSubmit;
public static UserName: React.FunctionComponent<LoginItemProps>;
public static Password: React.FunctionComponent<LoginItemProps>;
public static Mobile: React.FunctionComponent<LoginItemProps>;
public static Captcha: React.FunctionComponent<LoginItemProps>;
static defaultProps = {
className: '',
defaultActiveKey: '',
onTabChange: () => {},
onSubmit: () => {},
};
constructor(props: LoginProps) {
super(props);
this.state = {
type: props.defaultActiveKey,
tabs: [],
active: {},
};
}
onSwitch = (type: string) => {
this.setState(
{
type,
},
() => {
const { onTabChange } = this.props;
if (onTabChange) {
onTabChange(type);
}
},
);
};
getContext: () => LoginContextProps = () => {
const { form } = this.props;
const { tabs = [] } = this.state;
return {
tabUtil: {
addTab: id => {
this.setState({
tabs: [...tabs, id],
});
},
removeTab: id => {
this.setState({
tabs: tabs.filter(currentId => currentId !== id),
});
},
},
form: { ...form },
updateActive: activeItem => {
const { type = '', active = {} } = this.state;
if (active[type]) {
active[type].push(activeItem);
} else {
active[type] = [activeItem];
}
this.setState({
active,
});
},
};
};
handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
const { active = {}, type = '' } = this.state;
const { form, onSubmit } = this.props;
const activeFields = active[type] || [];
if (form) {
form.validateFields(activeFields, { force: true }, (err, values) => {
if (onSubmit) {
onSubmit(err, values);
}
});
}
};
render() {
const { className, children } = this.props;
const { type, tabs = [] } = this.state;
const TabChildren: React.ReactComponentElement<LoginTab>[] = [];
const otherChildren: React.ReactElement<any>[] = [];
React.Children.forEach(
children,
(child: React.ReactComponentElement<LoginTab> | React.ReactElement<any>) => {
if (!child) {
return;
}
if (child.type.typeName === 'LoginTab') {
TabChildren.push(child);
} else {
otherChildren.push(child);
}
},
);
return (
<LoginContext.Provider value={this.getContext()}>
<div className={classNames(className, styles.login)}>
<Form onSubmit={this.handleSubmit}>
{tabs.length ? (
<React.Fragment>
<Tabs
animated={false}
className={styles.tabs}
activeKey={type}
onChange={this.onSwitch}
>
{TabChildren}
</Tabs>
{otherChildren}
</React.Fragment>
) : (
children
)}
</Form>
</div>
</LoginContext.Provider>
);
}
}
(Object.keys(LoginItem) as (keyof LoginItemType)[]).forEach(item => {
Login[item] = LoginItem[item];
});
export default Form.create<LoginProps>()(Login);
import { Icon } from 'antd';
import React from 'react';
import styles from './index.less';
export default {
UserName: {
props: {
size: 'large',
id: 'userName',
prefix: <Icon type="user" className={styles.prefixIcon} />,
placeholder: 'admin',
},
rules: [
{
required: true,
message: 'Please enter username!',
},
],
},
Password: {
props: {
size: 'large',
prefix: <Icon type="lock" className={styles.prefixIcon} />,
type: 'password',
id: 'password',
placeholder: '888888',
},
rules: [
{
required: true,
message: 'Please enter password!',
},
],
},
Mobile: {
props: {
size: 'large',
prefix: <Icon type="mobile" className={styles.prefixIcon} />,
placeholder: 'mobile number',
},
rules: [
{
required: true,
message: 'Please enter mobile number!',
},
{
pattern: /^1\d{10}$/,
message: 'Wrong mobile number format!',
},
],
},
Captcha: {
props: {
size: 'large',
prefix: <Icon type="mail" className={styles.prefixIcon} />,
placeholder: 'captcha',
},
rules: [
{
required: true,
message: 'Please enter Captcha!',
},
],
},
};
import { Alert, Checkbox, Icon } from 'antd';
import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale';
import React, { Component } from 'react';
import { CheckboxChangeEvent } from 'antd/es/checkbox';
import { Dispatch } from 'redux';
import { FormComponentProps } from 'antd/es/form';
import Link from 'umi/link';
import { connect } from 'dva';
import { StateType } from './model';
import LoginComponents from './components/Login';
import styles from './style.less';
const { Tab, UserName, Password, Mobile, Captcha, Submit } = LoginComponents;
interface LoginProps {
dispatch: Dispatch<any>;
userLogin: StateType;
submitting: boolean;
}
interface LoginState {
type: string;
autoLogin: boolean;
}
export interface FromDataType {
userName: string;
password: string;
mobile: string;
captcha: string;
}
@connect(
({
userLogin,
loading,
}: {
userLogin: StateType;
loading: {
effects: {
[key: string]: string;
};
};
}) => ({
userLogin,
submitting: loading.effects['userLogin/login'],
}),
)
class Login extends Component<
LoginProps,
LoginState
> {
loginForm: FormComponentProps['form'] | undefined | null = undefined;
state: LoginState = {
type: 'account',
autoLogin: true,
};
changeAutoLogin = (e: CheckboxChangeEvent) => {
this.setState({
autoLogin: e.target.checked,
});
};
handleSubmit = (err: any, values: FromDataType) => {
const { type } = this.state;
if (!err) {
const { dispatch } = this.props;
dispatch({
type: 'userLogin/login',
payload: {
...values,
type,
},
});
}
};
onTabChange = (type: string) => {
this.setState({ type });
};
onGetCaptcha = () =>
new Promise((resolve, reject) => {
if (!this.loginForm) {
return;
}
this.loginForm.validateFields(['mobile'], {}, (err: any, values: FromDataType) => {
if (err) {
reject(err);
} else {
const { dispatch } = this.props;
((dispatch({
type: 'userLogin/getCaptcha',
payload: values.mobile,
}) as unknown) as Promise<any>)
.then(resolve)
.catch(reject);
}
});
});
renderMessage = (content: string) => (
<Alert style={{ marginBottom: 24 }} message={content} type="error" showIcon />
);
render() {
const { userLogin, submitting } = this.props;
const { status, type: loginType } = userLogin;
const { type, autoLogin } = this.state;
return (
<div className={styles.main}>
<LoginComponents
defaultActiveKey={type}
onTabChange={this.onTabChange}
onSubmit={this.handleSubmit}
ref={(form: any) => {
this.loginForm = form;
}}
>
<Tab key="account" tab={formatMessage({ id: 'user-login.login.tab-login-credentials' })}>
{status === 'error' &&
loginType === 'account' &&
!submitting &&
this.renderMessage(
formatMessage({ id: 'user-login.login.message-invalid-credentials' }),
)}
<UserName
name="userName"
placeholder={`${formatMessage({ id: 'user-login.login.userName' })}: admin or user`}
rules={[
{
required: true,
message: formatMessage({ id: 'user-login.userName.required' }),
},
]}
/>
<Password
name="password"
placeholder={`${formatMessage({ id: 'user-login.login.password' })}: ant.design`}
rules={[
{
required: true,
message: formatMessage({ id: 'user-login.password.required' }),
},
]}
onPressEnter={() =>
this.loginForm && this.loginForm.validateFields(this.handleSubmit)
}
/>
</Tab>
<Tab key="mobile" tab={formatMessage({ id: 'user-login.login.tab-login-mobile' })}>
{status === 'error' &&
loginType === 'mobile' &&
!submitting &&
this.renderMessage(
formatMessage({ id: 'user-login.login.message-invalid-verification-code' }),
)}
<Mobile
name="mobile"
placeholder={formatMessage({ id: 'user-login.phone-number.placeholder' })}
rules={[
{
required: true,
message: formatMessage({ id: 'user-login.phone-number.required' }),
},
{
pattern: /^1\d{10}$/,
message: formatMessage({ id: 'user-login.phone-number.wrong-format' }),
},
]}
/>
<Captcha
name="captcha"
placeholder={formatMessage({ id: 'user-login.verification-code.placeholder' })}
countDown={120}
onGetCaptcha={this.onGetCaptcha}
getCaptchaButtonText={formatMessage({ id: 'user-login.form.get-captcha' })}
getCaptchaSecondText={formatMessage({ id: 'user-login.captcha.second' })}
rules={[
{
required: true,
message: formatMessage({ id: 'user-login.verification-code.required' }),
},
]}
/>
</Tab>
<div>
<Checkbox checked={autoLogin} onChange={this.changeAutoLogin}>
<FormattedMessage id="user-login.login.remember-me" />
</Checkbox>
<a style={{ float: 'right' }} href="">
<FormattedMessage id="user-login.login.forgot-password" />
</a>
</div>
<Submit loading={submitting}>
<FormattedMessage id="user-login.login.login" />
</Submit>
<div className={styles.other}>
<FormattedMessage id="user-login.login.sign-in-with" />
<Icon type="alipay-circle" className={styles.icon} theme="outlined" />
<Icon type="taobao-circle" className={styles.icon} theme="outlined" />
<Icon type="weibo-circle" className={styles.icon} theme="outlined" />
<Link className={styles.register} to="/user/register">
<FormattedMessage id="user-login.login.signup" />
</Link>
</div>
</LoginComponents>
</div>
);
}
}
export default Login;
export default {
'user-login.login.userName': 'userName',
'user-login.login.password': 'password',
'user-login.login.message-invalid-credentials':
'Invalid username or password(admin/ant.design)',
'user-login.login.message-invalid-verification-code': 'Invalid verification code',
'user-login.login.tab-login-credentials': 'Credentials',
'user-login.login.tab-login-mobile': 'Mobile number',
'user-login.login.remember-me': 'Remember me',
'user-login.login.forgot-password': 'Forgot your password?',
'user-login.login.sign-in-with': 'Sign in with',
'user-login.login.signup': 'Sign up',
'user-login.login.login': 'Login',
'user-login.register.register': 'Register',
'user-login.register.get-verification-code': 'Get code',
'user-login.register.sign-in': 'Already have an account?',
'user-login.register-result.msg': 'Account:registered at {email}',
'user-login.register-result.activation-email':
'The activation email has been sent to your email address and is valid for 24 hours. Please log in to the email in time and click on the link in the email to activate the account.',
'user-login.register-result.back-home': 'Back to home',
'user-login.register-result.view-mailbox': 'View mailbox',
'user-login.email.required': 'Please enter your email!',
'user-login.email.wrong-format': 'The email address is in the wrong format!',
'user-login.userName.required': 'Please enter your userName!',
'user-login.password.required': 'Please enter your password!',
'user-login.password.twice': 'The passwords entered twice do not match!',
'user-login.strength.msg':
"Please enter at least 6 characters and don't use passwords that are easy to guess.",
'user-login.strength.strong': 'Strength: strong',
'user-login.strength.medium': 'Strength: medium',
'user-login.strength.short': 'Strength: too short',
'user-login.confirm-password.required': 'Please confirm your password!',
'user-login.phone-number.required': 'Please enter your phone number!',
'user-login.phone-number.wrong-format': 'Malformed phone number!',
'user-login.verification-code.required': 'Please enter the verification code!',
'user-login.title.required': 'Please enter a title',
'user-login.date.required': 'Please select the start and end date',
'user-login.goal.required': 'Please enter a description of the goal',
'user-login.standard.required': 'Please enter a metric',
'user-login.form.get-captcha': 'Get Captcha',
'user-login.captcha.second': 'sec',
'user-login.form.optional': ' (optional) ',
'user-login.form.submit': 'Submit',
'user-login.form.save': 'Save',
'user-login.email.placeholder': 'Email',
'user-login.password.placeholder': 'Password',
'user-login.confirm-password.placeholder': 'Confirm password',
'user-login.phone-number.placeholder': 'Phone number',
'user-login.verification-code.placeholder': 'Verification code',
'user-login.title.label': 'Title',
'user-login.title.placeholder': 'Give the target a name',
'user-login.date.label': 'Start and end date',
'user-login.placeholder.start': 'Start date',
'user-login.placeholder.end': 'End date',
'user-login.goal.label': 'Goal description',
'user-login.goal.placeholder': 'Please enter your work goals',
'user-login.standard.label': 'Metrics',
'user-login.standard.placeholder': 'Please enter a metric',
'user-login.client.label': 'Client',
'user-login.label.tooltip': 'Target service object',
'user-login.client.placeholder':
'Please describe your customer service, internal customers directly @ Name / job number',
'user-login.invites.label': 'Inviting critics',
'user-login.invites.placeholder':
'Please direct @ Name / job number, you can invite up to 5 people',
'user-login.weight.label': 'Weight',
'user-login.weight.placeholder': 'Please enter weight',
'user-login.public.label': 'Target disclosure',
'user-login.label.help': 'Customers and invitees are shared by default',
'user-login.radio.public': 'Public',
'user-login.radio.partially-public': 'Partially public',
'user-login.radio.private': 'Private',
'user-login.publicUsers.placeholder': 'Open to',
'user-login.option.A': 'Colleague A',
'user-login.option.B': 'Colleague B',
'user-login.option.C': 'Colleague C',
'user-login.navBar.lang': 'Languages',
};
export default {
'user-login.login.userName': '用户名',
'user-login.login.password': '密码',
'user-login.login.message-invalid-credentials': '账户或密码错误(admin/ant.design)',
'user-login.login.message-invalid-verification-code': '验证码错误',
'user-login.login.tab-login-credentials': '账户密码登录',
'user-login.login.tab-login-mobile': '手机号登录',
'user-login.login.remember-me': '自动登录',
'user-login.login.forgot-password': '忘记密码',
'user-login.login.sign-in-with': '其他登录方式',
'user-login.login.signup': '注册账户',
'user-login.login.login': '登录',
'user-login.register.register': '注册',
'user-login.register.get-verification-code': '获取验证码',
'user-login.register.sign-in': '使用已有账户登录',
'user-login.register-result.msg': '你的账户:{email} 注册成功',
'user-login.register-result.activation-email':
'激活邮件已发送到你的邮箱中,邮件有效期为24小时。请及时登录邮箱,点击邮件中的链接激活帐户。',
'user-login.register-result.back-home': '返回首页',
'user-login.register-result.view-mailbox': '查看邮箱',
'user-login.email.required': '请输入邮箱地址!',
'user-login.email.wrong-format': '邮箱地址格式错误!',
'user-login.userName.required': '请输入用户名!',
'user-login.password.required': '请输入密码!',
'user-login.password.twice': '两次输入的密码不匹配!',
'user-login.strength.msg': '请至少输入 6 个字符。请不要使用容易被猜到的密码。',
'user-login.strength.strong': '强度:强',
'user-login.strength.medium': '强度:中',
'user-login.strength.short': '强度:太短',
'user-login.confirm-password.required': '请确认密码!',
'user-login.phone-number.required': '请输入手机号!',
'user-login.phone-number.wrong-format': '手机号格式错误!',
'user-login.verification-code.required': '请输入验证码!',
'user-login.title.required': '请输入标题',
'user-login.date.required': '请选择起止日期',
'user-login.goal.required': '请输入目标描述',
'user-login.standard.required': '请输入衡量标准',
'user-login.form.get-captcha': '获取验证码',
'user-login.captcha.second': '',
'user-login.form.optional': '(选填)',
'user-login.form.submit': '提交',
'user-login.form.save': '保存',
'user-login.email.placeholder': '邮箱',
'user-login.password.placeholder': '至少6位密码,区分大小写',
'user-login.confirm-password.placeholder': '确认密码',
'user-login.phone-number.placeholder': '手机号',
'user-login.verification-code.placeholder': '验证码',
'user-login.title.label': '标题',
'user-login.title.placeholder': '给目标起个名字',
'user-login.date.label': '起止日期',
'user-login.placeholder.start': '开始日期',
'user-login.placeholder.end': '结束日期',
'user-login.goal.label': '目标描述',
'user-login.goal.placeholder': '请输入你的阶段性工作目标',
'user-login.standard.label': '衡量标准',
'user-login.standard.placeholder': '请输入衡量标准',
'user-login.client.label': '客户',
'user-login.label.tooltip': '目标的服务对象',
'user-login.client.placeholder': '请描述你服务的客户,内部客户直接 @姓名/工号',
'user-login.invites.label': '邀评人',
'user-login.invites.placeholder': '请直接 @姓名/工号,最多可邀请 5 人',
'user-login.weight.label': '权重',
'user-login.weight.placeholder': '请输入',
'user-login.public.label': '目标公开',
'user-login.label.help': '客户、邀评人默认被分享',
'user-login.radio.public': '公开',
'user-login.radio.partially-public': '部分公开',
'user-login.radio.private': '不公开',
'user-login.publicUsers.placeholder': '公开给',
'user-login.option.A': '同事甲',
'user-login.option.B': '同事乙',
'user-login.option.C': '同事丙',
'user-login.navBar.lang': '语言',
};
export default {
'user-login.login.userName': '賬戶',
'user-login.login.password': '密碼',
'user-login.login.message-invalid-credentials': '賬戶或密碼錯誤(admin/ant.design)',
'user-login.login.message-invalid-verification-code': '驗證碼錯誤',
'user-login.login.tab-login-credentials': '賬戶密碼登錄',
'user-login.login.tab-login-mobile': '手機號登錄',
'user-login.login.remember-me': '自動登錄',
'user-login.login.forgot-password': '忘記密碼',
'user-login.login.sign-in-with': '其他登錄方式',
'user-login.login.signup': '註冊賬戶',
'user-login.login.login': '登錄',
'user-login.register.register': '註冊',
'user-login.register.get-verification-code': '獲取驗證碼',
'user-login.register.sign-in': '使用已有賬戶登錄',
'user-login.register-result.msg': '妳的賬戶:{email} 註冊成功',
'user-login.register-result.activation-email':
'激活郵件已發送到妳的郵箱中,郵件有效期為24小時。請及時登錄郵箱,點擊郵件中的鏈接激活帳戶。',
'user-login.register-result.back-home': '返回首頁',
'user-login.register-result.view-mailbox': '查看郵箱',
'user-login.email.required': '請輸入郵箱地址!',
'user-login.email.wrong-format': '郵箱地址格式錯誤!',
'user-login.userName.required': '請輸入賬戶!',
'user-login.password.required': '請輸入密碼!',
'user-login.password.twice': '兩次輸入的密碼不匹配!',
'user-login.strength.msg': '請至少輸入 6 個字符。請不要使用容易被猜到的密碼。',
'user-login.strength.strong': '強度:強',
'user-login.strength.medium': '強度:中',
'user-login.strength.short': '強度:太短',
'user-login.confirm-password.required': '請確認密碼!',
'user-login.phone-number.required': '請輸入手機號!',
'user-login.phone-number.wrong-format': '手機號格式錯誤!',
'user-login.verification-code.required': '請輸入驗證碼!',
'user-login.title.required': '請輸入標題',
'user-login.date.required': '請選擇起止日期',
'user-login.goal.required': '請輸入目標描述',
'user-login.standard.required': '請輸入衡量標淮',
'user-login.form.get-captcha': '獲取驗證碼',
'user-login.captcha.second': '',
'user-login.form.optional': '(選填)',
'user-login.form.submit': '提交',
'user-login.form.save': '保存',
'user-login.email.placeholder': '郵箱',
'user-login.password.placeholder': '至少6位密碼,區分大小寫',
'user-login.confirm-password.placeholder': '確認密碼',
'user-login.phone-number.placeholder': '手機號',
'user-login.verification-code.placeholder': '驗證碼',
'user-login.title.label': '標題',
'user-login.title.placeholder': '給目標起個名字',
'user-login.date.label': '起止日期',
'user-login.placeholder.start': '開始日期',
'user-login.placeholder.end': '結束日期',
'user-login.goal.label': '目標描述',
'user-login.goal.placeholder': '請輸入妳的階段性工作目標',
'user-login.standard.label': '衡量標淮',
'user-login.standard.placeholder': '請輸入衡量標淮',
'user-login.client.label': '客戶',
'user-login.label.tooltip': '目標的服務對象',
'user-login.client.placeholder': '請描述妳服務的客戶,內部客戶直接 @姓名/工號',
'user-login.invites.label': '邀評人',
'user-login.invites.placeholder': '請直接 @姓名/工號,最多可邀請 5 人',
'user-login.weight.label': '權重',
'user-login.weight.placeholder': '請輸入',
'user-login.public.label': '目標公開',
'user-login.label.help': '客戶、邀評人默認被分享',
'user-login.radio.public': '公開',
'user-login.radio.partially-public': '部分公開',
'user-login.radio.private': '不公開',
'user-login.publicUsers.placeholder': '公開給',
'user-login.option.A': '同事甲',
'user-login.option.B': '同事乙',
'user-login.option.C': '同事丙',
'user-login.navBar.lang': '語言',
};
import { AnyAction, Reducer } from 'redux';
import { EffectsCommandMap } from 'dva';
import { routerRedux } from 'dva/router';
import { fakeAccountLogin, getFakeCaptcha } from './service';
import { getPageQuery, setAuthority } from './utils/utils';
export interface StateType {
status?: 'ok' | 'error';
type?: string;
currentAuthority?: 'user' | 'guest' | 'admin';
}
export type Effect = (
action: AnyAction,
effects: EffectsCommandMap & { select: <T>(func: (state: StateType) => T) => T },
) => void;
export interface ModelType {
namespace: string;
state: StateType;
effects: {
login: Effect;
getCaptcha: Effect;
};
reducers: {
changeLoginStatus: Reducer<StateType>;
};
}
const Model: ModelType = {
namespace: 'userLogin',
state: {
status: undefined,
},
effects: {
*login({ payload }, { call, put }) {
const response = yield call(fakeAccountLogin, payload);
yield put({
type: 'changeLoginStatus',
payload: response,
});
// Login successfully
if (response.status === 'ok') {
const urlParams = new URL(window.location.href);
const params = getPageQuery();
let { redirect } = params as { redirect: string };
if (redirect) {
const redirectUrlParams = new URL(redirect);
if (redirectUrlParams.origin === urlParams.origin) {
redirect = redirect.substr(urlParams.origin.length);
if (redirect.match(/^\/.*#/)) {
redirect = redirect.substr(redirect.indexOf('#') + 1);
}
} else {
window.location.href = redirect;
return;
}
}
yield put(routerRedux.replace(redirect || '/'));
}
},
*getCaptcha({ payload }, { call }) {
yield call(getFakeCaptcha, payload);
},
},
reducers: {
changeLoginStatus(state, { payload }) {
setAuthority(payload.currentAuthority);
return {
...state,
status: payload.status,
type: payload.type,
};
},
},
};
export default Model;
import request from 'umi-request';
import { FromDataType } from './index';
export async function fakeAccountLogin(params: FromDataType) {
return request('/api/login/account', {
method: 'POST',
data: params,
});
}
export async function getFakeCaptcha(mobile: string) {
return request(`/api/login/captcha?mobile=${mobile}`);
}
@import '~antd/es/style/themes/default.less';
.main {
width: 368px;
margin: 0 auto;
@media screen and (max-width: @screen-sm) {
width: 95%;
}
.icon {
margin-left: 16px;
color: rgba(0, 0, 0, 0.2);
font-size: 24px;
vertical-align: middle;
cursor: pointer;
transition: color 0.3s;
&:hover {
color: @primary-color;
}
}
.other {
margin-top: 24px;
line-height: 22px;
text-align: left;
.register {
float: right;
}
}
:global {
.antd-pro-login-submit {
width: 100%;
margin-top: 24px;
}
}
}
import { parse } from 'qs';
export function getPageQuery() {
return parse(window.location.href.split('?')[1]);
}
export function setAuthority(authority: string | string[]) {
const proAuthority = typeof authority === 'string' ? [authority] : authority;
return localStorage.setItem('antd-pro-authority', JSON.stringify(proAuthority));
}
export default {
'POST /api/register': (
req: any,
res: { send: (arg0: { status: string; currentAuthority: string }) => void },
) => {
res.send({ status: 'ok', currentAuthority: 'user' });
},
};
import { Button, Col, Form, Input, Popover, Progress, Row, Select, message } from 'antd';
import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale';
import React, { Component } from 'react';
import { Dispatch } from 'redux';
import { FormComponentProps } from 'antd/es/form';
import Link from 'umi/link';
import { connect } from 'dva';
import router from 'umi/router';
import { StateType } from './model';
import styles from './style.less';
const FormItem = Form.Item;
const { Option } = Select;
const InputGroup = Input.Group;
const passwordStatusMap = {
ok: (
<div className={styles.success}>
<FormattedMessage id="user-register.strength.strong" />
</div>
),
pass: (
<div className={styles.warning}>
<FormattedMessage id="user-register.strength.medium" />
</div>
),
poor: (
<div className={styles.error}>
<FormattedMessage id="user-register.strength.short" />
</div>
),
};
const passwordProgressMap: {
ok: 'success';
pass: 'normal';
poor: 'exception';
} = {
ok: 'success',
pass: 'normal',
poor: 'exception',
};
interface userRegisterProps extends FormComponentProps {
dispatch: Dispatch<any>;
userRegister: StateType;
submitting: boolean;
}
interface userRegisterState {
count: number;
confirmDirty: boolean;
visible: boolean;
help: string;
prefix: string;
}
export interface UserRegisterParams {
mail: string;
password: string;
confirm: string;
mobile: string;
captcha: string;
prefix: string;
}
@connect(
({
userRegister,
loading,
}: {
userRegister: StateType;
loading: {
effects: {
[key: string]: string;
};
};
}) => ({
userRegister,
submitting: loading.effects['userRegister/submit'],
}),
)
class Register extends Component<
userRegisterProps,
userRegisterState
> {
state: userRegisterState = {
count: 0,
confirmDirty: false,
visible: false,
help: '',
prefix: '86',
};
interval: number | undefined = undefined;
componentDidUpdate() {
const { userRegister, form } = this.props;
const account = form.getFieldValue('mail');
if (userRegister.status === 'ok') {
message.success('注册成功!');
router.push({
pathname: '/user/register-result',
state: {
account,
},
});
}
}
componentWillUnmount() {
clearInterval(this.interval);
}
onGetCaptcha = () => {
let count = 59;
this.setState({ count });
this.interval = window.setInterval(() => {
count -= 1;
this.setState({ count });
if (count === 0) {
clearInterval(this.interval);
}
}, 1000);
};
getPasswordStatus = () => {
const { form } = this.props;
const value = form.getFieldValue('password');
if (value && value.length > 9) {
return 'ok';
}
if (value && value.length > 5) {
return 'pass';
}
return 'poor';
};
handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
const { form, dispatch } = this.props;
form.validateFields({ force: true }, (err, values) => {
if (!err) {
const { prefix } = this.state;
dispatch({
type: 'userRegister/submit',
payload: {
...values,
prefix,
},
});
}
});
};
checkConfirm = (rule: any, value: string, callback: (messgae?: string) => void) => {
const { form } = this.props;
if (value && value !== form.getFieldValue('password')) {
callback(formatMessage({ id: 'user-register.password.twice' }));
} else {
callback();
}
};
checkPassword = (rule: any, value: string, callback: (messgae?: string) => void) => {
const { visible, confirmDirty } = this.state;
if (!value) {
this.setState({
help: formatMessage({ id: 'user-register.password.required' }),
visible: !!value,
});
callback('error');
} else {
this.setState({
help: '',
});
if (!visible) {
this.setState({
visible: !!value,
});
}
if (value.length < 6) {
callback('error');
} else {
const { form } = this.props;
if (value && confirmDirty) {
form.validateFields(['confirm'], { force: true });
}
callback();
}
}
};
changePrefix = (value: string) => {
this.setState({
prefix: value,
});
};
renderPasswordProgress = () => {
const { form } = this.props;
const value = form.getFieldValue('password');
const passwordStatus = this.getPasswordStatus();
return value && value.length ? (
<div className={styles[`progress-${passwordStatus}`]}>
<Progress
status={passwordProgressMap[passwordStatus]}
className={styles.progress}
strokeWidth={6}
percent={value.length * 10 > 100 ? 100 : value.length * 10}
showInfo={false}
/>
</div>
) : null;
};
render() {
const { form, submitting } = this.props;
const { getFieldDecorator } = form;
const { count, prefix, help, visible } = this.state;
return (
<div className={styles.main}>
<h3>
<FormattedMessage id="user-register.register.register" />
</h3>
<Form onSubmit={this.handleSubmit}>
<FormItem>
{getFieldDecorator('mail', {
rules: [
{
required: true,
message: formatMessage({ id: 'user-register.email.required' }),
},
{
type: 'email',
message: formatMessage({ id: 'user-register.email.wrong-format' }),
},
],
})(
<Input
size="large"
placeholder={formatMessage({ id: 'user-register.email.placeholder' })}
/>,
)}
</FormItem>
<FormItem help={help}>
<Popover
getPopupContainer={node => {
if (node && node.parentNode) {
return node.parentNode as HTMLElement;
}
return node;
}}
content={
<div style={{ padding: '4px 0' }}>
{passwordStatusMap[this.getPasswordStatus()]}
{this.renderPasswordProgress()}
<div style={{ marginTop: 10 }}>
<FormattedMessage id="user-register.strength.msg" />
</div>
</div>
}
overlayStyle={{ width: 240 }}
placement="right"
visible={visible}
>
{getFieldDecorator('password', {
rules: [
{
validator: this.checkPassword,
},
],
})(
<Input
size="large"
type="password"
placeholder={formatMessage({ id: 'user-register.password.placeholder' })}
/>,
)}
</Popover>
</FormItem>
<FormItem>
{getFieldDecorator('confirm', {
rules: [
{
required: true,
message: formatMessage({ id: 'user-register.confirm-password.required' }),
},
{
validator: this.checkConfirm,
},
],
})(
<Input
size="large"
type="password"
placeholder={formatMessage({ id: 'user-register.confirm-password.placeholder' })}
/>,
)}
</FormItem>
<FormItem>
<InputGroup compact>
<Select
size="large"
value={prefix}
onChange={this.changePrefix}
style={{ width: '20%' }}
>
<Option value="86">+86</Option>
<Option value="87">+87</Option>
</Select>
{getFieldDecorator('mobile', {
rules: [
{
required: true,
message: formatMessage({ id: 'user-register.phone-number.required' }),
},
{
pattern: /^\d{11}$/,
message: formatMessage({ id: 'user-register.phone-number.wrong-format' }),
},
],
})(
<Input
size="large"
style={{ width: '80%' }}
placeholder={formatMessage({ id: 'user-register.phone-number.placeholder' })}
/>,
)}
</InputGroup>
</FormItem>
<FormItem>
<Row gutter={8}>
<Col span={16}>
{getFieldDecorator('captcha', {
rules: [
{
required: true,
message: formatMessage({ id: 'user-register.verification-code.required' }),
},
],
})(
<Input
size="large"
placeholder={formatMessage({ id: 'user-register.verification-code.placeholder' })}
/>,
)}
</Col>
<Col span={8}>
<Button
size="large"
disabled={!!count}
className={styles.getCaptcha}
onClick={this.onGetCaptcha}
>
{count
? `${count} s`
: formatMessage({ id: 'user-register.register.get-verification-code' })}
</Button>
</Col>
</Row>
</FormItem>
<FormItem>
<Button
size="large"
loading={submitting}
className={styles.submit}
type="primary"
htmlType="submit"
>
<FormattedMessage id="user-register.register.register" />
</Button>
<Link className={styles.login} to="/user/login">
<FormattedMessage id="user-register.register.sign-in" />
</Link>
</FormItem>
</Form>
</div>
);
}
}
export default Form.create<userRegisterProps>()(Register);
export default {
'user-register.login.userName': 'userName',
'user-register.login.password': 'password',
'user-register.login.message-invalid-credentials':
'Invalid username or password(admin/ant.design)',
'user-register.login.message-invalid-verification-code': 'Invalid verification code',
'user-register.login.tab-login-credentials': 'Credentials',
'user-register.login.tab-login-mobile': 'Mobile number',
'user-register.login.remember-me': 'Remember me',
'user-register.login.forgot-password': 'Forgot your password?',
'user-register.login.sign-in-with': 'Sign in with',
'user-register.login.signup': 'Sign up',
'user-register.login.login': 'Login',
'user-register.register.register': 'Register',
'user-register.register.get-verification-code': 'Get code',
'user-register.register.sign-in': 'Already have an account?',
'user-register.register-result.msg': 'Account:registered at {email}',
'user-register.register-result.activation-email':
'The activation email has been sent to your email address and is valid for 24 hours. Please log in to the email in time and click on the link in the email to activate the account.',
'user-register.register-result.back-home': 'Back to home',
'user-register.register-result.view-mailbox': 'View mailbox',
'user-register.email.required': 'Please enter your email!',
'user-register.email.wrong-format': 'The email address is in the wrong format!',
'user-register.userName.required': 'Please enter your userName!',
'user-register.password.required': 'Please enter your password!',
'user-register.password.twice': 'The passwords entered twice do not match!',
'user-register.strength.msg':
"Please enter at least 6 characters and don't use passwords that are easy to guess.",
'user-register.strength.strong': 'Strength: strong',
'user-register.strength.medium': 'Strength: medium',
'user-register.strength.short': 'Strength: too short',
'user-register.confirm-password.required': 'Please confirm your password!',
'user-register.phone-number.required': 'Please enter your phone number!',
'user-register.phone-number.wrong-format': 'Malformed phone number!',
'user-register.verification-code.required': 'Please enter the verification code!',
'user-register.title.required': 'Please enter a title',
'user-register.date.required': 'Please select the start and end date',
'user-register.goal.required': 'Please enter a description of the goal',
'user-register.standard.required': 'Please enter a metric',
'user-register.form.get-captcha': 'Get Captcha',
'user-register.captcha.second': 'sec',
'user-register.form.optional': ' (optional) ',
'user-register.form.submit': 'Submit',
'user-register.form.save': 'Save',
'user-register.email.placeholder': 'Email',
'user-register.password.placeholder': 'Password',
'user-register.confirm-password.placeholder': 'Confirm password',
'user-register.phone-number.placeholder': 'Phone number',
'user-register.verification-code.placeholder': 'Verification code',
'user-register.title.label': 'Title',
'user-register.title.placeholder': 'Give the target a name',
'user-register.date.label': 'Start and end date',
'user-register.placeholder.start': 'Start date',
'user-register.placeholder.end': 'End date',
'user-register.goal.label': 'Goal description',
'user-register.goal.placeholder': 'Please enter your work goals',
'user-register.standard.label': 'Metrics',
'user-register.standard.placeholder': 'Please enter a metric',
'user-register.client.label': 'Client',
'user-register.label.tooltip': 'Target service object',
'user-register.client.placeholder':
'Please describe your customer service, internal customers directly @ Name / job number',
'user-register.invites.label': 'Inviting critics',
'user-register.invites.placeholder':
'Please direct @ Name / job number, you can invite up to 5 people',
'user-register.weight.label': 'Weight',
'user-register.weight.placeholder': 'Please enter weight',
'user-register.public.label': 'Target disclosure',
'user-register.label.help': 'Customers and invitees are shared by default',
'user-register.radio.public': 'Public',
'user-register.radio.partially-public': 'Partially public',
'user-register.radio.private': 'Private',
'user-register.publicUsers.placeholder': 'Open to',
'user-register.option.A': 'Colleague A',
'user-register.option.B': 'Colleague B',
'user-register.option.C': 'Colleague C',
'user-register.navBar.lang': 'Languages',
};
export default {
'user-register.login.userName': '用户名',
'user-register.login.password': '密码',
'user-register.login.message-invalid-credentials': '账户或密码错误(admin/ant.design)',
'user-register.login.message-invalid-verification-code': '验证码错误',
'user-register.login.tab-login-credentials': '账户密码登录',
'user-register.login.tab-login-mobile': '手机号登录',
'user-register.login.remember-me': '自动登录',
'user-register.login.forgot-password': '忘记密码',
'user-register.login.sign-in-with': '其他登录方式',
'user-register.login.signup': '注册账户',
'user-register.login.login': '登录',
'user-register.register.register': '注册',
'user-register.register.get-verification-code': '获取验证码',
'user-register.register.sign-in': '使用已有账户登录',
'user-register.register-result.msg': '你的账户:{email} 注册成功',
'user-register.register-result.activation-email':
'激活邮件已发送到你的邮箱中,邮件有效期为24小时。请及时登录邮箱,点击邮件中的链接激活帐户。',
'user-register.register-result.back-home': '返回首页',
'user-register.register-result.view-mailbox': '查看邮箱',
'user-register.email.required': '请输入邮箱地址!',
'user-register.email.wrong-format': '邮箱地址格式错误!',
'user-register.userName.required': '请输入用户名!',
'user-register.password.required': '请输入密码!',
'user-register.password.twice': '两次输入的密码不匹配!',
'user-register.strength.msg': '请至少输入 6 个字符。请不要使用容易被猜到的密码。',
'user-register.strength.strong': '强度:强',
'user-register.strength.medium': '强度:中',
'user-register.strength.short': '强度:太短',
'user-register.confirm-password.required': '请确认密码!',
'user-register.phone-number.required': '请输入手机号!',
'user-register.phone-number.wrong-format': '手机号格式错误!',
'user-register.verification-code.required': '请输入验证码!',
'user-register.title.required': '请输入标题',
'user-register.date.required': '请选择起止日期',
'user-register.goal.required': '请输入目标描述',
'user-register.standard.required': '请输入衡量标准',
'user-register.form.get-captcha': '获取验证码',
'user-register.captcha.second': '',
'user-register.form.optional': '(选填)',
'user-register.form.submit': '提交',
'user-register.form.save': '保存',
'user-register.email.placeholder': '邮箱',
'user-register.password.placeholder': '至少6位密码,区分大小写',
'user-register.confirm-password.placeholder': '确认密码',
'user-register.phone-number.placeholder': '手机号',
'user-register.verification-code.placeholder': '验证码',
'user-register.title.label': '标题',
'user-register.title.placeholder': '给目标起个名字',
'user-register.date.label': '起止日期',
'user-register.placeholder.start': '开始日期',
'user-register.placeholder.end': '结束日期',
'user-register.goal.label': '目标描述',
'user-register.goal.placeholder': '请输入你的阶段性工作目标',
'user-register.standard.label': '衡量标准',
'user-register.standard.placeholder': '请输入衡量标准',
'user-register.client.label': '客户',
'user-register.label.tooltip': '目标的服务对象',
'user-register.client.placeholder': '请描述你服务的客户,内部客户直接 @姓名/工号',
'user-register.invites.label': '邀评人',
'user-register.invites.placeholder': '请直接 @姓名/工号,最多可邀请 5 人',
'user-register.weight.label': '权重',
'user-register.weight.placeholder': '请输入',
'user-register.public.label': '目标公开',
'user-register.label.help': '客户、邀评人默认被分享',
'user-register.radio.public': '公开',
'user-register.radio.partially-public': '部分公开',
'user-register.radio.private': '不公开',
'user-register.publicUsers.placeholder': '公开给',
'user-register.option.A': '同事甲',
'user-register.option.B': '同事乙',
'user-register.option.C': '同事丙',
'user-register.navBar.lang': '语言',
};
export default {
'user-register.login.userName': '賬戶',
'user-register.login.password': '密碼',
'user-register.login.message-invalid-credentials': '賬戶或密碼錯誤(admin/ant.design)',
'user-register.login.message-invalid-verification-code': '驗證碼錯誤',
'user-register.login.tab-login-credentials': '賬戶密碼登錄',
'user-register.login.tab-login-mobile': '手機號登錄',
'user-register.login.remember-me': '自動登錄',
'user-register.login.forgot-password': '忘記密碼',
'user-register.login.sign-in-with': '其他登錄方式',
'user-register.login.signup': '註冊賬戶',
'user-register.login.login': '登錄',
'user-register.register.register': '註冊',
'user-register.register.get-verification-code': '獲取驗證碼',
'user-register.register.sign-in': '使用已有賬戶登錄',
'user-register.register-result.msg': '妳的賬戶:{email} 註冊成功',
'user-register.register-result.activation-email':
'激活郵件已發送到妳的郵箱中,郵件有效期為24小時。請及時登錄郵箱,點擊郵件中的鏈接激活帳戶。',
'user-register.register-result.back-home': '返回首頁',
'user-register.register-result.view-mailbox': '查看郵箱',
'user-register.email.required': '請輸入郵箱地址!',
'user-register.email.wrong-format': '郵箱地址格式錯誤!',
'user-register.userName.required': '請輸入賬戶!',
'user-register.password.required': '請輸入密碼!',
'user-register.password.twice': '兩次輸入的密碼不匹配!',
'user-register.strength.msg': '請至少輸入 6 個字符。請不要使用容易被猜到的密碼。',
'user-register.strength.strong': '強度:強',
'user-register.strength.medium': '強度:中',
'user-register.strength.short': '強度:太短',
'user-register.confirm-password.required': '請確認密碼!',
'user-register.phone-number.required': '請輸入手機號!',
'user-register.phone-number.wrong-format': '手機號格式錯誤!',
'user-register.verification-code.required': '請輸入驗證碼!',
'user-register.title.required': '請輸入標題',
'user-register.date.required': '請選擇起止日期',
'user-register.goal.required': '請輸入目標描述',
'user-register.standard.required': '請輸入衡量標淮',
'user-register.form.get-captcha': '獲取驗證碼',
'user-register.captcha.second': '',
'user-register.form.optional': '(選填)',
'user-register.form.submit': '提交',
'user-register.form.save': '保存',
'user-register.email.placeholder': '郵箱',
'user-register.password.placeholder': '至少6位密碼,區分大小寫',
'user-register.confirm-password.placeholder': '確認密碼',
'user-register.phone-number.placeholder': '手機號',
'user-register.verification-code.placeholder': '驗證碼',
'user-register.title.label': '標題',
'user-register.title.placeholder': '給目標起個名字',
'user-register.date.label': '起止日期',
'user-register.placeholder.start': '開始日期',
'user-register.placeholder.end': '結束日期',
'user-register.goal.label': '目標描述',
'user-register.goal.placeholder': '請輸入妳的階段性工作目標',
'user-register.standard.label': '衡量標淮',
'user-register.standard.placeholder': '請輸入衡量標淮',
'user-register.client.label': '客戶',
'user-register.label.tooltip': '目標的服務對象',
'user-register.client.placeholder': '請描述妳服務的客戶,內部客戶直接 @姓名/工號',
'user-register.invites.label': '邀評人',
'user-register.invites.placeholder': '請直接 @姓名/工號,最多可邀請 5 人',
'user-register.weight.label': '權重',
'user-register.weight.placeholder': '請輸入',
'user-register.public.label': '目標公開',
'user-register.label.help': '客戶、邀評人默認被分享',
'user-register.radio.public': '公開',
'user-register.radio.partially-public': '部分公開',
'user-register.radio.private': '不公開',
'user-register.publicUsers.placeholder': '公開給',
'user-register.option.A': '同事甲',
'user-register.option.B': '同事乙',
'user-register.option.C': '同事丙',
'user-register.navBar.lang': '語言',
};
import { AnyAction, Reducer } from 'redux';
import { EffectsCommandMap } from 'dva';
import { fakeRegister } from './service';
export interface StateType {
status?: 'ok' | 'error';
currentAuthority?: 'user' | 'guest' | 'admin';
}
export type Effect = (
action: AnyAction,
effects: EffectsCommandMap & { select: <T>(func: (state: StateType) => T) => T },
) => void;
export interface ModelType {
namespace: string;
state: StateType;
effects: {
submit: Effect;
};
reducers: {
registerHandle: Reducer<StateType>;
};
}
const Model: ModelType = {
namespace: 'userRegister',
state: {
status: undefined,
},
effects: {
*submit({ payload }, { call, put }) {
const response = yield call(fakeRegister, payload);
yield put({
type: 'registerHandle',
payload: response,
});
},
},
reducers: {
registerHandle(state, { payload }) {
return {
...state,
status: payload.status,
};
},
},
};
export default Model;
import request from 'umi-request';
import { UserRegisterParams } from './index';
export async function fakeRegister(params: UserRegisterParams) {
return request('/api/register', {
method: 'POST',
data: params,
});
}
@import '~antd/es/style/themes/default.less';
.main {
width: 368px;
margin: 0 auto;
:global {
.ant-form-item {
margin-bottom: 24px;
}
}
h3 {
margin-bottom: 20px;
font-size: 16px;
}
.getCaptcha {
display: block;
width: 100%;
}
.submit {
width: 50%;
}
.login {
float: right;
line-height: @btn-height-lg;
}
}
.success,
.warning,
.error {
transition: color 0.3s;
}
.success {
color: @success-color;
}
.warning {
color: @warning-color;
}
.error {
color: @error-color;
}
.progress-pass > .progress {
:global {
.ant-progress-bg {
background-color: @warning-color;
}
}
}
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