diff --git a/README.md b/README.md index 84df26a75f8d29dcd4c94d467cff8d29010fe645..5840e2ae97006cc8eb047733c2f52f03fd46e135 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ We need your help: https://github.com/ant-design/ant-design-pro/issues/120 - :triangular_ruler: **Common Templates**: Typical templates for enterprise applications - :rocket: **State of The Art Development**: Newest development stack of React/dva/antd - :iphone: **Responsive**: Designed for varies of screen size -- :art: **Themeing**: Customizable theme with simple config +- :art: **Theming**: Customizable theme with simple config - :globe_with_meridians: **International**: Built-in i18n solution - :gear: **Best Practice**: Solid workflow make your code health - :1234: **Mock development**: Easy to use mock development solution diff --git a/package.json b/package.json index 7282742ff5dbbb59d2528ef318893c12711b9285..290d6799423ae3364e00f14b172743f53d262e71 100755 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "dva": "^2.1.0", "dva-loading": "^1.0.4", "enquire-js": "^0.1.1", - "fastclick": "^1.0.6", "lodash": "^4.17.4", "lodash-decorators": "^4.4.1", "moment": "^2.19.1", @@ -77,7 +76,7 @@ "stylelint-config-standard": "^18.0.0" }, "optionalDependencies": { - "nightmare": "^2.10.0" + "puppeteer": "^1.1.1" }, "lint-staged": { "**/*.{js,jsx}": "lint-staged:js", diff --git a/src/components/Login/demo/basic.md b/src/components/Login/demo/basic.md index 1fca454f42f12939881cdb97eff3a30f247cce48..5fbd0ca25448f92e964538c545edaf07d595ff27 100644 --- a/src/components/Login/demo/basic.md +++ b/src/components/Login/demo/basic.md @@ -1,9 +1,11 @@ --- order: 0 -title: Standard Login +title: + zh-CN: 标准登录 + en-US: Standard Login --- -支持账号密码及手机号登录两种模式。 +Support login with account and mobile number. ````jsx import Login from 'ant-design-pro/lib/Login'; @@ -26,7 +28,7 @@ class LoginDemo extends React.Component { if (!err && (values.username !== 'admin' || values.password !== '888888')) { setTimeout(() => { this.setState({ - notice: '账号或密码错误!', + notice: 'The combination of username and password is incorrect!', }); }, 500); } @@ -50,7 +52,7 @@ class LoginDemo extends React.Component { onTabChange={this.onTabChange} onSubmit={this.onSubmit} > - + { this.state.notice && @@ -58,21 +60,21 @@ class LoginDemo extends React.Component { - + console.log('Get captcha!')} name="captcha" />
- 自动登录 - 忘记密码 + Keep me logged in + Forgot password
- 登录 + Login
- 其他登录方式 + Other login methods - 注册账户 + Register
); diff --git a/src/components/Login/index.en-US.md b/src/components/Login/index.en-US.md new file mode 100644 index 0000000000000000000000000000000000000000..bc38579fe68db8de84bc4a5bb2d9356d0004e38f --- /dev/null +++ b/src/components/Login/index.en-US.md @@ -0,0 +1,47 @@ +--- +title: Login +cols: 1 +order: 15 +--- + +Support multiple common ways of login with built-in controls. You can choose your own combinations and use with your custom controls. + +## API + +### Login + +Property | Description | Type | Default +----|------|-----|------ +defaultActiveKey | default key to activate the tab panel | String | - +onTabChange | callback on changing tabs | (key) => void | - +onSubmit | callback on submit | (err, values) => void | - + +### Login.Tab + +Property | Description | Type | Default +----|------|-----|------ +key | key of the tab | String | - +tab | displayed text of the tab | ReactNode | - + +### Login.UserName + +Property | Description | Type | Default +----|------|-----|------ +name | name of the control, also the key of the submitted data | String | - +rules | validation rules, same with [option.rules](getFieldDecorator(id, options)) in Form getFieldDecorator(id, options) | object[] | - + +Apart from the above properties, Login.Username also support all properties of antd.Input, together with the default values of basic settings, such as _placeholder_, _size_ and _prefix_. All of these default values can be over-written. + +### Login.Password, Login.Mobile are the same as Login.UserName + +### Login.Captcha + +Property | Description | Type | Default +----|------|-----|------ +onGetCaptcha | callback on getting a new Captcha | () => void | - + +Apart from the above properties, _Login.Captcha_ support the same properties with _Login.UserName_. + +### Login.Submit + +Support all properties of _antd.Button_. \ No newline at end of file diff --git a/src/components/Login/index.md b/src/components/Login/index.zh-CN.md similarity index 96% rename from src/components/Login/index.md rename to src/components/Login/index.zh-CN.md index a56be08e0ae1d4ccda92e82c0d2b34515e563c0a..98f0f624f0754f9798d69a6b05e10ea382cb6d93 100644 --- a/src/components/Login/index.md +++ b/src/components/Login/index.zh-CN.md @@ -1,7 +1,5 @@ --- -title: - en-US: Login - zh-CN: Login +title: Login subtitle: 登录 cols: 1 order: 15 @@ -37,7 +35,7 @@ rules | 校验规则,同 Form getFieldDecorator(id, options) 中 [option.rules ### Login.Password、Login.Mobile 同 Login.UserName -### Login.Captcha +### Login.Captcha 参数 | 说明 | 类型 | 默认值 ----|------|-----|------ @@ -48,4 +46,3 @@ onGetCaptcha | 点击获取校验码的回调 | () => void | - ### Login.Submit 支持 antd.Button 的所有属性。 - diff --git a/src/components/Login/map.js b/src/components/Login/map.js index 81fd7a20be72af423674319fcc8c059c08eab1a5..4f596fff57d2bdee01758e9c01895eb358a4ab21 100644 --- a/src/components/Login/map.js +++ b/src/components/Login/map.js @@ -11,7 +11,7 @@ const map = { placeholder: 'admin', }, rules: [{ - required: true, message: '请输入账户名!', + required: true, message: 'Please enter username!', }], }, Password: { @@ -23,7 +23,7 @@ const map = { placeholder: '888888', }, rules: [{ - required: true, message: '请输入密码!', + required: true, message: 'Please enter password!', }], }, Mobile: { @@ -31,12 +31,12 @@ const map = { props: { size: 'large', prefix: , - placeholder: '手机号', + placeholder: 'mobile number', }, rules: [{ - required: true, message: '请输入手机号!', + required: true, message: 'Please enter mobile number!', }, { - pattern: /^1\d{10}$/, message: '手机号格式错误!', + pattern: /^1\d{10}$/, message: 'Wrong mobile number format!', }], }, Captcha: { @@ -44,10 +44,10 @@ const map = { props: { size: 'large', prefix: , - placeholder: '验证码', + placeholder: 'captcha', }, rules: [{ - required: true, message: '请输入验证码!', + required: true, message: 'Please enter Captcha!', }], }, }; diff --git a/src/e2e/home.e2e.js b/src/e2e/home.e2e.js index 61b0cd83a89568f5a88364c15196f2ff5b1064e4..1a5d95136f5a7cc0f8739415cae3f13bd4b6b573 100644 --- a/src/e2e/home.e2e.js +++ b/src/e2e/home.e2e.js @@ -1,9 +1,14 @@ -import Nightmare from 'nightmare'; +import puppeteer from 'puppeteer'; describe('Homepage', () => { it('it should have logo text', async () => { - const page = Nightmare().goto('http://localhost:8000'); - const text = await page.wait('h1').evaluate(() => document.body.innerHTML).end(); + const browser = await puppeteer.launch(); + const page = await browser.newPage(); + await page.goto('http://localhost:8000'); + await page.waitForSelector('h1'); + const text = await page.evaluate(() => document.body.innerHTML); expect(text).toContain('

