tntd 1.3.65 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/.eslintignore +2 -1
  2. package/babel.config.js +2 -2
  3. package/dist/0645cf743e4e44ca9da321d689897f07.png +0 -0
  4. package/dist/09db77de0c24fa0f45f8a5cf299a3d11.png +0 -0
  5. package/dist/1.tntd.js +12 -0
  6. package/dist/1d0b52448de217857b270af807e9360d.png +0 -0
  7. package/dist/25d78d77c9c2f0d403e5d899ceb5b1ef.png +0 -0
  8. package/dist/27fa44ff0c98e1594d79b73045aabedf.png +0 -0
  9. package/dist/2c95075adb68d6131b59cae9fa554ec2.png +0 -0
  10. package/dist/377c871d922a25c773a9e7c2f42ed7c0.png +0 -0
  11. package/dist/3d901589b40bd56ff1fde2bbb700bfe1.png +0 -0
  12. package/dist/4abe481e130d7be0574e45573de8beb7.png +0 -0
  13. package/dist/95ee2260a509cd630d89c5367ed1973b.png +0 -0
  14. package/dist/b9dd5ff3622296fbee51ed68f4bca1bf.png +0 -0
  15. package/dist/bd2921989f9296089ba58efb7a76f3ef.png +0 -0
  16. package/dist/stats.json +45855 -0
  17. package/dist/tntd.css +1 -0
  18. package/dist/tntd.js +15 -0
  19. package/es/ArrayInput/README.md +129 -0
  20. package/es/ArrayInput/icon.js +24 -0
  21. package/es/ArrayInput/index.js +274 -0
  22. package/es/ArrayInput/index.less +20 -0
  23. package/es/AuthContext.js +4 -0
  24. package/es/Columns/README.md +149 -0
  25. package/es/Columns/index.js +82 -0
  26. package/es/Columns/index.less +75 -0
  27. package/es/DevelopmentLogin/LoginModal.js +117 -0
  28. package/es/DevelopmentLogin/README.md +49 -0
  29. package/es/DevelopmentLogin/index.js +40 -0
  30. package/es/Ellipsis/README.md +104 -0
  31. package/es/Ellipsis/Svg/CopySVG.js +63 -0
  32. package/es/Ellipsis/Svg/TickSVG.js +41 -0
  33. package/es/Ellipsis/index.js +139 -0
  34. package/es/Ellipsis/index.less +56 -0
  35. package/es/Handle/README.md +104 -0
  36. package/es/Handle/index.js +86 -0
  37. package/es/Handle/index.less +9 -0
  38. package/es/Icon/README.md +119 -0
  39. package/es/Icon/fonts/demo.css +539 -0
  40. package/es/Icon/fonts/demo_index.html +3345 -0
  41. package/es/Icon/fonts/iconfont.css +569 -0
  42. package/es/Icon/fonts/iconfont.eot +0 -0
  43. package/es/Icon/fonts/iconfont.js +41 -0
  44. package/es/Icon/fonts/iconfont.json +975 -0
  45. package/es/Icon/fonts/iconfont.svg +440 -0
  46. package/es/Icon/fonts/iconfont.ttf +0 -0
  47. package/es/Icon/fonts/iconfont.woff +0 -0
  48. package/es/Icon/fonts/iconfont.woff2 +0 -0
  49. package/es/Icon/iconList.js +1 -0
  50. package/es/Icon/index.js +26 -0
  51. package/es/Icon/index.less +9 -0
  52. package/es/Img/Contain.js +69 -0
  53. package/es/Img/Cover.js +126 -0
  54. package/es/Img/README.md +131 -0
  55. package/es/Img/index.js +76 -0
  56. package/es/Layout/ActionsContext.js +3 -0
  57. package/es/Layout/AppList.js +223 -0
  58. package/es/Layout/Application.js +113 -0
  59. package/es/Layout/Avatar.js +112 -0
  60. package/es/Layout/CompatibleLanguage.js +177 -0
  61. package/es/Layout/EnterpriseLayout/Avatar.js +138 -0
  62. package/es/Layout/EnterpriseLayout/Language.js +81 -0
  63. package/es/Layout/EnterpriseLayout/Theme.js +75 -0
  64. package/es/Layout/EnterpriseLayout/index.js +31 -0
  65. package/es/Layout/GlobalNavigation/NavigationPopup.js +396 -0
  66. package/es/Layout/GlobalNavigation/index.js +137 -0
  67. package/es/Layout/Header.js +95 -0
  68. package/es/Layout/HeaderActions.js +105 -0
  69. package/es/Layout/HeaderNavs.js +93 -0
  70. package/es/Layout/HeaderTabs.js +264 -0
  71. package/es/Layout/Iconfont.js +4 -0
  72. package/es/Layout/Language.js +81 -0
  73. package/es/Layout/Layout.js +232 -0
  74. package/es/Layout/Logo.js +86 -0
  75. package/es/Layout/OrgAppList.js +304 -0
  76. package/es/Layout/README.md +783 -0
  77. package/es/Layout/SideMenu.js +338 -0
  78. package/es/Layout/Theme.js +105 -0
  79. package/es/Layout/checkAuth.js +29 -0
  80. package/es/Layout/createActions.js +39 -0
  81. package/es/Layout/images/avatar/empty.png +0 -0
  82. package/es/Layout/images/avatar/female1.png +0 -0
  83. package/es/Layout/images/avatar/female2.png +0 -0
  84. package/es/Layout/images/avatar/female3.png +0 -0
  85. package/es/Layout/images/avatar/female4.png +0 -0
  86. package/es/Layout/images/avatar/female5.png +0 -0
  87. package/es/Layout/images/avatar/female6.png +0 -0
  88. package/es/Layout/images/avatar/male1.png +0 -0
  89. package/es/Layout/images/avatar/male2.png +0 -0
  90. package/es/Layout/images/avatar/male3.png +0 -0
  91. package/es/Layout/images/avatar/male4.png +0 -0
  92. package/es/Layout/images/avatar/male5.png +0 -0
  93. package/es/Layout/images/avatar/male6.png +0 -0
  94. package/es/Layout/images/index.js +35 -0
  95. package/es/Layout/images/logo/baldur.svg +14 -0
  96. package/es/Layout/images/logo/bi.svg +14 -0
  97. package/es/Layout/images/logo/bridge.svg +15 -0
  98. package/es/Layout/images/logo/convert.svg +18 -0
  99. package/es/Layout/images/logo/dataocean.svg +31 -0
  100. package/es/Layout/images/logo/default.svg +19 -0
  101. package/es/Layout/images/logo/dispatch.svg +14 -0
  102. package/es/Layout/images/logo/graph.svg +26 -0
  103. package/es/Layout/images/logo/handle.svg +10 -0
  104. package/es/Layout/images/logo/indicator.svg +41 -0
  105. package/es/Layout/images/logo/kafka.svg +12 -0
  106. package/es/Layout/images/logo/logo-custom.svg +13 -0
  107. package/es/Layout/images/logo/model.svg +17 -0
  108. package/es/Layout/images/logo/mysql.svg +15 -0
  109. package/es/Layout/images/logo/orion.svg +24 -0
  110. package/es/Layout/images/logo/salaxy.svg +11 -0
  111. package/es/Layout/images/logo/storage.svg +16 -0
  112. package/es/Layout/images/logo/tnt_cli_identify.svg +19 -0
  113. package/es/Layout/images/logo/turing.svg +35 -0
  114. package/es/Layout/images/theme/theme1.svg +35 -0
  115. package/es/Layout/images/theme/theme2.svg +33 -0
  116. package/es/Layout/index.js +122 -0
  117. package/es/Layout/paaslayout/CompactSideMenu.js +167 -0
  118. package/es/Layout/paaslayout/Header.js +77 -0
  119. package/es/Layout/paaslayout/Logo.js +22 -0
  120. package/es/Layout/paaslayout/SideMenu.js +168 -0
  121. package/es/Layout/paaslayout/index.js +233 -0
  122. package/es/Layout/storage.js +47 -0
  123. package/es/Layout/utils.js +136 -0
  124. package/es/LoadingButton/README.md +75 -0
  125. package/es/LoadingButton/index.js +43 -0
  126. package/es/Modal/README.md +59 -0
  127. package/es/Modal/index.js +94 -0
  128. package/es/Modal/index.less +86 -0
  129. package/es/Page/Box.js +72 -0
  130. package/es/Page/README.md +180 -0
  131. package/es/Page/index.js +165 -0
  132. package/es/Page/index.less +144 -0
  133. package/es/Page/utils.js +23 -0
  134. package/es/QueryForm/Field/Checkbox.js +19 -0
  135. package/es/QueryForm/Field/Select.js +78 -0
  136. package/es/QueryForm/Field/SelectInput.js +88 -0
  137. package/es/QueryForm/Field/fieldsMap.js +27 -0
  138. package/es/QueryForm/Field/index.js +155 -0
  139. package/es/QueryForm/README.md +512 -0
  140. package/es/QueryForm/createActions.js +53 -0
  141. package/es/QueryForm/index.js +376 -0
  142. package/es/QueryForm/index.less +133 -0
  143. package/es/QueryForm/useForm.js +7 -0
  144. package/es/QueryListScene/List.js +376 -0
  145. package/es/QueryListScene/QueryForm.js +166 -0
  146. package/es/QueryListScene/QueryListScene.js +76 -0
  147. package/es/QueryListScene/README.md +790 -0
  148. package/es/QueryListScene/Title.js +12 -0
  149. package/es/QueryListScene/Toolbar.js +20 -0
  150. package/es/QueryListScene/createActions.js +72 -0
  151. package/es/QueryListScene/index.js +19 -0
  152. package/es/QueryListScene/index.less +97 -0
  153. package/es/QueryListScene/useActions.js +7 -0
  154. package/es/Select/DropDownWrap.js +116 -0
  155. package/es/Select/README.md +68 -0
  156. package/es/Select/index.js +618 -0
  157. package/es/Table/README.md +109 -0
  158. package/es/Table/ResizableTable/index.js +108 -0
  159. package/es/Table/ResizableTable/index.less +36 -0
  160. package/es/Table/index.js +33 -0
  161. package/es/Title/README.md +106 -0
  162. package/es/Title/index.js +40 -0
  163. package/es/Title/index.less +170 -0
  164. package/es/index.js +19 -0
  165. package/es/locale.js +60 -0
  166. package/package.json +1 -1
  167. package/doc-scripts.config.js +0 -37
  168. package/doc-scripts.renderer.js +0 -11
  169. package/docs/README.md +0 -1643
