ronds-metadata 1.1.70 → 1.1.71

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,6 +1,7 @@
1
1
  interface IFileViewProps {
2
- path: string;
2
+ path?: string;
3
3
  limit?: number;
4
+ data?: any[];
4
5
  }
5
6
  declare const FileView: (props: IFileViewProps) => JSX.Element;
6
7
  export default FileView;
@@ -10,6 +10,7 @@ import * as XLSX from 'xlsx';
10
10
 
11
11
  var FileView = function FileView(props) {
12
12
  var path = props.path,
13
+ data = props.data,
13
14
  _props$limit = props.limit,
14
15
  limit = _props$limit === void 0 ? 1000 : _props$limit;
15
16
  var ref = React.useRef(null);
@@ -79,14 +80,17 @@ var FileView = function FileView(props) {
79
80
 
80
81
  case 6:
81
82
  blob = _context.sent;
82
- fileReader = new FileReader(); //二进制
83
+ fileReader = new FileReader();
84
+ // blob.type = 'text/csv;charset=utf-8;';
85
+ // const bl = new Blob([blob], { type: 'text/csv;charset=utf-8;' });
86
+ // console.log('blob2', bl);
87
+ //二进制
83
88
  // fileReader.readAsBinaryString(blob);
84
-
85
89
  fileReader.readAsArrayBuffer(blob);
86
90
 
87
91
  fileReader.onload = function (event) {
88
92
  try {
89
- var data = [];
93
+ var _data = [];
90
94
  var binary = ''; // 以二进制流方式读取得到整份excel表格对象
91
95
 
92
96
  var result = event.target.result;
@@ -105,13 +109,13 @@ var FileView = function FileView(props) {
105
109
  for (var sheet in workbook.Sheets) {
106
110
  if (workbook.Sheets.hasOwnProperty(sheet)) {
107
111
  // 利用 sheet_to_json 方法将 excel 转成 json 数据
108
- data = data.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet])); // 如果只取第一张表,就取消注释这行
112
+ _data = _data.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet])); // 如果只取第一张表,就取消注释这行
109
113
 
110
114
  break;
111
115
  }
112
116
  }
113
117
 
114
- processDataToExcel(data);
118
+ processDataToExcel(_data);
115
119
  } catch (e) {
116
120
  return;
117
121
  }
@@ -129,6 +133,11 @@ var FileView = function FileView(props) {
129
133
  getFileData();
130
134
  }
131
135
  }, [getFileData, path]);
136
+ React.useEffect(function () {
137
+ if (data && firstLoadRef.current) {
138
+ processDataToExcel(data);
139
+ }
140
+ }, [getFileData, data]);
132
141
 
133
142
  if (!value) {
134
143
  return /*#__PURE__*/React.createElement(_Spin, null);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "public": true,
3
3
  "name": "ronds-metadata",
4
- "version": "1.1.70",
4
+ "version": "1.1.71",
5
5
  "scripts": {
6
6
  "start": "dumi dev",
7
7
  "docs:build": "dumi build",
@@ -44,6 +44,7 @@
44
44
  "babel-plugin-transform-remove-console": "^6.9.4",
45
45
  "bl": "^5.0.0",
46
46
  "codemirror": "^5.63.0",
47
+ "codepage": "^1.15.0",
47
48
  "github-markdown-css": "^5.1.0",
48
49
  "immer": "^9.0.14",
49
50
  "lodash": "^4.17.21",