ztxkui 2.3.5 → 2.3.6

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.
@@ -1,10 +1,48 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
1
37
  import { Link } from 'react-router-dom';
2
38
  import Upload from 'components/Upload';
3
- import { useState, useEffect, useCallback } from 'react';
39
+ import { useState, useEffect, useCallback, useRef } from 'react';
4
40
  var originFileList = [];
5
- var token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZW5hbnRfaWQiOiIwMDAwMDAiLCJtZW1iZXJfdHlwZSI6MSwiaGFuZGxlX2hyX3Bob25lIjpudWxsLCJyZXN1bWVfZGF0ZSI6bnVsbCwidXNlcl9uYW1lIjoiY2hlbnl4IiwiZW1wX25hbWUiOiLpmYjkuprpm4QiLCJlbXBfbnVtYmVyIjoiWUcyMTA3MDA4IiwiaW10X2lkIjpudWxsLCJyZWFsX25hbWUiOiLpmYjkuprpm4QiLCJjbGllbnRfdHlwZSI6IndlYiIsImRhdGFfcm9sZV9pZCI6IjEzNDU5Nzg1MDUzMDIwNTY5NjIsMTQxMjYxNDExMDY0NzM4NjExNCwxNDEyNjE1Njc3MTE5MjY2ODE3LDE0NDgxMjEwODY1MDQzMDA1NDYsMTQ1MjgyMDI5MzgwMjcxMzA5MCwxNDUzOTI1MDAxNTMxNDc4MDE3LDE0NTg3MTIwODIwODIzNTcyNTAsMTQ1ODgyNjIzODE4NTg4OTc5NCwxNDU4ODI3NzAxMDEyMzI0MzUzLDE0NTg4MjgzNjA4MDE1MDkzNzcsMTQ2MDA4OTI2MjAxMjAzMDk3NywxNDYxMTM3Nzg4NjQ1MTI2MTQ2IiwiY2xpZW50X2lkIjoic3dvcmQiLCJ1c2VyX3R5cGUiOiJ3ZW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VudCI6ImNoZW55eCIsInJlc3VtZV9pZCI6bnVsbH0.wr6BV61OVYd-o9kccJJhWBGWzqyYyMTqdwd5qUxZlhM";
6
42
  function UploadDemo() {
43
+ var _this = this;
7
44
  var _a = useState(originFileList), fileList = _a[0], setFileList = _a[1];
45
+ var upload = useRef();
8
46
  useEffect(function () {
9
47
  setTimeout(function () {
10
48
  setFileList([
@@ -15,6 +53,27 @@ function UploadDemo() {
15
53
  // percent: 100,
16
54
  // status: 'done',
17
55
  },
56
+ {
57
+ attachId: '123',
58
+ attachName: '123.jpg',
59
+ fileSize: 36742,
60
+ percent: 80,
61
+ status: 'uploading',
62
+ },
63
+ {
64
+ attachId: '1491978407680376833',
65
+ attachName: '260929616_640_640.jpg',
66
+ fileSize: 36742,
67
+ percent: 80,
68
+ status: 'error',
69
+ },
70
+ {
71
+ attachId: '1492035772232466434',
72
+ attachName: '260929610_640_640.jpg',
73
+ fileSize: 36742,
74
+ // percent: 100,
75
+ // status: 'error',
76
+ },
18
77
  // {
19
78
  // // uid可不传,这个应该时组件需要一个内部id,可以同attachId
20
79
  // uid: '1418469936545132546',
@@ -80,6 +139,29 @@ function UploadDemo() {
80
139
  setFileList(filelist);
81
140
  }
82
141
  }, []);
142
+ var checkHandle = function () { return __awaiter(_this, void 0, void 0, function () {
143
+ var err_1, errorFields;
144
+ var _a, _b;
145
+ return __generator(this, function (_c) {
146
+ switch (_c.label) {
147
+ case 0:
148
+ _c.trys.push([0, 2, , 3]);
149
+ return [4 /*yield*/, ((_b = (_a = upload.current) === null || _a === void 0 ? void 0 : _a.validate) === null || _b === void 0 ? void 0 : _b.call(_a, { title: '测试下面的', isError: true }))];
150
+ case 1:
151
+ _c.sent();
152
+ return [3 /*break*/, 3];
153
+ case 2:
154
+ err_1 = _c.sent();
155
+ console.log(err_1);
156
+ errorFields = err_1.errorFields;
157
+ if (errorFields) {
158
+ console.log(errorFields[0].errors + '');
159
+ }
160
+ return [2 /*return*/];
161
+ case 3: return [2 /*return*/];
162
+ }
163
+ });
164
+ }); };
83
165
  return (React.createElement("div", null,
84
166
  React.createElement(Link, { to: "/test" }, "test"),
85
167
  React.createElement(Upload, { method: "post", headers: {
@@ -96,7 +178,7 @@ function UploadDemo() {
96
178
  system: '2',
97
179
  }, apiBaseUrl: "http://192.168.0.83:8888", fileBaseUrl: "http://192.168.0.83:88", originFileList: fileList, callback: uploadCallbackFn, onDeleteCallback: function (index, file) {
98
180
  console.log(index, file);
99
- } }),
181
+ }, upload: upload }),
100
182
  React.createElement(Upload, { maxSize: 200 * 1024, ztAccept: ['.jpg', '.jpeg', '.png', '.bmp', '.gif'], listType: "picture-card", method: "post", headers: {
101
183
  'Zmdms-Auth': token,
102
184
  }, showUploadList: {
@@ -105,6 +187,7 @@ function UploadDemo() {
105
187
  showRemoveIcon: true,
106
188
  }, apiBaseUrl: "http://192.168.0.83:8888", fileBaseUrl: "http://192.168.0.83:88", showTable: false, showTip: false, originFileList: fileList, maxCount: 1, callback: uploadCallbackFn, onDeleteCallback: function (index, file) {
107
189
  console.log(index, file);
108
- }, authToken: token })));
190
+ }, authToken: token }),
191
+ React.createElement("button", { onClick: checkHandle }, "\u68C0\u67E5")));
109
192
  }
