Skip to content

Commit dba40e1

Browse files
committed
feat: use @umijs/plugin-antd-mobile
1 parent 36f481f commit dba40e1

File tree

11 files changed

+28
-57
lines changed

11 files changed

+28
-57
lines changed

.eslintrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

config/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// umijs@3 规则,包名以@umijs/plugin、@umijs/preset 或者 umi-plugin、umi-preset 开头的,将会被直接使用。
2-
// 所以这个项目使用了 preset: umi-preset-mobile5
2+
// 所以这个项目使用了 plugins: @umijs/plugin-antd-mobile @umijs/plugin-esbuild @alitajs/hd
3+
// 下方配置仅需要显式使用 alita 插件
34
export default {
5+
plugins: ['@alitajs/hd'],
6+
hd: {},
7+
esbuild: {},
48
};

package.json

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
"start": "umi dev",
55
"build": "umi build",
66
"test": "umi test",
7-
"lint": "eslint {src,mock,tests}/**/*.{ts,tsx} --fix",
8-
"precommit": "lint-staged"
7+
"prettier": "prettier -c --write \"**/*\""
98
},
109
"dependencies": {
11-
"umi-preset-mobile5": "^2.8.24",
10+
"@alitajs/hd": "^2.8.30",
11+
"@umijs/plugin-antd-mobile": "^1.1.0",
12+
"@umijs/plugin-esbuild": "^1.4.1",
13+
"antd-mobile": "^5.0.0-rc.7",
14+
"prettier": "^2.5.1",
1215
"react": "^16.8.6",
1316
"react-dom": "^16.8.6"
1417
},
@@ -18,25 +21,7 @@
1821
"@types/react-dom": "^16.0.11",
1922
"@types/react-test-renderer": "^16.0.3",
2023
"babel-eslint": "^9.0.0",
21-
"eslint": "^5.4.0",
22-
"eslint-config-umi": "^1.4.0",
23-
"eslint-plugin-flowtype": "^2.50.0",
24-
"eslint-plugin-import": "^2.14.0",
25-
"eslint-plugin-jsx-a11y": "^5.1.1",
26-
"eslint-plugin-react": "^7.11.1",
27-
"husky": "^0.14.3",
28-
"lint-staged": "^7.2.2",
2924
"react-test-renderer": "^16.7.0",
3025
"umi": "^3.5.18"
31-
},
32-
"lint-staged": {
33-
"*.{ts,tsx}": [
34-
"eslint --fix",
35-
"git add"
36-
],
37-
"*.{js,jsx}": [
38-
"eslint --fix",
39-
"git add"
40-
]
4126
}
4227
}

src/global.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
html, body, #root {
1+
html,
2+
body,
3+
#root {
24
height: 100%;
35
}
46

src/layouts/index.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
.normal {
32
font-family: Georgia, sans-serif;
43
text-align: center;

src/layouts/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import styles from './index.css';
33

4-
const BasicLayout: React.FC = props => {
4+
const BasicLayout: React.FC = (props) => {
55
return (
66
<div className={styles.normal}>
77
<h1 className={styles.title}>Yay! Welcome to umi!</h1>

src/pages/index/__tests__/index.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ import Index from '..';
33
import React from 'react';
44
import renderer, { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer';
55

6-
76
describe('Page: index', () => {
87
it('Render correctly', () => {
98
const wrapper: ReactTestRenderer = renderer.create(<Index />);
109
expect(wrapper.root.children.length).toBe(1);
1110
const outerLayer = wrapper.root.children[0] as ReactTestInstance;
1211
expect(outerLayer.type).toBe('div');
1312
expect(outerLayer.children.length).toBe(2);
14-
1513
});
1614
});

src/pages/index/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { Button } from 'antd-mobile';
33
import { history } from 'umi';
44
import styles from './index.css';
55

6-
export default function ({ }) {
6+
export default function ({}) {
77
return (
88
<div className={styles.normal}>
99
<div className={styles.welcome} />
10-
<p className={styles.description}>To get started, edit <code>src/pages/index.js</code> and save to reload.</p>
10+
<p className={styles.description}>
11+
To get started, edit <code>src/pages/index.js</code> and save to reload.
12+
</p>
1113
<Button size="large" color="primary" fill="solid" block onClick={() => history.push('/list')}>
1214
Go to List
1315
</Button>

src/pages/list/index.tsx

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,28 @@ async function mockRequest() {
1010
return [];
1111
}
1212
count++;
13-
return [
14-
'A',
15-
'B',
16-
'C',
17-
'D',
18-
'E',
19-
'F',
20-
'G',
21-
'H',
22-
'I',
23-
'J',
24-
'K',
25-
'L',
26-
'M',
27-
'N',
28-
'O',
29-
'P',
30-
'Q',
31-
];
13+
return ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q'];
3214
}
3315

3416
export default () => {
3517
const [data, setData] = useState<string[]>([]);
3618
const [hasMore, setHasMore] = useState(true);
3719
async function loadMore() {
3820
const append = await mockRequest();
39-
setData(val => [...val, ...append]);
21+
setData((val) => [...val, ...append]);
4022
setHasMore(append.length > 0);
4123
}
4224

4325
return (
4426
<>
4527
<List>
4628
{data.map((item, index) => (
47-
<List.Item key={index} onClick={() => history.goBack()}>{item}</List.Item>
29+
<List.Item key={index} onClick={() => history.goBack()}>
30+
{item}
31+
</List.Item>
4832
))}
4933
</List>
5034
<InfiniteScroll loadMore={loadMore} hasMore={hasMore} />
5135
</>
52-
)
53-
}
36+
);
37+
};

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"strict": true,
1313
"paths": {
1414
"@/*": ["src/*"],
15-
"@@/*": ["src/.umi/*"],
15+
"@@/*": ["src/.umi/*"]
1616
},
1717
"allowSyntheticDefaultImports": true
1818
},

0 commit comments

Comments
 (0)