package/docs/README.md DELETED
@@ -1,1643 +0,0 @@
1
- ## 简介(tntd)
2
-
3
- tntd 是同盾前端 UED 部门,基于特定业务场景开发的一套业务场景组件。
4
-
5
- ### 功能特性
6
-
7
- - Layout, UED 部门统一的外框架组件,包含头整体页面布局、头部导航、菜单
8
- - QueryListScene, 查询列表页,主要适用场景是表单查询 + Table 页面及组件,包含了数据管理,通用逻辑处理如: 分页、查询、重置、表单内容自适应展开、收缩、Loading、轮询等
9
-
10
- ### 环境依赖
11
-
12
- - nodejs、npm
13
- - React、antd
14
-
15
- ### 安装
16
-
17
- - npm install tntd --save
18
-
19
- ### 运行 DEMO
20
-
21
- - npm install
22
- - npm run start
23
-
24
- ### 目录结构
25
-
26
- <pre>
27
- .
28
- ├── components(组件源码)
29
- | ├── layout
30
- | └── querylistscene
31
- ├── lib(babel编译后的代码)
32
- | ├── layout
33
- | └── querylistscene
34
- ├── babel.config.js
35
- ├── package.json
36
- └── README.td
37
- </pre>
38
-
39
- ### 使用
40
-
41
- ```js
42
- import ReactDOM from "react-dom";
43
- import { QueryListScene, Layout } from "tntd";
44
-
45
- const { QueryForm, Field, QueryList } = QueryListScene;
46
- const columns = [
47
- {
48
- title: "ID",
49
- dataIndex: "id",
50
- width: 60,
51
- },
52
- {
53
- title: "项目名称",
54
- dataIndex: "name",
55
- sorter: (a, b) => a.name > b.name,
56
- },
57
- ];
58
- const query = params => {
59
- return new Promise(resolve => {
60
- resolve([
61
- { id: 1, name: "xxx" },
62
- { id: 2, name: "yyy" },
63
- ]);
64
- });
65
- };
66
-
67
- ReactDOM.render(
68
- <Layout
69
- logo=""
70
- name="应用名称"
71
- enName="Application English Name"
72
- userInfo={{}}
73
- menus={[]}
74
- onMenuChange={onMenuChange}
75
- onMenuSelect={onMenuSelect}
76
- onLanguageChange={onLanguageChange}
77
- onThemeChange={onThemeChange}
78
- onAppChange={onAppChange}
79
- >
80
- <QueryListScene query={query} title="查询列表页">
81
- <QueryForm>
82
- <Field type="string" name="name" props={{ placeholder: "名称" }} />
83
- <Field type="date" name="date" />
84
- <Field
85
- type="select"
86
- name="select"
87
- props={{
88
- placeholder: "状态",
89
- options: ["初始化", "运行中", "成功", "失败"],
90
- }}
91
- />
92
- </QueryForm>
93
- <QueryList columns={columns} />
94
- </QueryListScene>
95
- </Layout>,
96
- document.getElementById("root")
97
- );
98
- ```
99
-
100
- ## Layout 外框架组件
101
-
102
- ### 代码演示
103
-
104
- #### 初始化数据
105
-
106
- ```jsx
107
- import { createGlobalStyle } from "styled-components";
108
- import "antd/dist/antd.css";
109
-
110
- const GlobalStyle = createGlobalStyle`
111
- .site-body {
112
- .ichYgh {
113
- padding: 0;
114
- overflow: visible;
115
- }
116
- }
117
- `;
118
-
119
- const menus = [
120
- {
121
- children: [
122
- {
123
- code: "dadicasesearch",
124
- enName: "dadicasesearch",
125
- icon: "home",
126
- menuName: "案件检索",
127
- path: "/orion/case/relation",
128
- },
129
- ],
130
- code: "casegraph",
131
- enName: "casegraph",
132
- groupIcon: "box",
133
- groupName: "案件分析",
134
- },
135
- {
136
- children: [
137
- {
138
- code: "taglist",
139
- enName: "taglist",
140
- icon: "home",
141
- menuName: "标签管理",
142
- path: "/orion/tag/list",
143
- },
144
- {
145
- code: "tagdata",
146
- enName: "tagdata",
147
- icon: "layer-color",
148
- menuName: "打标数据管理",
149
- path: "/orion/tag/datalist",
150
- },
151
- ],
152
- code: "tagmm",
153
- enName: "tagmm",
154
- groupIcon: "warning",
155
- groupName: "标签管理",
156
- },
157
- {
158
- children: [
159
- {
160
- code: "QX0101",
161
- enName: "Organization Manage",
162
- icon: "org",
163
- menuName: "机构管理\t",
164
- path: "/bridge/permission/organization",
165
- },
166
- {
167
- code: "QX0102",
168
- enName: "Role Manage",
169
- icon: "role",
170
- menuName: "角色管理",
171
- path: "/bridge/permission/role",
172
- },
173
- {
174
- code: "QX0103",
175
- enName: "User Manage",
176
- icon: "user-group",
177
- menuName: "用户管理",
178
- path: "/bridge/permission/user",
179
- },
180
- ],
181
- code: "permission",
182
- enName: "Permission Manage",
183
- groupIcon: "user",
184
- groupName: "权限管理",
185
- },
186
- {
187
- children: [
188
- {
189
- code: "QX0201",
190
- enName: "Function Register",
191
- icon: "python",
192
- menuName: "功能注册",
193
- path: "/bridge/system/register",
194
- },
195
- {
196
- code: "QX0202",
197
- enName: "Solution",
198
- icon: "python",
199
- menuName: "解决方案",
200
- path: "/bridge/system/solution",
201
- },
202
- {
203
- code: "QX0203",
204
- enName: "System Configuration",
205
- icon: "Python",
206
- menuName: "系统设置",
207
- path: "/bridge/system/startup",
208
- },
209
- ],
210
- code: "QX0203",
211
- enName: "System Configuration",
212
- groupIcon: "box",
213
- groupName: "解决方案",
214
- },
215
- ];
216
- const userInfo = {
217
- account: "admin",
218
- avatar: "male1",
219
- expiration: 1924963199000,
220
- firstLogin: "0",
221
- gender: 0,
222
- gmtCreate: 1551771456000,
223
- gmtModified: 1570607897000,
224
- lang: "cn",
225
- layout: "default",
226
- orgUuid: "a8202aea546f48979754bdd45c471b08",
227
- roleUuids: '["ee8dbc99831b4a9cb17578b51bbb09e0"]',
228
- salt: "9ac81141a689494eb769d39956bf5656",
229
- simplified: 1,
230
- status: 0,
231
- theme: "default",
232
- tryDate: 1571033960000,
233
- tryTime: 1,
234
- userName: "超级管理员",
235
- uuid: "c693e0ec0a2e4bf8b71eef8152d88a29",
236
- };
237
-
238
- Object.assign(window, {
239
- store: {
240
- menus,
241
- userInfo,
242
- },
243
- });
244
-
245
- ReactDOM.render(<GlobalStyle />, document.getElementById("root"));
246
- ```
247
-
248
- #### 全家桶模式(新)
249
-
250
- ```jsx
251
- import React from "react";
252
- import ReactDOM from "react-dom";
253
- import Layout from "../components/Layout/index";
254
-
255
- const { menus, userInfo } = window.store;
256
- const onMenuChange = param => {
257
- console.log("onMenuChange:", param);
258
- };
259
- const onMenuSelect = param => {
260
- console.log("onMenMenuSelectChange:", param);
261
- };
262
- const onLanguageChange = language => {
263
- console.log("onLanguageChange:", language);
264
- };
265
- const onThemeChange = theme => {
266
- console.log("onThemeChange:", theme);
267
- };
268
- const onAppChange = param => {
269
- console.log("onAppChange", param);
270
- };
271
- const onLogoClick = () => {
272
- console.log("logo click");
273
- };
274
-
275
- ReactDOM.render(
276
- <Layout
277
- logo=""
278
- name="私有云全家桶"
279
- enName="Private Cloud"
280
- selectedAppKey="enterprise"
281
- config={{
282
- globalNavigation: true,
283
- }}
284
- appList={[
285
- { key: "movie", name: "电影图谱" },
286
- { key: "enterprise", name: "企业图谱" },
287
- ]}
288
- userInfo={userInfo}
289
- selectedMenuKey="tagdata"
290
- menus={menus}
291
- onMenuChange={onMenuChange}
292
- onMenuSelect={onMenuSelect}
293
- onLanguageChange={onLanguageChange}
294
- onThemeChange={onThemeChange}
295
- onAppChange={onAppChange}
296
- onLogoClick={onLogoClick}
297
- onLogout={() => alert("do logout")}
298
- ></Layout>,
299
- document.getElementById("root")
300
- );
301
- ```
302
-
303
- #### 全家桶模式(旧)
304
-
305
- ```jsx
306
- import React from "react";
307
- import ReactDOM from "react-dom";
308
- import Layout from "../components/Layout/index";
309
- import DevelopmentLogin from "../components/DevelopmentLogin";
310
-
311
- const { HeaderActionItem } = Layout;
312
- const { menus, userInfo } = window.store;
313
- const onMenuChange = param => {
314
- console.log("onMenuChange:", param);
315
- };
316
- const onMenuSelect = param => {
317
- console.log("onMenuMenuSelectChange:", param);
318
- };
319
- const onLanguageChange = language => {
320
- console.log("onLanguageChange:", language);
321
- };
322
- const onThemeChange = theme => {
323
- console.log("onThemeChange:", theme);
324
- };
325
- const onAppChange = param => {
326
- console.log("onAppChange", param);
327
- };
328
- const onLogoClick = () => {
329
- console.log("logo click");
330
- };
331
-
332
- ReactDOM.render(
333
- <Layout
334
- logo=""
335
- name="私有云全家桶"
336
- enName="Private Cloud"
337
- selectedAppKey="enterprise"
338
- size="large"
339
- compatible
340
- appList={[
341
- { key: "movie", name: "电影图谱" },
342
- { key: "enterprise", name: "企业图谱" },
343
- ]}
344
- userInfo={userInfo}
345
- selectedMenuKey="tagdata"
346
- menus={menus}
347
- onMenuChange={onMenuChange}
348
- onMenuSelect={onMenuSelect}
349
- onLanguageChange={onLanguageChange}
350
- onThemeChange={onThemeChange}
351
- onAppChange={onAppChange}
352
- onLogoClick={onLogoClick}
353
- extraHeaderActions={[
354
- <HeaderActionItem key="help" onClick={() => console.log("Help")}>
355
- <DevelopmentLogin
356
- signIn={userInfo =>
357
- new Promise(resolve => {
358
- setTimeout(() => {
359
- resolve({ tdToken: "_td_token_", userId: "_uid_" });
360
- }, 100);
361
- })
362
- }
363
- />
364
- </HeaderActionItem>,
365
- ]}
366
- ></Layout>,
367
- document.getElementById("root")
368
- );
369
- ```
370
-
371
- #### 全家桶 Pass 模式
372
-
373
- ```jsx
374
- import React from "react";
375
- import ReactDOM from "react-dom";
376
- import Layout from "../components/Layout/index";
377
-
378
- const { menus, userInfo } = window.store;
379
- const onApplicationChange = appKey => {
380
- console.log("onApplicationChange:", appKey);
381
- };
382
-
383
- ReactDOM.render(
384
- <Layout
385
- type="paas"
386
- compatible
387
- size="large"
388
- appKey="orion"
389
- logo=""
390
- name="私有云全家桶"
391
- enName="Private Cloud"
392
- userInfo={userInfo}
393
- menus={menus}
394
- onApplicationChange={onApplicationChange}
395
- ></Layout>,
396
- document.getElementById("root")
397
- );
398
- ```
399
-
400
- #### Pass 模式 - 自定义菜单
401
-
402
- ```jsx
403
- import React, { useState } from "react";
404
- import ReactDOM from "react-dom";
405
- import { Menu, Layout as AntLayout } from "antd";
406
- import styled from "styled-components";
407
- import Layout from "../components/Layout/index";
408
- import Icon from "../components/Icon/index";
409
-
410
- const { HeaderNavs, HeaderActionItem } = Layout;
411
- const { Sider } = AntLayout;
412
- const { menus, userInfo } = window.store;
413
- const navs = [
414
- {
415
- name: "数据开发",
416
- key: "/dataocean/",
417
- menus: [
418
- { name: "作业开发", key: "home" },
419
- { name: "资源管理", key: "resource" },
420
- { name: "函数管理", key: "func" },
421
- ],
422
- },
423
- {
424
- name: "数据管理",
425
- key: "/dataocean/dm",
426
- menus: [
427
- { name: "数据管理概览", key: "overview" },
428
- { name: "数据查找", key: "search" },
429
- { name: "我的表管理", key: "table" },
430
- ],
431
- },
432
- {
433
- name: "运维中心",
434
- key: "/dataocean/jm",
435
- menus: [
436
- { name: "数据管理概览", key: "jm1" },
437
- { name: "数据查找", key: "jm2" },
438
- { name: "我的表管理", key: "jm3" },
439
- ],
440
- },
441
- {
442
- name: "系统管理",
443
- key: "/dataocean/system",
444
- menus: [
445
- { name: "数据管理概览", key: "system1" },
446
- { name: "数据查找", key: "system2" },
447
- { name: "我的表管理", key: "system3" },
448
- ],
449
- },
450
- ];
451
-
452
- const SideMenu = props => {
453
- const [collapsed, setCollapsed] = useState(false);
454
- const { selectedNav } = props;
455
- const MenuTitleBlock = styled.div`
456
- margin: 10px 20px 8px;
457
- line-height: 48px;
458
- height: 48px;
459
- vertical-align: middle;
460
- border-bottom: 1px solid #e8e8e8;
461
- font-size: 16px;
462
- i {
463
- float: right;
464
- line-height: 48px;
465
- cursor: pointer;
466
- }
467
- `;
468
-
469
- console.log("collapsed...", collapsed);
470
-
471
- return (
472
- <Sider
473
- width={216}
474
- theme="light"
475
- collapsed={collapsed}
476
- style={{ boxShadow: "0 1px 10px 0 rgba(0,0,0,0.10)" }}
477
- >
478
- <MenuTitleBlock>
479
- {!collapsed && selectedNav.name}
480
- <Icon
481
- type={collapsed ? "menu-unfold" : "menu-fold"}
482
- onClick={() => {
483
- setCollapsed(!collapsed);
484
- }}
485
- />
486
- </MenuTitleBlock>
487
- <Menu
488
- defaultSelectedKeys={selectedNav.menus[0].key}
489
- mode="inline"
490
- theme="light"
491
- style={{
492
- border: "none",
493
- }}
494
- >
495
- {(selectedNav.menus || []).map(menu => (
496
- <Menu.Item key={menu.key}>
497
- <Icon type="chart-pie-alt" />
498
- <span>{menu.name}</span>
499
- </Menu.Item>
500
- ))}
501
- </Menu>
502
- </Sider>
503
- );
504
- };
505
-
506
- const PassLayout = props => {
507
- const [selectedNav, setSelectedNav] = useState(navs[0]);
508
- const onNavChange = nav => {
509
- setSelectedNav(nav);
510
- };
511
-
512
- return (
513
- <Layout
514
- type="paas"
515
- compatible
516
- size="large"
517
- appKey="orion"
518
- logo=""
519
- name="私有云全家桶"
520
- enName="Private Cloud"
521
- userInfo={userInfo}
522
- menus={menus}
523
- config={{
524
- language: false,
525
- theme: false,
526
- }}
527
- headerNavs={<HeaderNavs navs={navs} onChange={onNavChange} />}
528
- extraHeaderActions={[
529
- <HeaderActionItem key="help" onClick={() => alert("Help")}>
530
- <Icon type="zhibiao" />
531
- </HeaderActionItem>,
532
- <HeaderActionItem key="mail" onClick={() => alert("Mail")}>
533
- <Icon type="guanjia" />
534
- </HeaderActionItem>,
535
- ]}
536
- sideMenu={<SideMenu selectedNav={selectedNav} />}
537
- >
538
- {props.children}
539
- </Layout>
540
- );
541
- };
542
-
543
- ReactDOM.render(<PassLayout>PassLayout</PassLayout>, document.getElementById("root"));
544
- ```
545
-
546
- ### API
547
-
548
- #### Layout
549
-
550
- | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
551
- | :------------------ | :------------------------------------------------------------------------------------------------------------------- | :--------------- | :----------------------------------------------------------------------------------------- | :----------------------------- |
552
- | type | Layout 类型,全家桶风格、Paas 风格;default | string | default | 否 |
553
- | size | Layout 里面 header,菜单等高度尺寸设置,目前是不设置或设置为 large,large 是老的样式 | string | default | 否 |
554
- | compatible | 兼容模式,新的全家桶设计样式与现有的不一致,为了保证老的项目过渡,需要保持原有的全家桶风格则设置 | boolean | false | 否 |
555
- | appKey | 当前应用的前缀,如 图谱 orion, 机器学习 turing, 解决方案中 path 的前缀,type=paas 才需要 | string | 无 | 否 |
556
- | logo | 应用的 logo, 如果对应的应用 logo 图片有内置在 layout 组件中则,传对应应用的 key 即可,否则传 React Component、string | React Component | 无 | 是 |
557
- | name | 应用名称 | string | 无 | 是 |
558
- | enName | 应用名称英文名称 | string | 无 | 否(需要支持英文模式则需要传) |
559
- | userInfo | 用户信息,统一登录用户信息数据直接传过来 | Object | 无 | 否 |
560
- | selectedMenuKey | 激活菜单选中,目前是用 menuTree 中的 code 作为标识 | string | menus[0].children[0] | 否 |
561
- | menus | 菜单信息,解决方案中 menuTree 接口获取的菜单数据直接传过来 | Array | 无 | 否 |
562
- | config | 功能配置信息,主题(theme)、语言切换(language)、用户头像(avatar)、应用切换(application)、全局导航(globalNavigation) | Object | { theme: true, language: true, avatar: true, application: false, globalNavigation: false } | 否 |
563
- | headerNavs | 头部导航组件,如果有需要可以在头部区域加导航 | React Component | 无 | 否 |
564
- | extraHeaderActions | 头部右上角一些额外操作项,主要适用于一些定制化场景 | Array、ReactNode | 无 | 否 |
565
- | sideMenu | 侧边栏菜单组件,有自定义侧边栏菜单的场景时可用 | ReactNode | 无 | 否 |
566
- | onMenuChange | 菜单切换回调事件 | Function | 无 | 否 |
567
- | onBeforeMenuChange | 菜单切换前回调事件(return false 则可以禁止默认行为) | Function | 无 | 否 |
568
- | onMenuSelect | 菜单选中回调事件 | Function | 无 | 否 |
569
- | onThemeChange | 主题切换回调事件 | Function | 无 | 否 |
570
- | onLanguageChange | 语言切换回调事件 | Function | 无 | 否 |
571
- | onApplicationChange | 应用切换回调事件 | Function | 无 | 否 |
572
- | onLogoClick | logo 区域点击事件 | Function | 无 | 否 |
573
- | onLogout | 退出登录事件 | Function | 跳转登录页面 | 否 |
574
-
575
- #### HeaderNavs
576
-
577
- | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
578
- | :---------- | :--------------------------------------------------------------- | :------- | :---------- | :------- |
579
- | navs | 导航数据,格式[{ name: "看板", key: "/dashboard" }], key 要求唯一 | Array | 无 | 是 |
580
- | selectedKey | 指定选中的导航 | String | navs[0].key | 否 |
581
- | onChange | 导航变化事件回调函数 onChange(Object: selectedNav) | Function | 无 | 否 |
582
- | onSelect | 选中导航事件回调函数 onSelect(Object: selectedNav) | Function | 无 | 否 |
583
-
584
- ## QueryListScene 查询列表
585
-
586
- 主要用于查询列表页面场景,主要包括三部分: 表单查询、操作工具栏、表格数据展示。组件特点:
587
-
588
- - 标签结构化、语义化,提高代码可读性
589
- - 样式统一,方便统一维护升级
590
- - 数据状态管理 + 通用逻辑涵盖(如 Loading、分页、切换页码、查询、重置、自动轮询等)
591
-
592
- ### 安装
593
-
594
- ```
595
- npm install tntd --save
596
- ```
597
-
598
- ### 代码演示
599
-
600
- ```jsx
601
- import React, { Fragment } from "react";
602
- import ReactDOM from "react-dom";
603
- import { Button, Popconfirm, Divider, ButtonGroup, Cascader } from "antd";
604
- import { QueryListScene, Icon } from "tntd";
605
- import { createGlobalStyle } from "styled-components";
606
- import "antd/dist/antd.css";
607
-
608
- const GlobalStyle = createGlobalStyle`
609
- .site-body {
610
- .ichYgh {
611
- overflow: visible;
612
- }
613
- }
614
- `;
615
-
616
- const { QueryForm, Field, Toolbar, QueryList, createActions } = QueryListScene;
617
- const actions = createActions();
618
-
619
- const ColumnActions = ({ record }) => {
620
- const onDelete = () => {
621
- new Promise(resolve => {
622
- resolve(true);
623
- }).then(() => {
624
- actions.search();
625
- });
626
- };
627
-
628
- return (
629
- <span>
630
- <a>编辑</a>
631
- <Divider type="vertical" />
632
- <Popconfirm title="删除确认" onConfirm={onDelete} okText="确认" cancelText="取消">
633
- <a>删除</a>
634
- </Popconfirm>
635
- <Divider type="vertical" />
636
- <a download target="__blank" href={`/download?id=${record.id}`}>
637
- 下载
638
- </a>
639
- </span>
640
- );
641
- };
642
-
643
- const columns = [
644
- {
645
- title: "ID",
646
- dataIndex: "id",
647
- width: 60,
648
- },
649
- {
650
- title: "项目名称",
651
- dataIndex: "name",
652
- sorter: (a, b) => a.name > b.name,
653
- },
654
- {
655
- title: "管理员",
656
- dataIndex: "owner",
657
- width: 100,
658
- },
659
- {
660
- title: "创建时间",
661
- dataIndex: "createTime",
662
- width: 200,
663
- },
664
- {
665
- title: "状态",
666
- dataIndex: "status",
667
- width: 100,
668
- },
669
- {
670
- title: "操作",
671
- dataIndex: "operation",
672
- width: 150,
673
- render: (val, record) => <ColumnActions record={record} />,
674
- },
675
- ];
676
- const query = ({ current = 1, pageSize = 10, ...rest }) => {
677
- console.log("query", { current, pageSize, rest });
678
- return new Promise(resolve => {
679
- setTimeout(() => {
680
- resolve({
681
- current,
682
- pageSize,
683
- total: 100,
684
- data: new Array(100)
685
- .fill(1)
686
- .map((item, index) => ({
687
- id: index + 1,
688
- name: `项目${index + 1}`,
689
- owner: `张三${index + 1}`,
690
- createTime: "2019-09-10 16:30:34",
691
- status: ["初始化", "运行中", "成功", "失败"][index % 4],
692
- }))
693
- .slice((current - 1) * pageSize, current * pageSize),
694
- });
695
- }, 500);
696
- });
697
- };
698
-
699
- const ExtraActions = (
700
- <Button.Group>
701
- <Button icon="cloud-upload" />
702
- <Button icon="cloud-download" />
703
- <Button icon="setting" />
704
- </Button.Group>
705
- );
706
-
707
- ReactDOM.render(
708
- <Fragment>
709
- <QueryListScene title="项目管理" query={query} actions={actions} interval={3000}>
710
- <QueryForm
711
- extraActions={ExtraActions}
712
- showFieldCount={3}
713
- initialValues={{
714
- name: "xxx",
715
- status: "initial",
716
- obj: {
717
- name: "zhangsan",
718
- },
719
- }}
720
- >
721
- <Field
722
- type="selectInput"
723
- name="obj"
724
- props={{
725
- placeholder: "名称",
726
- options: [
727
- { label: "名称", value: "name" },
728
- { label: "ID", value: "id" },
729
- ],
730
- }}
731
- />
732
- <Field type="input" name="name" props={{ placeholder: "名称" }} />
733
- <Field
734
- name="cascader"
735
- component={Cascader}
736
- props={{
737
- options: [
738
- {
739
- value: "zhejiang",
740
- label: "Zhejiang",
741
- children: [
742
- {
743
- value: "hangzhou",
744
- label: "Hangzhou",
745
- children: [
746
- {
747
- value: "xihu",
748
- label: "West Lake",
749
- },
750
- ],
751
- },
752
- ],
753
- },
754
- ],
755
- }}
756
- />
757
- <Field title="日期" type="date" name="date1" />
758
- <Field
759
- title="状态"
760
- type="select"
761
- name="status"
762
- props={{
763
- placeholder: "状态",
764
- options: [
765
- { label: "初始化", value: "initial" },
766
- { label: "运行中", value: "running" },
767
- { label: "成功", value: "success" },
768
- { label: "失败", value: "fail" },
769
- ],
770
- }}
771
- />
772
- <Field title="日期" type="date" name="date" />
773
- <Field title="日期范围" type="dateRange" name="date2" />
774
- <Field
775
- title="状态"
776
- type="select"
777
- name="select1"
778
- props={{
779
- placeholder: "状态",
780
- options: ["初始化", "运行中", "成功", "失败"],
781
- }}
782
- />
783
- <Field title="名称" type="input" name="name2" props={{ placeholder: "名称" }} />
784
- <Field
785
- title="状态2"
786
- type="select"
787
- name="select2"
788
- props={{
789
- placeholder: "状态",
790
- options: ["初始化", "运行中", "成功", "失败"],
791
- }}
792
- />
793
- </QueryForm>
794
- <Toolbar>
795
- <Button type="primary">新增</Button>
796
- <Button type="warning">删除</Button>
797
- </Toolbar>
798
- <QueryList rowKey="id" bordered={false} paginationSticky columns={columns} />
799
- </QueryListScene>
800
- <GlobalStyle />
801
- </Fragment>,
802
- document.getElementById("root")
803
- );
804
- ```
805
-
806
- ### QueryListScene with memory
807
-
808
- - 使用场景: 从列表页跳转到其它页面再回到列表页时会记住查询条件及分页参数。
809
- - 重置记忆数据:actions.resetMemoryData
810
-
811
- ```jsx
812
- import React, { useState, useEffect, Fragment } from "react";
813
- import ReactDOM from "react-dom";
814
- import { Button } from "antd";
815
- import { QueryListScene } from "tntd";
816
-
817
- const { QueryForm, Field, Toolbar, QueryList, createActions } = QueryListScene;
818
- const actions = createActions();
819
-
820
- const QueryListPage = () => {
821
- const [visible, setVisible] = useState(true);
822
- const query = params => {
823
- params.pageSize = params.pageSize || 10;
824
- const { current, pageSize } = params;
825
- console.log("memory query params...", params);
826
-
827
- return Promise.resolve({
828
- current,
829
- pageSize,
830
- total: 100,
831
- data: new Array(100)
832
- .fill(1)
833
- .map((item, index) => ({
834
- id: index + 1,
835
- name: `项目${index + 1}`,
836
- owner: `张三${index + 1}`,
837
- createTime: "2019-09-10 16:30:34",
838
- status: ["初始化", "运行中", "成功", "失败"][index % 4],
839
- }))
840
- .slice((current - 1) * pageSize, current * pageSize),
841
- });
842
- };
843
-
844
- return (
845
- <Fragment>
846
- <Button type={visible ? "danger" : "primary"} onClick={() => setVisible(!visible)}>
847
- {visible ? "销毁列表" : "显示列表"}
848
- </Button>
849
- <Button onClick={actions.resetMemoryData}>重置记忆数据</Button>
850
- {visible ? (
851
- <QueryListScene memory actions={actions} query={query}>
852
- <QueryForm initialValues={{ name: "项目" }}>
853
- <Field
854
- name="name"
855
- type="input"
856
- props={{
857
- placeholder: "名称",
858
- }}
859
- />
860
- <Field
861
- type="select"
862
- name="status"
863
- props={{
864
- placeholder: "状态",
865
- options: ["初始化", "运行中", "成功", "失败"],
866
- }}
867
- />
868
- </QueryForm>
869
- <QueryList
870
- columns={[
871
- { dataIndex: "id", title: "ID" },
872
- { dataIndex: "name", title: "名称" },
873
- { dataIndex: "owner", title: "负责人" },
874
- { dataIndex: "status", title: "状态" },
875
- ]}
876
- />
877
- </QueryListScene>
878
- ) : (
879
- <p style={{ color: "red" }}>列表已销毁</p>
880
- )}
881
- </Fragment>
882
- );
883
- };
884
-
885
- ReactDOM.render(<QueryListPage />, document.getElementById("root"));
886
- ```
887
-
888
- ### API
889
-
890
- #### QueryListScene
891
-
892
- | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
893
- | :-------- | :----------------------------------------------------------------------------------- | :------ | :----- | :------- |
894
- | query | 查询数据方法,调用时会把 queryform 数据作为参数 | Promise | 无 | 是 |
895
- | title | 标题 | string | 无 | 否 |
896
- | actions | 组件上聚合的方法,需由 createActions 方法创建出来 | Object | 无 | 否 |
897
- | interval | 轮训时间间隔单位 ms,设置该值后列表可自动轮询 | number | 无 | 否 |
898
- | memory | 组件销毁时是否需要记住表单和分页数据 | boolean | false | 否 |
899
- | className | css 类 | string | 无 | 否 |
900
- | size | 目前主要设置 header 高度,默认按照新的设计,如果需要保持原有系统不变,则设置为 large | string | 无 | 否 |
901
-
902
- #### QueryForm
903
-
904
- | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
905
- | :------------- | :-------------------------------------------------------- | :-------- | :----- | :------- |
906
- | title | 标题 | string | 无 | 否 |
907
- | showFieldCount | 显示在外面的表单数量(尽在“更多条件”在 Drawer 交互时使用) | number | 无 | 否 |
908
- | showExpand | 展开/收起功能配置,默认开启 | boolean | true | 否 |
909
- | showSearch | 搜索按钮显示配置,默认开启 | boolean | true | 否 |
910
- | showReset | 重置按钮显示配置,默认开启 | boolean | true | 否 |
911
- | drawerProps | Drawer props(参见 antd,设置样式宽度时可用) | Object | 无 | 否 |
912
- | extraActions | 额外操作 | ReactNode | 无 | 否 |
913
- | renderActions | 表单操作, 自定义操作按钮,默认是查询、重置 | Function | 无 | 否 |
914
- | onChange | 表单变化事件,onChange(values, { name, value, preValue }) | Function | 无 | 否 |
915
-
916
- #### Field
917
-
918
- | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
919
- | :-------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----- | :----- | :------- |
920
- | name | 表单项名,保证唯一 | string | 无 | 是 |
921
- | title | 表单 label | string | 无 | 否 |
922
- | type | 表单类型 input、search, number、select、selectInput、 date、 dateRange | 无 | 否 |
923
- | component | 表单组件,如果内置的 type 表单组件不满足需求的话,可以直接传 ReactNode 类型的表单组件,其优先级高于 type,如 antd TreeSelect、Cascader 等,也可以完全自定义表单组件 | 无 | 否 |
924
- | props | 表单元素属性,参照 antd, Input, InputNumber, Select, DatePicker | Object | 无 | 否 |
925
- | className | 添加样式 class | string | 无 | 否 |
926
-
927
- #### Toolbar
928
-
929
-
930
-
931
- #### QueryList
932
-
933
- 同 antd Table
934
-
935
- | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
936
- | :--------------- | :--------------------------------------------- | :------ | :----- | :------- |
937
- | localPagination | 前端分页,数据一次性从接口获取,前端分页时使用 | boolean | false | 否 |
938
- | paginationSticky | 分页是否吸底(sticky) | boolean | false | 否 |
939
-
940
- #### createActions
941
-
942
- ```
943
- const { createActions } = QueryListScene;
944
- const actions = createActions();
945
-
946
- actions对象接口如下:
947
- {
948
- // 设置查询表单数据(默认自动查询,不需要查询needSearch传false)
949
- setFormData: (data: Object, needSearch = true),
950
- // 重置表单数据
951
- resetFormData: (needSearch = false),
952
- // 重置记忆数据,form、pagination
953
- resetMemoryData(),
954
- // 设置表格数据
955
- setTableDataSource: (dataSource: Array),
956
- // 设置分页数据
957
- setPagination: (
958
- pagination: Object = {
959
- current,
960
- pageSize,
961
- total
962
- }
963
- ),
964
- // 查询列表, params 为查询参数,会扩展到formData上, showLoading:是否显示loading
965
- search: (params?: Object, showLoading?: boolean = true),
966
-
967
- // 获取表单数据,name不传则是整个表单数据对象,传了name则获取单个表单值
968
- getFormData: (name?: string),
969
- // 获取当前查询条件的表单数据,与getFormData的区别在于,这里是已执行过查询的数据
970
- getSubmittedFormData: (name?: string),
971
- // 获取列表数据
972
- getTableDataSource: (),
973
- // 获取分页数据
974
- getPagination: ()
975
- }
976
- ```
977
-
978
- ## Icon 组件
979
-
980
- ### 代码演示
981
-
982
- ```jsx
983
- import { Fragment, useState } from "react";
984
- import ReactDOM from "react-dom";
985
- import { createGlobalStyle } from "styled-components";
986
- import { Icon } from "tntd";
987
- import "antd/dist/antd.css";
988
-
989
- const GlobalStyle = createGlobalStyle`
990
- .site-body {
991
- .ichYgh {
992
- padding: 0;
993
- overflow: visible;
994
- }
995
- }
996
- `;
997
-
998
- ReactDOM.render(<Icon type="analysis" />, document.getElementById("root"));
999
- ```
1000
-
1001
- ```jsx
1002
- import { Fragment, useState } from "react";
1003
- import ReactDOM from "react-dom";
1004
- import styled, { createGlobalStyle } from "styled-components";
1005
- import { Input } from "antd";
1006
- import { Icon } from "tntd";
1007
- import { iconList as icons } from "tntd/Icon";
1008
- import "antd/dist/antd.css";
1009
-
1010
- const GlobalStyle = createGlobalStyle`
1011
- .site-body {
1012
- .ichYgh {
1013
- padding: 0;
1014
- overflow: visible;
1015
- }
1016
- }
1017
- `;
1018
- const IconList = styled.ul`
1019
- margin: 10px 0;
1020
- overflow: hidden;
1021
- list-style: none;
1022
- `;
1023
- const IconItem = styled.li`
1024
- position: relative;
1025
- float: left;
1026
- width: 16.66%;
1027
- height: 100px;
1028
- margin: 3px 0;
1029
- padding: 10px 0 0;
1030
- overflow: hidden;
1031
- color: #555;
1032
- text-align: center;
1033
- list-style: none;
1034
- background-color: inherit;
1035
- border-radius: 4px;
1036
- cursor: pointer;
1037
- -webkit-transition: color 0.3s ease-in-out, background-color 0.3s ease-in-out;
1038
- transition: color 0.3s ease-in-out, background-color 0.3s ease-in-out;
1039
- &:hover {
1040
- color: #fff;
1041
- background-color: #1890ff;
1042
- }
1043
- .tnt-icon {
1044
- margin: 12px 0 8px;
1045
- font-size: 36px;
1046
- -webkit-transition: -webkit-transform 0.3s ease-in-out;
1047
- transition: -webkit-transform 0.3s ease-in-out;
1048
- transition: transform 0.3s ease-in-out;
1049
- transition: transform 0.3s ease-in-out, -webkit-transform 0.3s ease-in-out;
1050
- will-change: transform;
1051
- }
1052
- `;
1053
-
1054
- const IconsDemo = props => {
1055
- const [searchValue, setSearchValue] = useState();
1056
-
1057
- return (
1058
- <Fragment>
1059
- <Input.Search
1060
- onChange={evt => setSearchValue(evt.target.value)}
1061
- placeholder="输入icon标识搜索"
1062
- />
1063
- <IconList>
1064
- {icons
1065
- .filter(icon => !searchValue || new RegExp(searchValue, "i").test(icon))
1066
- .map(icon => (
1067
- <IconItem key={icon}>
1068
- <Icon type={icon} />
1069
- <p>{icon}</p>
1070
- </IconItem>
1071
- ))}
1072
- </IconList>
1073
- <GlobalStyle />
1074
- </Fragment>
1075
- );
1076
- };
1077
-
1078
- ReactDOM.render(<IconsDemo />, document.getElementById("root"));
1079
- ```
1080
-
1081
- ### API
1082
-
1083
- #### Icon
1084
-
1085
- | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
1086
- | :------- | :------------ | :----- | :----- | :------- |
1087
- | type | icon 类型标识 | string | 无 | 是 |
1088
- | prefix | type 前缀 | string | | 否 |
1089
-
1090
- ## Modal 全屏浮层组件
1091
-
1092
- ### 代码演示
1093
-
1094
- ```jsx
1095
- import { Fragment, useState } from "react";
1096
- import ReactDOM from "react-dom";
1097
- import { createGlobalStyle } from "styled-components";
1098
- import { Button } from "antd";
1099
- import { Modal } from "tntd";
1100
- import "antd/dist/antd.css";
1101
-
1102
- const GlobalStyle = createGlobalStyle`
1103
- .site-body {
1104
- .ichYgh {
1105
- padding: 0;
1106
- overflow: visible;
1107
- }
1108
- }
1109
- `;
1110
-
1111
- const FullscreenModalDemo = props => {
1112
- const [visible, setVisible] = useState(false);
1113
-
1114
- return (
1115
- <Fragment>
1116
- <Button type="primary" onClick={() => setVisible(true)}>
1117
- 带全屏Modal
1118
- </Button>
1119
- <Modal
1120
- visible={visible}
1121
- title="司南"
1122
- logo="https://sinan.tongdun.me/cdn/bucket/20191127134944493_favicon.png"
1123
- onCancel={() => setVisible(false)}
1124
- onToggleFullscreen={isFullscreen => console.log(`isFullscreen: ${isFullscreen}`)}
1125
- >
1126
- <iframe src="https://sinan.tongdun.me/book/2085" />
1127
- </Modal>
1128
- <GlobalStyle />
1129
- </Fragment>
1130
- );
1131
- };
1132
-
1133
- ReactDOM.render(<FullscreenModalDemo />, document.getElementById("root"));
1134
- ```
1135
-
1136
- ### API
1137
-
1138
- #### Modal
1139
-
1140
- 同 antd Modal
1141
-
1142
- | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
1143
- | :----------------- | :----------- | :------- | :----- | :------- |
1144
- | logo | logo 地址 | string | 无 | 是 |
1145
- | supportFullscreen | 是否支持全屏 | boolean | true | 否 |
1146
- | onToggleFullscreen | 全屏切换事件 | Function | null | 否 |
1147
-
1148
- ## Columns 组件
1149
-
1150
- ### 代码演示
1151
-
1152
- ```jsx
1153
- import React, { useState } from "react";
1154
- import ReactDOM from "react-dom";
1155
- import { createGlobalStyle } from "styled-components";
1156
- import { Button } from "antd";
1157
- import { Columns, Icon } from "tntd";
1158
- import "antd/dist/antd.css";
1159
-
1160
- const { Item } = Columns;
1161
-
1162
- const GlobalStyle = createGlobalStyle`
1163
- .site-body {
1164
- .ichYgh {
1165
- padding: 0;
1166
- overflow: visible;
1167
- }
1168
- }
1169
- `;
1170
-
1171
- const Demo = props => {
1172
- const [activeTabKey, setActiveTabKey] = useState(null);
1173
- const [activeTabKey1, setActiveTabKey1] = useState(null);
1174
-
1175
- const tabList = [
1176
- {
1177
- key: "1",
1178
- tab: "tab1",
1179
- },
1180
- {
1181
- key: "2",
1182
- tab: "tab2",
1183
- },
1184
- ];
1185
- const contentList = {
1186
- "1": <p>content1</p>,
1187
- "2": <p>content2</p>,
1188
- };
1189
- const tabList1 = [
1190
- {
1191
- key: "3",
1192
- tab: "tab3",
1193
- },
1194
- {
1195
- key: "4",
1196
- tab: "tab4",
1197
- },
1198
- ];
1199
- const contentList1 = {
1200
- "3": <p>content3</p>,
1201
- "4": <p>content4</p>,
1202
- };
1203
-
1204
- return (
1205
- <>
1206
- <Columns gutter={12} height={300}>
1207
- <Item
1208
- title={
1209
- <div>
1210
- <Icon type="edit" style={{ marginRight: 10 }} />
1211
- 修改
1212
- </div>
1213
- }
1214
- span={4}
1215
- hoverable={true}
1216
- style={{ color: "#bbb" }}
1217
- cover={<span>123</span>}
1218
- loading={true}
1219
- >
1220
- 修改修改修改修改修改修改修改修改修改修改修改修改
1221
- </Item>
1222
- <Item
1223
- title="测试2"
1224
- extra={
1225
- <Button size="small" type="primary" icon="more">
1226
- 更多
1227
- </Button>
1228
- }
1229
- span={4}
1230
- >
1231
- 我的column 我的column 我的column 我的column 我的column
1232
- </Item>
1233
- <Item title="测试3" span={4}>
1234
- 我的column 我的column 我的column 我的column 我的column我的column 我的column
1235
- 我的column 我的column 我的column我的column 我的column 我的column 我的column
1236
- 我的column我的column 我的column 我的column 我的column 我的column我的column
1237
- 我的column 我的column 我的column 我的column我的column 我的column 我的column
1238
- 我的column 我的column我的column 我的column 我的column 我的column
1239
- 我的column我的column 我的column 我的column 我的column 我的column我的column
1240
- 我的column 我的column 我的column 我的column我的column 我的column 我的column
1241
- 我的column 我的column我的column 我的column 我的column 我的column
1242
- 我的column我的column 我的column 我的column 我的column 我的column我的column
1243
- 我的column 我的column 我的column 我的column我的column 我的column 我的column
1244
- 我的column 我的column我的
1245
- </Item>
1246
- <Item
1247
- title="测试4"
1248
- span={12}
1249
- tabList={tabList}
1250
- defaultActiveTabKey="2"
1251
- activeTabKey={activeTabKey}
1252
- onTabChange={key => setActiveTabKey(key)}
1253
- tabBarExtraContent={
1254
- <Button size="small" type="primary" icon="plus">
1255
- 添加
1256
- </Button>
1257
- }
1258
- >
1259
- {contentList[activeTabKey]}
1260
- </Item>
1261
- </Columns>
1262
- <Columns height={400} gutter={[20, 24]}>
1263
- <Item
1264
- bordered={true}
1265
- span={12}
1266
- tabList={tabList1}
1267
- activeTabKey={activeTabKey1}
1268
- onTabChange={key => setActiveTabKey1(key)}
1269
- tabBarExtraContent={
1270
- <Button size="small" type="primary" icon="search">
1271
- 搜索
1272
- </Button>
1273
- }
1274
- >
1275
- 我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦!
1276
- {contentList1[activeTabKey1]}
1277
- </Item>
1278
- <Item title="测试5" span={12} bordered={true}>
1279
- 我是一段很长很长很长段文本哦我是一段很长很长很长段文本哦我是
1280
- </Item>
1281
- </Columns>
1282
- </>
1283
- );
1284
- };
1285
-
1286
- ReactDOM.render(<Demo />, document.getElementById("root"));
1287
- ```
1288
-
1289
- ### API
1290
-
1291
- #### Columns
1292
-
1293
- | 参数 | type | description | default |
1294
- | :------ | :----------- | :---------------------------- | :------ |
1295
- | align | top | middle | bottom | 垂直对齐方式(同 antd 中的 row 使用方法相同 ) | top |
1296
- | gutter | number/array | 同 antd 中的 row 使用方法类似 | 0 |
1297
- | justify | start | end | center | space-around | space-between | 水平排列方式(同 antd 中的 row 使用方法相同 ) | start |
1298
- | height | int | 列的高度 | - |
1299
-
1300
- #### Columns.Item
1301
-
1302
- | 参数 | type | description | default |
1303
- | :------------------ | :----------------------------------- | :---------------------------------------------- | :---------------------- |
1304
- | span | int | 与 antd 中 col 的 span 的使用方法相同 | 24 |
1305
- | extra | string/ReactNode | title 右上角的操作区域 | - |
1306
- | title | string/ReactNode | column 标题 | - |
1307
- | hoverable | boolean | 鼠标移过时可浮起 | false |
1308
- | bordered | boolean | 是否有边框 | false(默认边框是阴影) |
1309
- | tabList | Array<{key: string, tab: ReactNode}> | 标题列表 | - |
1310
- | activeTabKey | string | 当前激活页签的 key | - |
1311
- | onTabChange | (key) => void | 页签切换的回调 | - |
1312
- | defaultActiveTabKey | string | 初始化选中页签的 key,如果没有设置 activeTabKey | 第一个页签 |
1313
- | tabBarExtraContent | ReactNode | tab bar 上额外的元素 | - |
1314
- | headStyle | CSSProperties | 自定义标题区域样式 | - |
1315
-
1316
- ## DevelopmentLogin 组件
1317
-
1318
- ### 代码演示
1319
-
1320
- ```jsx
1321
- import { Fragment, useState } from "react";
1322
- import ReactDOM from "react-dom";
1323
- import { createGlobalStyle } from "styled-components";
1324
- import { DevelopmentLogin } from "tntd";
1325
- import "antd/dist/antd.css";
1326
-
1327
- const GlobalStyle = createGlobalStyle`
1328
- .site-body {
1329
- .ichYgh {
1330
- padding: 0;
1331
- overflow: visible;
1332
- }
1333
- }
1334
- `;
1335
-
1336
- ReactDOM.render(
1337
- <DevelopmentLogin
1338
- signIn={params => {
1339
- console.log("login info...", params);
1340
- // TODO 发送请求到后端登录,返回一个promise
1341
- // 目前组件内部在拿到返回的数据后默认的处理逻辑如下:
1342
- /*
1343
- const { tdToken: token, userId } = res || {};
1344
-
1345
- cookies.set('_td_token_', token, { path: '/' });
1346
- cookies.set('_uid_', userId, { path: '/' });
1347
- */
1348
- return new Promise(resolve => {
1349
- setTimeout(() => {
1350
- resolve({
1351
- tdToken: "tdToken",
1352
- userId: "userId",
1353
- });
1354
- }, 100);
1355
- });
1356
- }}
1357
- />,
1358
- document.getElementById("root")
1359
- );
1360
- ```
1361
-
1362
- ### API
1363
-
1364
- #### DevelopmentLogin
1365
-
1366
- | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
1367
- | :------- | :--------------- | :--------------------------- | :----- | :------- |
1368
- | signIn | 登录时执行的方法 | Function(返回值类型 Promise) | 无 | 是 |
1369
-
1370
- <br/>
1371
-
1372
- ## Handle 组件
1373
-
1374
- ### 代码演示
1375
-
1376
- ```jsx
1377
- import React from "react";
1378
- import ReactDOM from "react-dom";
1379
- import "antd/dist/antd.css";
1380
- import { Button, Table } from "antd";
1381
- import { Handle } from "tntd";
1382
-
1383
- const Demo = props => {
1384
- const dataSource = [
1385
- {
1386
- key: "1",
1387
- name: "胡彦斌",
1388
- age: 32,
1389
- address: "西湖区湖底公园1号",
1390
- },
1391
- {
1392
- key: "2",
1393
- name: "胡彦祖",
1394
- age: 42,
1395
- address: "西湖区湖底公园1号",
1396
- },
1397
- ];
1398
-
1399
- const columns = [
1400
- {
1401
- title: "姓名",
1402
- dataIndex: "name",
1403
- key: "name",
1404
- },
1405
- {
1406
- title: "年龄",
1407
- dataIndex: "age",
1408
- key: "age",
1409
- },
1410
- {
1411
- title: "住址",
1412
- dataIndex: "address",
1413
- key: "address",
1414
- },
1415
- {
1416
- title: "操作",
1417
- dataIndex: "opera",
1418
- render: () => (
1419
- <Handle className="custom-class">
1420
- <a
1421
- onClick={() => {
1422
- console.log("online");
1423
- }}
1424
- >
1425
- 上线
1426
- </a>
1427
- <a>查看</a>
1428
- <a>编辑</a>
1429
- <a>测试</a>
1430
- <a>导入</a>
1431
- <a>导出</a>
1432
- </Handle>
1433
- ),
1434
- },
1435
- ];
1436
-
1437
- return <Table dataSource={dataSource} columns={columns} rowKey={(e, i) => i} />;
1438
- };
1439
-
1440
- ReactDOM.render(<Demo />, document.getElementById("root"));
1441
- ```
1442
-
1443
- ### API
1444
-
1445
- #### Handle
1446
-
1447
- | 属性名称 | 属性说明 | 类型 | 默认值 | 是否必须 |
1448
- | :-------- | :------------------------------------ | :----- | :----- | :------- |
1449
- | type | 类型,展示“更多”的模式,Icon 或者文字 | String | 文字 | 否 |
1450
- | num | 最多展示的个数 | Number | 3 | 否 |
1451
- | divider | 分隔线 | Bool | true | 否 |
1452
- | lang | 中英文 | String | cn | 否 |
1453
- | className | 自定义类名 | String | 无 | 否 |
1454
-
1455
- ## Page 组件
1456
-
1457
- ### 代码演示
1458
-
1459
- ```jsx
1460
- import React, { useState } from "react";
1461
- import ReactDOM from "react-dom";
1462
- import styled from "styled-components";
1463
- import { Button, Divider } from "antd";
1464
- import { Page } from "tntd";
1465
- import "antd/dist/antd.css";
1466
-
1467
- const { Box } = Page;
1468
-
1469
- const left = "< 返回列表";
1470
- const center = "先灰再白后灰";
1471
- const right = (
1472
- <>
1473
- <Button>预览</Button>
1474
- <Button type="primary">保存</Button>
1475
- </>
1476
- );
1477
-
1478
- const Demo = props => {
1479
- return (
1480
- <div>
1481
- <Page title={left} center={center} extra={right}>
1482
- <Box width="200">第一列</Box>
1483
- <Box mode="white">第二列</Box>
1484
- <Box width="200">第三列</Box>
1485
- </Page>
1486
- </div>
1487
- );
1488
- };
1489
-
1490
- ReactDOM.render(<Demo />, document.getElementById("root"));
1491
- ```
1492
-
1493
- ### API
1494
-
1495
- #### Page
1496
-
1497
- | 参数 | 说明 | 类型 | 默认值 | 是否必须 |
1498
- | :----------- | :--------------------------------------------------------------------- | :---------------- | :------ | :------- |
1499
- | title | 标题栏左侧内容 | ReactNode | - | 否 |
1500
- | center | 标题栏中间内容 | ReactNode | - | 否 |
1501
- | extra | 标题栏右侧内容 | ReactNode | - | 否 |
1502
- | headerHeight | 标题栏的高度 | string/int | 50px | 否 |
1503
- | height | 组件整体高度 | string | 100vh | 否 |
1504
- | size | 根据 size 尺寸调整标题栏的 padding 值,Page.Box 组件也会继承 size 属性 | `default | small` | default | 否 |
1505
-
1506
- #### Page.Box
1507
-
1508
- 描述:Page.Box 包裹了 antd 库中的 Card 组件,Box 属性都会透传到 Card 组件。
1509
-
1510
- | 参数 | 说明 | 类型 | 默认值 | 是否必须 |
1511
- | :-------- | :--------------------------------------------- | :------------ | :------------------- | :------- |
1512
- | width | 30%代表占父容器的百分比, 30 代表固定宽度 30px | string/int | flex:1,代表均分空间 | 否 |
1513
- | mode | white 是白色背景,gray 为灰色背景 | `white| gray` | gray | 否 |
1514
- | noPadding | 如果为 true,Box 的 padding 为 0 | boolean | false | 否 |
1515
-
1516
- ## ArrayInput 组件
1517
-
1518
- ### 代码演示 1
1519
-
1520
- ```jsx
1521
- import React, { useState } from "react";
1522
- import ReactDOM from "react-dom";
1523
- import { Button, Icon, Input, Select } from "antd";
1524
- import { ArrayInput } from "tntd";
1525
- import "antd/dist/antd.css";
1526
-
1527
- const Option = Select.Option;
1528
-
1529
- const Demo = () => {
1530
- const [value, setValue] = useState([{ type: "input" }]);
1531
- return (
1532
- <ArrayInput
1533
- value={value}
1534
- onChange={v => {
1535
- console.log("值修改了", v);
1536
- setValue(v);
1537
- }}
1538
- plusTip="注意要添加哦"
1539
- deleteTip="注意要删除了哦"
1540
- require
1541
- >
1542
- {(row, index) => {
1543
- return (
1544
- <>
1545
- <Select
1546
- name="type"
1547
- placeholder="联动"
1548
- span={4}
1549
- onChange={(value, index, changeValue) => {
1550
- changeValue(index, "string", undefined);
1551
- }}
1552
- >
1553
- <Option value="input">输入框</Option>
1554
- <Option value="select">选择框</Option>
1555
- </Select>
1556
- {row.type === "input" ? (
1557
- <Input name="string" placeholder="输入值" span={6} />
1558
- ) : (
1559
- <Select name="string" placeholder="下拉值" span={6}>
1560
- <Option value="input">下拉值1</Option>
1561
- <Option value="select">下拉值2</Option>
1562
- </Select>
1563
- )}
1564
- <Input name="input" placeholder="输入框" />
1565
- </>
1566
- );
1567
- }}
1568
- </ArrayInput>
1569
- );
1570
- };
1571
-
1572
- ReactDOM.render(<Demo />, document.getElementById("root"));
1573
- ```
1574
-
1575
- ### 代码演示 2
1576
-
1577
- ```jsx
1578
- import React, { useState } from "react";
1579
- import ReactDOM from "react-dom";
1580
- import { Button, Icon, Input, Select } from "antd";
1581
- import { ArrayInput } from "tntd";
1582
- import "antd/dist/antd.css";
1583
-
1584
- const Option = Select.Option;
1585
-
1586
- const Demo = () => {
1587
- return (
1588
- <ArrayInput mode="table">
1589
- {(row, index) => {
1590
- return [
1591
- <Select
1592
- name="type"
1593
- placeholder="联动"
1594
- title="第一列"
1595
- span={4}
1596
- onChange={(value, index, changeValue) => {
1597
- changeValue(index, "string", undefined);
1598
- }}
1599
- >
1600
- <Option value="input">输入框</Option>
1601
- <Option value="select">选择框</Option>
1602
- </Select>,
1603
- row.type === "input" ? (
1604
- <Input name="string" placeholder="输入值" title="第二列" span={6} />
1605
- ) : (
1606
- <Select name="string" placeholder="下拉值" title="第二列" span={6}>
1607
- <Option value="input">下拉值1</Option>
1608
- <Option value="select">下拉值2</Option>
1609
- </Select>
1610
- ),
1611
- <Input name="input" placeholder="输入框" title="第三列" span={6} />,
1612
- ];
1613
- }}
1614
- </ArrayInput>
1615
- );
1616
- };
1617
-
1618
- ReactDOM.render(<Demo />, document.getElementById("root"));
1619
- ```
1620
-
1621
- ### API
1622
-
1623
- #### ArrayInput
1624
-
1625
- | 参数 | type | description | default |
1626
- | :----------- | :----------- | :---------------------------- | :------ |
1627
- | defaultValue | array | 默认值 | |
1628
- | value | array | 可控值 | |
1629
- | onChange | Function | 值变化时的回调 | |
1630
- | mode | string | 展示形式(list 或者 table) | list |
1631
- | gutter | number/array | 同 antd 中的 row 使用方法类似 | 10 |
1632
- | require | boolean | 是否至少有一列 | false |
1633
- | children | Function | 每行渲染函数 | |
1634
- | deleteTip | string | 删除按钮说明文案 | |
1635
- | plusTip | string | 添加按钮说明文案 | |
1636
-
1637
- #### children 中输入控件参数
1638
-
1639
- | 参数 | type | description | default |
1640
- | :---- | :----- | :---------------------------- | :------ |
1641
- | name | string | 控件的 key(必填) | |
1642
- | span | number | 同 antd 中的 Col 使用方法类似 | 4 |
1643
- | title | string | mode 为 table 的时候必填 | |