提交 4f93ea1562a08d7f140adc258f6df475530ae67a
1 个父辈
f035d04e
chore: update blocks and improve the local dev expirence
正在显示
12 个修改的文件
包含
89 行增加
和
36 行删除
1 | + | |
1 | 2 | export default { |
2 | 3 | plugins: [ |
3 | 4 | ['umi-plugin-block-dev', { |
4 | - 'layout': 'ant-design-pro', | |
5 | + layout: process.env.LAYOUT || 'ant-design-pro', | |
6 | + menu: { | |
7 | + name: process.env.BLOCK, | |
8 | + icon: 'home', | |
9 | + }, | |
5 | 10 | }], |
6 | 11 | ['umi-plugin-react', { |
7 | 12 | 'dva': true, |
8 | 13 | 'antd': true, |
9 | - }] | |
14 | + }], | |
15 | + require.resolve('./plugin'), | |
10 | 16 | ], |
11 | -} | |
17 | +}; | ... | ... |
1 | 1 | # umi-blocks |
2 | 2 | |
3 | -Official collection of some high quality blocks. | |
3 | +Official block collection from umi community. | |
4 | 4 | |
5 | 5 | ## Usage |
6 | 6 | |
7 | -```shell | |
8 | -$ umi block list | |
9 | -$ umi block add [A block name in list, or any github address of a umi block] | |
7 | +### Install Dependencies | |
8 | + | |
9 | +```bash | |
10 | +$ yarn | |
10 | 11 | ``` |
11 | 12 | |
12 | -You can visit umi [doc](https://umijs.org/guide/block.html) for find out more info about umi block. | |
13 | +### View Block or Template | |
13 | 14 | |
14 | -## Contribute | |
15 | +> Specify the block via BLOCK env. | |
15 | 16 | |
16 | -You can create a umi block and make a PR for us! | |
17 | +```bash | |
18 | +$ BLOCK=templates/user-dashboard yarn start | |
19 | +``` | |
17 | 20 | |
18 | -How to create a block: | |
21 | +### Create Block | |
19 | 22 | |
20 | -```shell | |
21 | -$ yarn create umi --block | |
23 | +```bash | |
24 | +# Create | |
25 | +$ BLOCK=templates/my-template yarn run create | |
26 | + | |
27 | +# Debug | |
28 | +$ BLOCK=templates/my-template yarn start | |
22 | 29 | ``` |
30 | + | |
31 | +You can visit umi [doc](https://umijs.org/guide/block.html) for find out more info about umi block. | |
32 | + | |
33 | +If you are done, make a PR for this. | |
34 | + | |
35 | +## LICENSE | |
36 | + | |
37 | +MIT | ... | ... |
blocks/blank/src/snapshot.png
0 → 100644
9.6 KB
blocks/demo/.umirc.js
已删除
100644 → 0
blocks/demo/snapshot.png
0 → 100644
8.9 KB
1 | 1 | { |
2 | 2 | "private": true, |
3 | 3 | "scripts": { |
4 | + "start": "UMI_UI=none umi dev", | |
4 | 5 | "lint:style": "stylelint \"src/**/*.less\" --syntax less", |
5 | 6 | "lint": "eslint --ext .js src mock tests && npm run lint:style", |
6 | 7 | "lint:fix": "eslint --fix --ext .js src mock tests && npm run lint:style", |
... | ... | @@ -10,6 +11,7 @@ |
10 | 11 | "build": "node ./_scripts/generate.js" |
11 | 12 | }, |
12 | 13 | "devDependencies": { |
14 | + "@ant-design/pro-layout": "^4.5.16", | |
13 | 15 | "babel-eslint": "^10.0.1", |
14 | 16 | "eslint": "^5.4.0", |
15 | 17 | "eslint-config-airbnb": "^17.0.0", |
... | ... | @@ -30,7 +32,8 @@ |
30 | 32 | "stylelint-config-standard": "^18.0.0", |
31 | 33 | "umi": "^2.3.0-0", |
32 | 34 | "umi-plugin-block-dev": "^2.0.0", |
33 | - "umi-plugin-react": "^1.3.0-0" | |
35 | + "umi-plugin-react": "^1.3.0-0", | |
36 | + "umi-request": "^1.2.6" | |
34 | 37 | }, |
35 | 38 | "lint-staged": { |
36 | 39 | "x/**/*.{js,ts,tsx,json,jsx,less}": [ | ... | ... |
plugin.js
0 → 100644
1 | +import { join } from 'path'; | |
2 | +import { readdirSync } from 'fs'; | |
3 | + | |
4 | +if (process.env.BLOCK) { | |
5 | + process.env.PAGES_PATH = join(process.env.BLOCK, 'src'); | |
6 | +} else { | |
7 | + console.log(` | |
8 | +Please specify the BLOCK env, | |
9 | + | |
10 | +e.g. | |
11 | + | |
12 | +$ BLOCK=templates/user-dashboard yarn start | |
13 | +$ BLOCK=blocks/blank yarn start | |
14 | + `.trim()); | |
15 | + process.exit(1); | |
16 | +} | |
17 | + | |
18 | +function getRoutes(type) { | |
19 | + const dirs = readdirSync(join(__dirname, type)); | |
20 | + const routes = []; | |
21 | + for (const dir of dirs) { | |
22 | + if (dir.charAt(0) === '.') continue; | |
23 | + routes.push({ | |
24 | + path: `/${type}/${dir}`, | |
25 | + component: join(type, dir, 'src', 'index.js'), | |
26 | + }); | |
27 | + } | |
28 | + return routes; | |
29 | +} | |
30 | + | |
31 | +function getRoute() { | |
32 | + return { | |
33 | + path: '/', | |
34 | + component: join(process.env.BLOCK, 'src', 'index.js'), | |
35 | + }; | |
36 | +} | |
37 | + | |
38 | +export default (api) => { | |
39 | + api.modifyRoutes(routes => { | |
40 | + routes[0].routes = [ | |
41 | + getRoute(), | |
42 | + // ...getRoutes('blocks'), | |
43 | + // ...getRoutes('templates'), | |
44 | + ...routes[0].routes.slice(1), | |
45 | + ]; | |
46 | + return routes; | |
47 | + }); | |
48 | +}; | ... | ... |
templates/user-dashboard/.umirc.js
已删除
100644 → 0
请
注册
或
登录
后发表评论