-
Notifications
You must be signed in to change notification settings - Fork 18
/
config.md
326 lines (260 loc) · 6.65 KB
/
config.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
---
nav: 教程
order: 1
group:
title: 基础配置
order: 4
---
## @antdp/config
[![npm](https://img.shields.io/npm/v/@antdp/config.svg?maxAge=3600)](https://www.npmjs.com/package/@antdp/config)
[![npm download](https://img.shields.io/npm/dm/@antdp/config.svg?style=flat)](https://www.npmjs.com/package/@antdp/config)
我们已将 umi 配置包裹了一层, 如果需要 antdp 中能使用自定义配置,你可以使用项目根目录的 `config/config.ts`/`config/config.js`进行配置
## Installation
```bash
npm i @antdp/config --save-dev
```
## Basic Usage
```js
// config/config.{js|ts}
//二次封装的umi配置
import config from '@antdp/config';
// 路由数据
import router from './router.json';
/**开发代理配置*/
import proxy from './proxy';
export default config(router, {
proxy,
});
```
## Interface
```typescript
import { IConfig, IRoute } from '@umijs/max';
export interface Options extends Omit<IConfig, 'routes'> {
routes: IRoute;
}
export interface Config {
(routes?: IRoute, optiosn?: Options): IConfig;
}
declare var config: Config;
export default config;
```
## define 配置
### ANTD_IS_TABS
是否显示 Tab 选项卡,默认值`true`显示
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {
+ ANTD_IS_TABS: true
},
);
```
### ANTD_IS_IFRAME_RENDER
是否使用 iframe 展示内容,默认值`true`开启
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {
+ ANTD_IS_IFRAME_RENDER: true
},
);
```
### ANTD_IS_STORAGE
默认 `sessionStorage` 存储,如果需要使用 `localStorage` 存储,设置为 `false`
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {
+ ANTD_IS_STORAGE: false
},
);
```
### ANTD_IS_BREADCRUMB
是否展示面包屑, Tab 选项卡优先级大于面包屑
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {
+ ANTD_IS_BREADCRUMB: true
},
);
```
### ANTD_AUTH_CONF
是否开启权限验证 默认值`false`不启用
- `auth_menu` 储存菜单路由权限---本地 keys 默认值`authMenu`
- `auth_btn` 储存按钮路径权限---本地 keys 默认值 `authBtn`
- `auth_check_url` 判断路径是否有权限的字段 默认值`menuUrl`,如果字段设置为`undefined`则`auth_menu`和`auth_btn`储存形式为 `["/web"]`,反之储存形式为`[{menuUrl:"/web"}]`,
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {
+ ANTD_AUTH_CONF: {
+ auth_menu:"authMenu",
+ auth_btn:"authBtn",
+ auth_check_url:undefined
}
},
);
```
### ANTD_MENU_IS_SHOW
是否显示 左侧菜单,默认值`true`
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {
+ ANTD_MENU_IS_SHOW: true
},
);
```
### ANTD_HEAD_IS_SHOW
是否显示 head 头部,默认值`true`
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {
+ ANTD_HEAD_IS_SHOW: true
},
);
```
### ANTD_MENU_SEARCH_IS_SHOW
是否开启菜单栏搜索,默认值`false`
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {
+ ANTD_MENU_SEARCH_IS_SHOW: true
},
);
```
## locale 配置
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {},
locale: {
// 默认使用 src/locales/zh-CN.ts 作为多语言文件
+ default: 'zh-CN',
+ antd: true,
// default true, when it is true, will use `navigator.language` overwrite default
// baseNavigator: true,
/**
* [国际化] 控制台提示 Warning: The current popular language does not exist, please check the locales folder! 警告信息
* https://github.com/umijs/umi/issues/4363#issuecomment-616134434
* 警用 `baseNavigator` 和 `title` 两个配置项 可以解决国际化警告问题
*/
+ baseNavigator: false,
+ title: false,
},
},
);
```
## @umijs/max 配置
### request
开启 `useRequest` 和 `request`,默认`未开启`
- `dataField` 该配置的默认值是 data。该配置的主要目的是方便 useRequest 直接消费数据。如果你想要在消费数据时拿到后端的原始数据,需要在这里配置 `dataField` 为 ''
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {},
+ request:{}
);
```
### react-query
开启`react-query`,默认`未开启`
- `devtool`: boolean,是否开启 react query 官方 devtool 工具,默认 `true`
- `queryClient`: boolean, 是否注册全局的 QueryClient 和 QueryClientProvier,默认 `true`
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {},
+ reactQuery: {
// 是否开启 react query 官方 devtool 工具
+ devtool: false,
+ queryClient: true,
},
);
```
### useModel
开启`useModel`,默认`未开启`
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {},
+ model: {},
);
```
### dva
开启`dva`,默认`未开启`
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {},
+ dva: {},
);
```
### styled-components
[styled-components](https://styled-components.com/) 样式方案
- `babelPlugin`: Object,开启 styled-components 的 babel 插件,仅 dev 模式有效
比如:
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {},
+ styledComponents: {},
);
```
### valtio
`valtio` 数据流方案
```diff
import config from '@antdp/config';
import proxy from './proxy';
import router from './router.json';
export default config(router, {
proxy,
define: {},
+ valtio: {},
);
```
[更多配置参考 umi](https://umijs.org/docs/api/config)