Ant Design Pro

'); + await page.close(); + browser.close(); }); }); diff --git a/src/e2e/login.e2e.js b/src/e2e/login.e2e.js index 703efc0b9ff83f16cd46c396319656f674b1a0cb..5211a3b49f1d6dca169429871283f89dfc512c92 100644 --- a/src/e2e/login.e2e.js +++ b/src/e2e/login.e2e.js @@ -1,32 +1,36 @@ -import Nightmare from 'nightmare'; +import puppeteer from 'puppeteer'; describe('Login', () => { + let browser; let page; - beforeEach(() => { - page = Nightmare(); - page - .goto('http://localhost:8000/') - .evaluate(() => { - window.localStorage.setItem('antd-pro-authority', 'guest'); - }) - .goto('http://localhost:8000/#/user/login'); + + beforeAll(async () => { + browser = await puppeteer.launch(); + }); + + beforeEach(async () => { + page = await browser.newPage(); + await page.goto('http://localhost:8000/#/user/login'); + await page.evaluate(() => window.localStorage.setItem('antd-pro-authority', 'guest')); }); + afterEach(() => page.close()); + it('should login with failure', async () => { - await page.type('#userName', 'mockuser') - .type('#password', 'wrong_password') - .click('button[type="submit"]') - .wait('.ant-alert-error') // should display error - .end(); + await page.type('#userName', 'mockuser'); + await page.type('#password', 'wrong_password'); + await page.click('button[type="submit"]'); + await page.waitForSelector('.ant-alert-error'); // should display error }); it('should login successfully', async () => { - const text = await page.type('#userName', 'admin') - .type('#password', '888888') - .click('button[type="submit"]') - .wait('.ant-layout-sider h1') // should display error - .evaluate(() => document.body.innerHTML) - .end(); + await page.type('#userName', 'admin'); + await page.type('#password', '888888'); + await page.click('button[type="submit"]'); + await page.waitForSelector('.ant-layout-sider h1'); // should display error + const text = await page.evaluate(() => document.body.innerHTML); expect(text).toContain('

Ant Design Pro

'); }); + + afterAll(() => browser.close()); }); diff --git a/src/index.js b/src/index.js index ef86ed2a1d732c4feafe38fa9d8f9bd0b28b7692..b4da8eed873f932e1350418237d42d76acea451b 100644 --- a/src/index.js +++ b/src/index.js @@ -7,7 +7,6 @@ import createHistory from 'history/createHashHistory'; // import createHistory from 'history/createBrowserHistory'; import createLoading from 'dva-loading'; import 'moment/locale/zh-cn'; -import FastClick from 'fastclick'; import './rollbar'; import './index.less'; @@ -28,7 +27,4 @@ app.router(require('./router').default); // 5. Start app.start('#root'); - -FastClick.attach(document.body); - export default app._store; // eslint-disable-line diff --git a/src/routes/List/TableList.js b/src/routes/List/TableList.js index e990c1b4b880c906f0fadab6d6b2da6de23c53b0..feaf1f0768993c893178feadc0874548213261d5 100644 --- a/src/routes/List/TableList.js +++ b/src/routes/List/TableList.js @@ -22,6 +22,7 @@ const CreateForm = Form.create()((props) => { const okHandle = () => { form.validateFields((err, fieldsValue) => { if (err) return; + form.resetFields(); handleAdd(fieldsValue); }); };