diff --git a/config/config.ts b/config/config.ts index 5123998f3807dac05c4ed4bcdb20767da5c40bf4..bf63695f3e1c04f7743965c95511cc4f85159014 100644 --- a/config/config.ts +++ b/config/config.ts @@ -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') || diff --git a/package.json b/package.json index 445971173931c618c769ae67eb7e2b8594ef8c62..63ec831298eb2b8d59513ccc108e4c57ed95b299 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/SelectLang/index.tsx b/src/components/SelectLang/index.tsx index ac8309d953721ac87b2d5d9b0823516837f3842f..b8b85dbae612288ccd67ed3ec6e562386dec980b 100644 --- a/src/components/SelectLang/index.tsx +++ b/src/components/SelectLang/index.tsx @@ -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; } + const SelectLang: React.FC = 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 = ( - {locales.map(locale => ( - - - {languageIcons[locale]} - {' '} - {languageLabels[locale]} - - ))} + {locales && + locales.map(({ label, key, icon }) => ( + + + {icon} + {' '} + {label} + + ))} ); return ( diff --git a/src/config.js b/src/config.js index a8e43836ea436ffcb75b159d2e133ef3019d441f..e1c6b63a737b62b36b4a07341d6f263dc30a0b68 100644 --- a/src/config.js +++ b/src/config.js @@ -1,9 +1,18 @@ /** * 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: '🇬🇧', + }, + ], }; diff --git a/src/layouts/UserLayout.tsx b/src/layouts/UserLayout.tsx index df0890aaa9c5c381d16e9437d1becb892b40e733..b32e242c156c88a26f2ae0fba3f1f7d7dbcc95d8 100644 --- a/src/layouts/UserLayout.tsx +++ b/src/layouts/UserLayout.tsx @@ -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 { >
- +
diff --git a/src/locales/pt-BR.ts b/src/locales/pt-BR.ts deleted file mode 100644 index 3ba8ef133ca9db5623f4471903c752af4ee17a4a..0000000000000000000000000000000000000000 --- a/src/locales/pt-BR.ts +++ /dev/null @@ -1,20 +0,0 @@ -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, -}; diff --git a/src/locales/pt-BR/component.ts b/src/locales/pt-BR/component.ts deleted file mode 100644 index 7cf9999c3ab4296935f65eb6d270ec4c9126c485..0000000000000000000000000000000000000000 --- a/src/locales/pt-BR/component.ts +++ /dev/null @@ -1,5 +0,0 @@ -export default { - 'component.tagSelect.expand': 'Expandir', - 'component.tagSelect.collapse': 'Diminuir', - 'component.tagSelect.all': 'Todas', -}; diff --git a/src/locales/pt-BR/globalHeader.ts b/src/locales/pt-BR/globalHeader.ts deleted file mode 100644 index c92739919227815c35d19e1ccf39949fdb8ba255..0000000000000000000000000000000000000000 --- a/src/locales/pt-BR/globalHeader.ts +++ /dev/null @@ -1,18 +0,0 @@ -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', -}; diff --git a/src/locales/pt-BR/menu.ts b/src/locales/pt-BR/menu.ts deleted file mode 100644 index 3666b6b665e4464ed3a2b911fad7cf60199f001d..0000000000000000000000000000000000000000 --- a/src/locales/pt-BR/menu.ts +++ /dev/null @@ -1,51 +0,0 @@ -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', -}; diff --git a/src/locales/pt-BR/pwa.ts b/src/locales/pt-BR/pwa.ts deleted file mode 100644 index 05cc79784227229ec18ed0b7598e6a03db6bb7d7..0000000000000000000000000000000000000000 --- a/src/locales/pt-BR/pwa.ts +++ /dev/null @@ -1,7 +0,0 @@ -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', -}; diff --git a/src/locales/pt-BR/settingDrawer.ts b/src/locales/pt-BR/settingDrawer.ts deleted file mode 100644 index 8a10b57e2d9ddf2a4de00eba5b4da1bef0ebedb0..0000000000000000000000000000000000000000 --- a/src/locales/pt-BR/settingDrawer.ts +++ /dev/null @@ -1,32 +0,0 @@ -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', -}; diff --git a/src/locales/pt-BR/settings.ts b/src/locales/pt-BR/settings.ts deleted file mode 100644 index aad2e3877550777446848c55448075d668b4c64a..0000000000000000000000000000000000000000 --- a/src/locales/pt-BR/settings.ts +++ /dev/null @@ -1,60 +0,0 @@ -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', -}; diff --git a/src/locales/zh-TW.ts b/src/locales/zh-TW.ts deleted file mode 100644 index 1eeaffe20554498a045e3ea449beb97b449b930d..0000000000000000000000000000000000000000 --- a/src/locales/zh-TW.ts +++ /dev/null @@ -1,20 +0,0 @@ -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, -}; diff --git a/src/locales/zh-TW/component.ts b/src/locales/zh-TW/component.ts deleted file mode 100644 index ba48e299a91a29a64e2f9834cf5b0b1d3c080fb4..0000000000000000000000000000000000000000 --- a/src/locales/zh-TW/component.ts +++ /dev/null @@ -1,5 +0,0 @@ -export default { - 'component.tagSelect.expand': '展開', - 'component.tagSelect.collapse': '收起', - 'component.tagSelect.all': '全部', -}; diff --git a/src/locales/zh-TW/globalHeader.ts b/src/locales/zh-TW/globalHeader.ts deleted file mode 100644 index ed5845185c9e040b43d7d79e914d5358175a7adb..0000000000000000000000000000000000000000 --- a/src/locales/zh-TW/globalHeader.ts +++ /dev/null @@ -1,17 +0,0 @@ -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': '查看更多', -}; diff --git a/src/locales/zh-TW/menu.ts b/src/locales/zh-TW/menu.ts deleted file mode 100644 index b0160286b6ed0e6cf7ffbb4dc5478cd8664b1d8a..0000000000000000000000000000000000000000 --- a/src/locales/zh-TW/menu.ts +++ /dev/null @@ -1,51 +0,0 @@ -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': '拓撲編輯器', -}; diff --git a/src/locales/zh-TW/pwa.ts b/src/locales/zh-TW/pwa.ts deleted file mode 100644 index 108a6e489be8e7567ac6d41cd7d81d7715020b3b..0000000000000000000000000000000000000000 --- a/src/locales/zh-TW/pwa.ts +++ /dev/null @@ -1,6 +0,0 @@ -export default { - 'app.pwa.offline': '當前處於離線狀態', - 'app.pwa.serviceworker.updated': '有新內容', - 'app.pwa.serviceworker.updated.hint': '請點擊“刷新”按鈕或者手動刷新頁面', - 'app.pwa.serviceworker.updated.ok': '刷新', -}; diff --git a/src/locales/zh-TW/settingDrawer.ts b/src/locales/zh-TW/settingDrawer.ts deleted file mode 100644 index 24dc281fa87e613c41824a78bf6561eaa0152a6d..0000000000000000000000000000000000000000 --- a/src/locales/zh-TW/settingDrawer.ts +++ /dev/null @@ -1,31 +0,0 @@ -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': - '配置欄只在開發環境用於預覽,生產環境不會展現,請拷貝後手動修改配置文件', -}; diff --git a/src/locales/zh-TW/settings.ts b/src/locales/zh-TW/settings.ts deleted file mode 100644 index dd45151a8a47fcc9367704a3bb947cac24638cba..0000000000000000000000000000000000000000 --- a/src/locales/zh-TW/settings.ts +++ /dev/null @@ -1,55 +0,0 @@ -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': '關', -}; diff --git a/src/pages/user/login/_mock.ts b/src/pages/user/login/_mock.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c7698f6dd5792ce00f833a586e106cc973d09ce --- /dev/null +++ b/src/pages/user/login/_mock.ts @@ -0,0 +1,36 @@ +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, +}; diff --git a/src/pages/user/login/components/Login/LoginContext.tsx b/src/pages/user/login/components/Login/LoginContext.tsx new file mode 100644 index 0000000000000000000000000000000000000000..ae571e0db3dd5fbbd1e5b1248947b9c9ab4ad4df --- /dev/null +++ b/src/pages/user/login/components/Login/LoginContext.tsx @@ -0,0 +1,13 @@ +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 = createContext({}); + +export default LoginContext; diff --git a/src/pages/user/login/components/Login/LoginItem.tsx b/src/pages/user/login/components/Login/LoginItem.tsx new file mode 100644 index 0000000000000000000000000000000000000000..6daea72b5242d22e05f25b8b7638abd07e98dc13 --- /dev/null +++ b/src/pages/user/login/components/Login/LoginItem.tsx @@ -0,0 +1,196 @@ +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 = Pick>; + +export type WrappedLoginItemProps = Omit; +export type LoginItemKeyType = keyof typeof ItemMap; +export interface LoginItemType { + UserName: React.FC; + Password: React.FC; + Mobile: React.FC; + Captcha: React.FC; +} + +export interface LoginItemProps { + name?: string; + rules?: any[]; + style?: React.CSSProperties; + onGetCaptcha?: (event?: MouseEvent) => void | Promise | 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 { + 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 ( + + + + {getFieldDecorator(name, options)()} + + + + + + + ); + } + return ( + + {getFieldDecorator(name, options)()} + + ); + } +} + +const LoginItem: Partial = {}; + +Object.keys(ItemMap).forEach(key => { + const item = ItemMap[key]; + LoginItem[key] = (props: LoginItemProps) => ( + + {context => ( + + )} + + ); +}); + +export default LoginItem as LoginItemType; diff --git a/src/pages/user/login/components/Login/LoginSubmit.tsx b/src/pages/user/login/components/Login/LoginSubmit.tsx new file mode 100644 index 0000000000000000000000000000000000000000..e4d75cb6e1a672562a1ace801af177eee2061c9c --- /dev/null +++ b/src/pages/user/login/components/Login/LoginSubmit.tsx @@ -0,0 +1,23 @@ +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 = ({ className, ...rest }) => { + const clsString = classNames(styles.submit, className); + return ( + + + + + + + + + + + + +
+ ); + } +} + +export default Form.create()(Register); diff --git a/src/pages/user/register/locales/en-US.ts b/src/pages/user/register/locales/en-US.ts new file mode 100644 index 0000000000000000000000000000000000000000..7609fc22fc6777b80a748c879aadbb7f68900e76 --- /dev/null +++ b/src/pages/user/register/locales/en-US.ts @@ -0,0 +1,78 @@ +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', +}; diff --git a/src/pages/user/register/locales/zh-CN.ts b/src/pages/user/register/locales/zh-CN.ts new file mode 100644 index 0000000000000000000000000000000000000000..4ca4078ea3521c3b5f3a860732f29c6bf0bfc2cc --- /dev/null +++ b/src/pages/user/register/locales/zh-CN.ts @@ -0,0 +1,74 @@ +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': '语言', +}; diff --git a/src/pages/user/register/locales/zh-TW.ts b/src/pages/user/register/locales/zh-TW.ts new file mode 100644 index 0000000000000000000000000000000000000000..6c17f83b2fa319f1bab5f8b9e5415c5c71df4d9d --- /dev/null +++ b/src/pages/user/register/locales/zh-TW.ts @@ -0,0 +1,74 @@ +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': '語言', +}; diff --git a/src/pages/user/register/model.ts b/src/pages/user/register/model.ts new file mode 100644 index 0000000000000000000000000000000000000000..bedce185b28eaf6a623fbb7356b99a8ad90793ff --- /dev/null +++ b/src/pages/user/register/model.ts @@ -0,0 +1,54 @@ +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: (func: (state: StateType) => T) => T }, +) => void; + +export interface ModelType { + namespace: string; + state: StateType; + effects: { + submit: Effect; + }; + reducers: { + registerHandle: Reducer; + }; +} + +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; diff --git a/src/pages/user/register/service.ts b/src/pages/user/register/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f8d0117dfc394d0e5d4da9beaf920c5fe1d6a0e --- /dev/null +++ b/src/pages/user/register/service.ts @@ -0,0 +1,9 @@ +import request from 'umi-request'; +import { UserRegisterParams } from './index'; + +export async function fakeRegister(params: UserRegisterParams) { + return request('/api/register', { + method: 'POST', + data: params, + }); +} diff --git a/src/pages/user/register/style.less b/src/pages/user/register/style.less new file mode 100644 index 0000000000000000000000000000000000000000..e3ee3b445d5cd666c8bbe032f95a235a99678790 --- /dev/null +++ b/src/pages/user/register/style.less @@ -0,0 +1,57 @@ +@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; + } + } +}