110
193
  export default UploadDemo;
@@ -10,6 +10,8 @@ export interface IEditableConfig {
10
10
  };
11
11
  maxHandle?: (record: any) => number;
12
12
  minHandle?: (record: any) => number;
13
+ /**是否禁用 */
14
+ disabledHandle?: (record: any) => boolean;
13
15
  /**数字输入框的转换类型:内置 货币和百分比 */
14
16
  formatterType?: IFormatterType;
15
17
  /**货币的前缀 可以为 $ 或 ¥ */
@@ -1,6 +1,9 @@
1
1
  import React from 'react';
2
2
  import { UploadProps } from 'antd/lib/upload';
3
3
  import { UploadFile } from './';
4
+ export interface IUploadRef {
5
+ validate?: (info?: any) => any;
6
+ }
4
7
  export interface IProps extends UploadProps {
5
8
  /**是否显示上传表格 */
6
9
  showTable?: boolean;
@@ -57,6 +60,8 @@ export interface IProps extends UploadProps {
57
60
  otherColumns?: any;
58
61
  /**是否直接替换 */
59
62
  isDirect?: boolean;
63
+ /**附件上传对象 */
64
+ upload?: any;
60
65
  }
61
66
  declare const Upload: React.FC<IProps>;
62
67
  export default Upload;
@@ -9,6 +9,42 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
12
48
  var __rest = (this && this.__rest) || function (s, e) {
13
49
  var t = {};
14
50
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -44,9 +80,58 @@ var _accept = [
44
80
  '.gif',
45
81
  ];
46
82
  var Upload = function (props) {
47
- var children = props.children, className = props.className, _a = props.showTip, showTip = _a === void 0 ? true : _a, _b = props.showUploadBtn, showUploadBtn = _b === void 0 ? true : _b, _c = props.showDeleteBtn, showDeleteBtn = _c === void 0 ? true : _c, onDownLoadCallbackBefore = props.onDownLoadCallbackBefore, _d = props.showDownloadBtn, showDownloadBtn = _d === void 0 ? true : _d, onDownLoadCallbackAfter = props.onDownLoadCallbackAfter, _e = props.showPreviewBtn, showPreviewBtn = _e === void 0 ? true : _e, onPreviewCallbackBefore = props.onPreviewCallbackBefore, _f = props.showTable, showTable = _f === void 0 ? true : _f, showUploadList = props.showUploadList, onChange = props.onChange, beforeUpload = props.beforeUpload, multiple = props.multiple, ztAccept = props.ztAccept, ztShowTipText = props.ztShowTipText, maxCount = props.maxCount, maxSize = props.maxSize, maxSizeStr = props.maxSizeStr, action = props.action, headers = props.headers, method = props.method, uploadUser = props.uploadUser, originFileList = props.originFileList, callback = props.callback, onDeleteCallback = props.onDeleteCallback, isAutoDelete = props.isAutoDelete, apiBaseUrl = props.apiBaseUrl, _g = props.fileBaseUrl, fileBaseUrl = _g === void 0 ? '' : _g, fileBtnText = props.fileBtnText, data = props.data, authToken = props.authToken, listType = props.listType, isPublic = props.isPublic, startColumns = props.startColumns, otherColumns = props.otherColumns, _h = props.isDirect, isDirect = _h === void 0 ? false : _h, restProps = __rest(props, ["children", "className", "showTip", "showUploadBtn", "showDeleteBtn", "onDownLoadCallbackBefore", "showDownloadBtn", "onDownLoadCallbackAfter", "showPreviewBtn", "onPreviewCallbackBefore", "showTable", "showUploadList", "onChange", "beforeUpload", "multiple", "ztAccept", "ztShowTipText", "maxCount", "maxSize", "maxSizeStr", "action", "headers", "method", "uploadUser", "originFileList", "callback", "onDeleteCallback", "isAutoDelete", "apiBaseUrl", "fileBaseUrl", "fileBtnText", "data", "authToken", "listType", "isPublic", "startColumns", "otherColumns", "isDirect"]);
83
+ var children = props.children, className = props.className, _a = props.showTip, showTip = _a === void 0 ? true : _a, _b = props.showUploadBtn, showUploadBtn = _b === void 0 ? true : _b, _c = props.showDeleteBtn, showDeleteBtn = _c === void 0 ? true : _c, onDownLoadCallbackBefore = props.onDownLoadCallbackBefore, _d = props.showDownloadBtn, showDownloadBtn = _d === void 0 ? true : _d, onDownLoadCallbackAfter = props.onDownLoadCallbackAfter, _e = props.showPreviewBtn, showPreviewBtn = _e === void 0 ? true : _e, onPreviewCallbackBefore = props.onPreviewCallbackBefore, _f = props.showTable, showTable = _f === void 0 ? true : _f, showUploadList = props.showUploadList, onChange = props.onChange, beforeUpload = props.beforeUpload, multiple = props.multiple, ztAccept = props.ztAccept, ztShowTipText = props.ztShowTipText, maxCount = props.maxCount, maxSize = props.maxSize, maxSizeStr = props.maxSizeStr, action = props.action, headers = props.headers, method = props.method, uploadUser = props.uploadUser, originFileList = props.originFileList, callback = props.callback, onDeleteCallback = props.onDeleteCallback, isAutoDelete = props.isAutoDelete, apiBaseUrl = props.apiBaseUrl, _g = props.fileBaseUrl, fileBaseUrl = _g === void 0 ? '' : _g, fileBtnText = props.fileBtnText, data = props.data, authToken = props.authToken, listType = props.listType, isPublic = props.isPublic, startColumns = props.startColumns, otherColumns = props.otherColumns, _h = props.isDirect, isDirect = _h === void 0 ? false : _h, upload = props.upload, restProps = __rest(props, ["children", "className", "showTip", "showUploadBtn", "showDeleteBtn", "onDownLoadCallbackBefore", "showDownloadBtn", "onDownLoadCallbackAfter", "showPreviewBtn", "onPreviewCallbackBefore", "showTable", "showUploadList", "onChange", "beforeUpload", "multiple", "ztAccept", "ztShowTipText", "maxCount", "maxSize", "maxSizeStr", "action", "headers", "method", "uploadUser", "originFileList", "callback", "onDeleteCallback", "isAutoDelete", "apiBaseUrl", "fileBaseUrl", "fileBtnText", "data", "authToken", "listType", "isPublic", "startColumns", "otherColumns", "isDirect", "upload"]);
48
84
  var _j = useState(originFileList || []), fileList = _j[0], setFileList = _j[1];
49
85
  var _k = useState('20M'), maxSizeTransStr = _k[0], setMaxSizeTransStr = _k[1];
86
+ useEffect(function () {
87
+ if (upload) {
88
+ upload.current = upload.current ? upload.current : {};
89
+ upload.current.validate = function (info) {
90
+ if (info === void 0) { info = { title: '', isError: false }; }
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ var i, fileItem;
93
+ return __generator(this, function (_a) {
94
+ switch (_a.label) {
95
+ case 0:
96
+ if (!Array.isArray(fileList)) return [3 /*break*/, 6];
97
+ i = 0;
98
+ _a.label = 1;
99
+ case 1:
100
+ if (!(i < fileList.length)) return [3 /*break*/, 6];
101
+ fileItem = fileList[i];
102
+ if (!(fileItem.status !== 'done' && fileItem.status !== 'error')) return [3 /*break*/, 3];
103
+ return [4 /*yield*/, Promise.reject({
104
+ errorFields: [
105
+ {
106
+ errors: (info.title || '') + " \u7B2C" + (i + 1) + "\u4E2A\u9644\u4EF6\u8FD8\u5728\u4E0A\u4F20\u4E2D\uFF0C\u8BF7\u7A0D\u7B49...",
107
+ },
108
+ ],
109
+ })];
110
+ case 2:
111
+ _a.sent();
112
+ _a.label = 3;
113
+ case 3:
114
+ if (!(info.isError && fileItem.status === 'error')) return [3 /*break*/, 5];
115
+ return [4 /*yield*/, Promise.reject({
116
+ errorFields: [
117
+ {
118
+ errors: (info.title || '') + " \u7B2C" + (i + 1) + "\u4E2A\u9644\u4EF6\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5",
119
+ },
120
+ ],
121
+ })];
122
+ case 4:
123
+ _a.sent();
124
+ _a.label = 5;
125
+ case 5:
126
+ i++;
127
+ return [3 /*break*/, 1];
128
+ case 6: return [2 /*return*/];
129
+ }
130
+ });
131
+ });
132
+ };
133
+ }
134
+ }, [fileList, upload]);
50
135
  useEffect(function () {
51
136
  var MAXSIZE = maxSize ? maxSize : 1024 * 1024 * 100;
52
137
  var MAXSIZESTR = maxSizeStr ? maxSizeStr : transformFileSize(MAXSIZE);
@@ -58,14 +143,14 @@ var Upload = function (props) {
58
143
  if (listType === 'text') {
59
144
  setFileList(originFileList.map(function (item) {
60
145
  var _a, _b, _c, _d;
61
- var attachId = item.attachId, name = item.name, attachName = item.attachName, fileSize = item.fileSize, size = item.size, response = item.response;
146
+ var attachId = item.attachId, name = item.name, attachName = item.attachName, fileSize = item.fileSize, size = item.size, response = item.response, percent = item.percent, status = item.status;
62
147
  return __assign(__assign({}, item), { uid: attachId ? attachId : (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.attachId, size: fileSize ? fileSize : size, name: name
63
148
  ? name
64
149
  : attachName
65
150
  ? attachName
66
151
  : ((_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.attachName)
67
152
  ? (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.attachName
68
- : (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.originalName, percent: 100, status: 'done', response: response
153
+ : (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.originalName, percent: typeof percent === 'number' ? percent : 100, status: status ? status : 'done', response: response
69
154
  ? response
70
155
  : {
71
156
  code: 200,
@@ -78,7 +163,7 @@ var Upload = function (props) {
78
163
  else {
79
164
  setFileList(originFileList.map(function (item) {
80
165
  var _a, _b, _c, _d, _e;
81
- var attachId = item.attachId, name = item.name, attachName = item.attachName, fileSize = item.fileSize, size = item.size, response = item.response;
166
+ var attachId = item.attachId, name = item.name, attachName = item.attachName, fileSize = item.fileSize, size = item.size, response = item.response, percent = item.percent, status = item.status;
82
167
  var fileId = response ? (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.attachId : null;
83
168
  return __assign(__assign({}, item), { uid: attachId ? attachId : (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.attachId, size: fileSize ? fileSize : size, name: name
84
169
  ? name
@@ -86,7 +171,7 @@ var Upload = function (props) {
86
171
  ? attachName
87
172
  : ((_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.attachName)
88
173
  ? (_d = response === null || response === void 0 ? void 0 : response.data) === null || _d === void 0 ? void 0 : _d.attachName
89
- : (_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.originalName, percent: 100, status: 'done', response: response
174
+ : (_e = response === null || response === void 0 ? void 0 : response.data) === null || _e === void 0 ? void 0 : _e.originalName, percent: typeof percent === 'number' ? percent : 100, status: status ? status : 'done', response: response
90
175
  ? response
91
176
  : {
92
177
  code: 200,
package/dist/index.js CHANGED
@@ -1,82 +1,61 @@
1
- // import React from 'react';
2
- // import ReactDOM from 'react-dom';
3
- // import App from './App';
4
- // import { ConfigProvider } from 'antd';
5
- // import zhCN from 'antd/lib/locale/zh_CN';
6
- // import * as dayjs from 'dayjs';
7
- // import zhCn from 'dayjs/locale/zh-cn';
8
- // import { BrowserRouter, Switch, Route, Link } from 'react-router-dom';
9
- // import Demo from './Demo';
10
- // import TreeSelectDemo from './TreeSelectDemo';
11
- // import TreeDemo from './TreeDemo';
12
- // import UploadDemo from './UploadDemo';
13
- // import CollapseDemo from './DemoCom/CollapseDemo';
14
- // import TimelineDemo from './DemoCom/TimelineDemo';
15
- // import WeChatDemo from './DemoCom/WechatDemo';
16
- // import TableDemo from './DemoCom/TableDemo';
17
- // import BasicDemo from './DemoCom/BasicDemo';
18
- // import FormDemo from './DemoCom/FormDemo';
19
- // dayjs.locale(zhCn);
20
- // ReactDOM.render(
21
- // // <React.StrictMode>
22
- // <ConfigProvider locale={zhCN}>
23
- // <BrowserRouter>
24
- // <Switch>
25
- // <Route exact path="/">
26
- // <App />
27
- // </Route>
28
- // <Route exact path="/select">
29
- // <Demo />
30
- // </Route>
31
- // <Route exact path="/tree-select">
32
- // <TreeSelectDemo />
33
- // </Route>
34
- // <Route exact path="/tree">
35
- // <TreeDemo />
36
- // </Route>
37
- // <Route exact path="/upload">
38
- // <UploadDemo />
39
- // </Route>
40
- // <Route exact path="/collapse">
41
- // <CollapseDemo />
42
- // </Route>
43
- // <Route exact path="/timeline">
44
- // <TimelineDemo />
45
- // </Route>
46
- // <Route exact path="/wechat">
47
- // <WeChatDemo />
48
- // </Route>
49
- // <Route exact path="/table">
50
- // <TableDemo />
51
- // </Route>
52
- // <Route exact path="/basic">
53
- // <BasicDemo />
54
- // </Route>
55
- // <Route exact path="/form">
56
- // <FormDemo />
57
- // </Route>
58
- // <Route exact path="/test">
59
- // <div>
60
- // <h1>
61
- // <Link to="/select">select</Link>
62
- // </h1>
63
- // <h1>
64
- // <Link to="/tree-select">tree select</Link>
65
- // </h1>
66
- // <h1>
67
- // <Link to="/tree">tree</Link>
68
- // </h1>
69
- // <h1>
70
- // <Link to="/upload">upload</Link>
71
- // </h1>
72
- // </div>
73
- // </Route>
74
- // </Switch>
75
- // </BrowserRouter>
76
- // </ConfigProvider>,
77
- // // </React.StrictMode>,
78
- // document.getElementById('root')
79
- // );
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import App from './App';
4
+ import { ConfigProvider } from 'antd';
5
+ import zhCN from 'antd/lib/locale/zh_CN';
6
+ import * as dayjs from 'dayjs';
7
+ import zhCn from 'dayjs/locale/zh-cn';
8
+ import { BrowserRouter, Switch, Route, Link } from 'react-router-dom';
9
+ import Demo from './Demo';
10
+ import TreeSelectDemo from './TreeSelectDemo';
11
+ import TreeDemo from './TreeDemo';
12
+ import UploadDemo from './UploadDemo';
13
+ import CollapseDemo from './DemoCom/CollapseDemo';
14
+ import TimelineDemo from './DemoCom/TimelineDemo';
15
+ import WeChatDemo from './DemoCom/WechatDemo';
16
+ import TableDemo from './DemoCom/TableDemo';
17
+ import BasicDemo from './DemoCom/BasicDemo';
18
+ import FormDemo from './DemoCom/FormDemo';
19
+ dayjs.locale(zhCn);
20
+ ReactDOM.render(
21
+ // <React.StrictMode>
22
+ React.createElement(ConfigProvider, { locale: zhCN },
23
+ React.createElement(BrowserRouter, null,
24
+ React.createElement(Switch, null,
25
+ React.createElement(Route, { exact: true, path: "/" },
26
+ React.createElement(App, null)),
27
+ React.createElement(Route, { exact: true, path: "/select" },
28
+ React.createElement(Demo, null)),
29
+ React.createElement(Route, { exact: true, path: "/tree-select" },
30
+ React.createElement(TreeSelectDemo, null)),
31
+ React.createElement(Route, { exact: true, path: "/tree" },
32
+ React.createElement(TreeDemo, null)),
33
+ React.createElement(Route, { exact: true, path: "/upload" },
34
+ React.createElement(UploadDemo, null)),
35
+ React.createElement(Route, { exact: true, path: "/collapse" },
36
+ React.createElement(CollapseDemo, null)),
37
+ React.createElement(Route, { exact: true, path: "/timeline" },
38
+ React.createElement(TimelineDemo, null)),
39
+ React.createElement(Route, { exact: true, path: "/wechat" },
40
+ React.createElement(WeChatDemo, null)),
41
+ React.createElement(Route, { exact: true, path: "/table" },
42
+ React.createElement(TableDemo, null)),
43
+ React.createElement(Route, { exact: true, path: "/basic" },
44
+ React.createElement(BasicDemo, null)),
45
+ React.createElement(Route, { exact: true, path: "/form" },
46
+ React.createElement(FormDemo, null)),
47
+ React.createElement(Route, { exact: true, path: "/test" },
48
+ React.createElement("div", null,
49
+ React.createElement("h1", null,
50
+ React.createElement(Link, { to: "/select" }, "select")),
51
+ React.createElement("h1", null,
52
+ React.createElement(Link, { to: "/tree-select" }, "tree select")),
53
+ React.createElement("h1", null,
54
+ React.createElement(Link, { to: "/tree" }, "tree")),
55
+ React.createElement("h1", null,
56
+ React.createElement(Link, { to: "/upload" }, "upload"))))))),
57
+ // </React.StrictMode>,
58
+ document.getElementById('root'));
80
59
  export { default as Button } from './components/Button';
81
60
  export { default as Calendar } from './components/Calendar';
82
61
  export { default as Checkbox } from './components/Checkbox';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",