|
|
(self["webpackChunk"] = self["webpackChunk"] || []).push([[86541],{
|
|
|
|
|
|
/***/ 56609:
|
|
|
/*!*********************************************!*\
|
|
|
!*** ./src/components/UploadFile/index.tsx ***!
|
|
|
\*********************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
"use strict";
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
|
/* harmony export */ cT: function() { return /* binding */ uploadFile; },
|
|
|
/* harmony export */ pe: function() { return /* binding */ decrypt; }
|
|
|
/* harmony export */ });
|
|
|
/* unused harmony exports reNameFile, UploadFile */
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/toConsumableArray.js */ 37205);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_0__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js */ 79800);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectWithoutProperties.js */ 39647);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_2__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectSpread2.js */ 82242);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_3__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/regeneratorRuntime.js */ 7557);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_4__);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/asyncToGenerator.js */ 41498);
|
|
|
/* harmony import */ var _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_5__);
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react */ 59301);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! antd */ 60028);
|
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! antd */ 8591);
|
|
|
/* harmony import */ var _utils_fetch__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/utils/fetch */ 49105);
|
|
|
/* harmony import */ var crypto_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! crypto-js */ 28209);
|
|
|
/* harmony import */ var crypto_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(crypto_js__WEBPACK_IMPORTED_MODULE_8__);
|
|
|
/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! uuid */ 1012);
|
|
|
/* harmony import */ var umi__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! umi */ 80608);
|
|
|
/* harmony import */ var ali_oss__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ali-oss */ 75264);
|
|
|
/* harmony import */ var ali_oss__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(ali_oss__WEBPACK_IMPORTED_MODULE_11__);
|
|
|
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! react/jsx-runtime */ 37712);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _excluded = ["user", "cancelUpload"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Dragger = antd__WEBPACK_IMPORTED_MODULE_10__/* ["default"] */ .Z.Dragger;
|
|
|
|
|
|
|
|
|
var decrypt = function decrypt(word) {
|
|
|
var ENC_KEY = "bf3c199c2470cb477d907b1e0917c17b";
|
|
|
var IV = "5183666c72eec9e4";
|
|
|
var key = crypto_js__WEBPACK_IMPORTED_MODULE_8___default().enc.Utf8.parse(ENC_KEY);
|
|
|
var iv = crypto_js__WEBPACK_IMPORTED_MODULE_8___default().enc.Utf8.parse(IV);
|
|
|
var decrypt = crypto_js__WEBPACK_IMPORTED_MODULE_8___default().AES.decrypt(word, key, {
|
|
|
iv: iv,
|
|
|
mode: (crypto_js__WEBPACK_IMPORTED_MODULE_8___default().mode).CBC
|
|
|
// padding: CryptoJS.pad.ZeroPadding
|
|
|
});
|
|
|
return decrypt.toString((crypto_js__WEBPACK_IMPORTED_MODULE_8___default().enc).Utf8);
|
|
|
};
|
|
|
var tempCheckpoint;
|
|
|
// 重命名
|
|
|
var reNameFile = /*#__PURE__*/(/* unused pure expression or super */ null && (function () {
|
|
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
|
var _res$data, _res$data2, _res$data3, _res$data4, _res$data5, _res$data6;
|
|
|
var identifier, oldFilename, newFilename, res, client;
|
|
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
|
while (1) switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
identifier = _ref.identifier, oldFilename = _ref.oldFilename, newFilename = _ref.newFilename;
|
|
|
_context.next = 3;
|
|
|
return Fetch('/api/buckets/get_upload_token_for_big_files.json', {
|
|
|
method: "get"
|
|
|
});
|
|
|
case 3:
|
|
|
res = _context.sent;
|
|
|
res.data = JSON.parse(decrypt(res.data));
|
|
|
client = new OSS({
|
|
|
endpoint: res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.end_point,
|
|
|
region: res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.region,
|
|
|
accessKeyId: res === null || res === void 0 || (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.access_key_id,
|
|
|
accessKeySecret: res === null || res === void 0 || (_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : _res$data4.access_key_secret,
|
|
|
bucket: res === null || res === void 0 || (_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : _res$data5.bucket,
|
|
|
stsToken: res === null || res === void 0 || (_res$data6 = res.data) === null || _res$data6 === void 0 ? void 0 : _res$data6.security_token
|
|
|
});
|
|
|
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
|
console.log(11111, "".concat(identifier, "/").concat(oldFilename), "".concat(identifier, "/").concat(newFilename), res.data);
|
|
|
client.copy("/".concat(identifier, "/").concat(oldFilename), "/".concat(identifier, "/").concat(newFilename)).then(function (r) {
|
|
|
console.log('拷贝成功', r);
|
|
|
// client
|
|
|
// .delete(`${identifier}/${oldFilename}`)
|
|
|
// .then(r => console.log(r))
|
|
|
// .catch(e => console.log(e));
|
|
|
})["catch"](function (e) {
|
|
|
console.log(e);
|
|
|
// debugger
|
|
|
});
|
|
|
}));
|
|
|
case 7:
|
|
|
case "end":
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}, _callee);
|
|
|
}));
|
|
|
return function reNameFile(_x) {
|
|
|
return _ref2.apply(this, arguments);
|
|
|
};
|
|
|
}()));
|
|
|
var uploadFile = /*#__PURE__*/function () {
|
|
|
var _ref3 = _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_5___default()( /*#__PURE__*/_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_4___default()().mark(function _callee2(file, obj, config) {
|
|
|
var _res$data7, _res$data8, _res$data9, _res$data10, _res$data11, _res$data12;
|
|
|
var res, namearrs, name, client;
|
|
|
return _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_4___default()().wrap(function _callee2$(_context2) {
|
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
|
case 0:
|
|
|
obj.file_name = file.name;
|
|
|
_context2.next = 3;
|
|
|
return (0,_utils_fetch__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .ZP)('/api/buckets/get_upload_token.json', {
|
|
|
method: "get"
|
|
|
});
|
|
|
case 3:
|
|
|
res = _context2.sent;
|
|
|
console.log("decrypt(res.data):", decrypt(res.data));
|
|
|
res.data = JSON.parse(decrypt(res.data));
|
|
|
namearrs = file.name.split(".");
|
|
|
namearrs.pop();
|
|
|
name = obj.realFileName ? namearrs.join("") : (0,uuid__WEBPACK_IMPORTED_MODULE_13__/* ["default"] */ .Z)(); // const name = file.name
|
|
|
client = new (ali_oss__WEBPACK_IMPORTED_MODULE_11___default())({
|
|
|
endpoint: res === null || res === void 0 || (_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.end_point,
|
|
|
region: res === null || res === void 0 || (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.region,
|
|
|
accessKeyId: res === null || res === void 0 || (_res$data9 = res.data) === null || _res$data9 === void 0 ? void 0 : _res$data9.access_key_id,
|
|
|
accessKeySecret: res === null || res === void 0 || (_res$data10 = res.data) === null || _res$data10 === void 0 ? void 0 : _res$data10.access_key_secret,
|
|
|
bucket: res === null || res === void 0 || (_res$data11 = res.data) === null || _res$data11 === void 0 ? void 0 : _res$data11.bucket,
|
|
|
stsToken: res === null || res === void 0 || (_res$data12 = res.data) === null || _res$data12 === void 0 ? void 0 : _res$data12.security_token
|
|
|
});
|
|
|
return _context2.abrupt("return", new Promise(function (resolve, reject) {
|
|
|
var _res$data13;
|
|
|
client.multipartUpload("".concat(name), new Blob([file], {
|
|
|
type: file.type
|
|
|
}), _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_3___default()(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_3___default()({
|
|
|
timeout: 200 * 1000,
|
|
|
partSize: 102400
|
|
|
}, config), {}, {
|
|
|
callback: {
|
|
|
url: res === null || res === void 0 || (_res$data13 = res.data) === null || _res$data13 === void 0 ? void 0 : _res$data13.callback_url,
|
|
|
host: res === null || res === void 0 ? void 0 : res.data.bucket_host,
|
|
|
body: 'bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&my_var=${x:my_var}&' + (0,_utils_fetch__WEBPACK_IMPORTED_MODULE_7__/* .parseParams */ .rz)(obj)
|
|
|
// body: 'bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&my_var=${x:my_var}&login=' + obj.login + '&container_id=' + obj.container_id + '&container_type='+obj.container_type,
|
|
|
}
|
|
|
})).then(function (result) {
|
|
|
var _result$data;
|
|
|
file.response = (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.data;
|
|
|
resolve(result === null || result === void 0 ? void 0 : result.data);
|
|
|
})["catch"](function (err) {
|
|
|
reject(err);
|
|
|
console.log("err:", err);
|
|
|
});
|
|
|
}));
|
|
|
case 11:
|
|
|
case "end":
|
|
|
return _context2.stop();
|
|
|
}
|
|
|
}, _callee2);
|
|
|
}));
|
|
|
return function uploadFile(_x2, _x3, _x4) {
|
|
|
return _ref3.apply(this, arguments);
|
|
|
};
|
|
|
}();
|
|
|
var UploadFile = function UploadFile(_ref4) {
|
|
|
var user = _ref4.user,
|
|
|
cancelUpload = _ref4.cancelUpload,
|
|
|
props = _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectWithoutProperties_js__WEBPACK_IMPORTED_MODULE_2___default()(_ref4, _excluded);
|
|
|
var _useState = (0,react__WEBPACK_IMPORTED_MODULE_6__.useState)([]),
|
|
|
_useState2 = _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default()(_useState, 2),
|
|
|
fileList = _useState2[0],
|
|
|
setFileList = _useState2[1];
|
|
|
var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_6__.useState)(),
|
|
|
_useState4 = _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_slicedToArray_js__WEBPACK_IMPORTED_MODULE_1___default()(_useState3, 2),
|
|
|
client = _useState4[0],
|
|
|
setClient = _useState4[1];
|
|
|
var _props = {
|
|
|
onRemove: function onRemove(e) {
|
|
|
setFileList(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_0___default()(fileList.filter(function (item) {
|
|
|
return item.name !== e.name;
|
|
|
})));
|
|
|
props.onChange(fileList.filter(function (item) {
|
|
|
return item.name !== e.name;
|
|
|
}));
|
|
|
},
|
|
|
disabled: props.disabled,
|
|
|
multiple: true,
|
|
|
fileList: fileList === null || fileList === void 0 ? void 0 : fileList.map(function (item) {
|
|
|
return item.file;
|
|
|
}),
|
|
|
customRequest: function customRequest() {},
|
|
|
beforeUpload: function () {
|
|
|
var _beforeUpload = _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_5___default()( /*#__PURE__*/_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_4___default()().mark(function _callee3(file) {
|
|
|
var fileSize;
|
|
|
return _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_4___default()().wrap(function _callee3$(_context3) {
|
|
|
while (1) switch (_context3.prev = _context3.next) {
|
|
|
case 0:
|
|
|
fileSize = props.maxSize || 1024 * 1024 * 1024 * 1;
|
|
|
if (!fileList.filter(function (item) {
|
|
|
return item.name === file.name;
|
|
|
}).length) {
|
|
|
_context3.next = 4;
|
|
|
break;
|
|
|
}
|
|
|
antd__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .ZP.info("".concat(file.name, "\u5DF2\u5B58\u5728\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9"));
|
|
|
return _context3.abrupt("return");
|
|
|
case 4:
|
|
|
if (!((file === null || file === void 0 ? void 0 : file.size) > fileSize)) {
|
|
|
_context3.next = 7;
|
|
|
break;
|
|
|
}
|
|
|
antd__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .ZP.info("\u6587\u4EF6\u8D85\u8FC7".concat(fileSize / 1024 / 1024 / 1024, "GB\uFF0C\u4E0D\u7B26\u5408\u4E0A\u4F20\u8981\u6C42"));
|
|
|
return _context3.abrupt("return", false);
|
|
|
case 7:
|
|
|
fileList.push({
|
|
|
name: file.name,
|
|
|
file: file
|
|
|
});
|
|
|
setFileList(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_0___default()(fileList));
|
|
|
props.onChange(fileList);
|
|
|
return _context3.abrupt("return", false);
|
|
|
case 11:
|
|
|
case "end":
|
|
|
return _context3.stop();
|
|
|
}
|
|
|
}, _callee3);
|
|
|
}));
|
|
|
function beforeUpload(_x5) {
|
|
|
return _beforeUpload.apply(this, arguments);
|
|
|
}
|
|
|
return beforeUpload;
|
|
|
}()
|
|
|
};
|
|
|
var _uploadFiles = /*#__PURE__*/function () {
|
|
|
var _ref5 = _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_5___default()( /*#__PURE__*/_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_4___default()().mark(function _callee4(file, obj) {
|
|
|
var _res$data14, _res$data15, _res$data16, _res$data17, _res$data18, _res$data19;
|
|
|
var name, res, namearrs, filename;
|
|
|
return _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_4___default()().wrap(function _callee4$(_context4) {
|
|
|
while (1) switch (_context4.prev = _context4.next) {
|
|
|
case 0:
|
|
|
obj.file_name = file.name;
|
|
|
name = file.name;
|
|
|
_context4.next = 4;
|
|
|
return (0,_utils_fetch__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .ZP)('/api/buckets/get_upload_token_for_big_files.json', {
|
|
|
method: "get"
|
|
|
});
|
|
|
case 4:
|
|
|
res = _context4.sent;
|
|
|
res.data = JSON.parse(decrypt(res.data));
|
|
|
if (!((res === null || res === void 0 ? void 0 : res.status) !== 0)) {
|
|
|
_context4.next = 12;
|
|
|
break;
|
|
|
}
|
|
|
fileList[fileList.findIndex(function (item) {
|
|
|
return item.name === name;
|
|
|
})]['status'] = 'error';
|
|
|
fileList[fileList.findIndex(function (item) {
|
|
|
return item.name === name;
|
|
|
})]['file']['status'] = 'error';
|
|
|
props.onChange(fileList);
|
|
|
antd__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .ZP.warning("上传失败,请重新尝试");
|
|
|
return _context4.abrupt("return");
|
|
|
case 12:
|
|
|
client = new (ali_oss__WEBPACK_IMPORTED_MODULE_11___default())({
|
|
|
endpoint: res === null || res === void 0 || (_res$data14 = res.data) === null || _res$data14 === void 0 ? void 0 : _res$data14.end_point,
|
|
|
region: res === null || res === void 0 || (_res$data15 = res.data) === null || _res$data15 === void 0 ? void 0 : _res$data15.region,
|
|
|
accessKeyId: res === null || res === void 0 || (_res$data16 = res.data) === null || _res$data16 === void 0 ? void 0 : _res$data16.access_key_id,
|
|
|
accessKeySecret: res === null || res === void 0 || (_res$data17 = res.data) === null || _res$data17 === void 0 ? void 0 : _res$data17.access_key_secret,
|
|
|
bucket: res === null || res === void 0 || (_res$data18 = res.data) === null || _res$data18 === void 0 ? void 0 : _res$data18.bucket,
|
|
|
stsToken: res === null || res === void 0 || (_res$data19 = res.data) === null || _res$data19 === void 0 ? void 0 : _res$data19.security_token
|
|
|
});
|
|
|
console.log(file, 'file');
|
|
|
setClient(client);
|
|
|
// const filename = uuidv4()
|
|
|
namearrs = file.name.split(".");
|
|
|
namearrs.pop();
|
|
|
filename = obj.realFileName ? namearrs.join(".") : (0,uuid__WEBPACK_IMPORTED_MODULE_13__/* ["default"] */ .Z)();
|
|
|
return _context4.abrupt("return", new Promise(function (resolve, reject) {
|
|
|
try {
|
|
|
var _res$data20;
|
|
|
client.multipartUpload("".concat(props.identifier, "/").concat(filename).concat(name.indexOf(".") > -1 ? '.' + name.split(".").pop() : ""), new Blob([file.file], {
|
|
|
type: file.file.type
|
|
|
}), {
|
|
|
timeout: 3600 * 1000,
|
|
|
partSize: 1002400,
|
|
|
progress: function progress(p, checkpoint, res) {
|
|
|
try {
|
|
|
console.log("进度", p, checkpoint, res);
|
|
|
var index = fileList.findIndex(function (item) {
|
|
|
return item.name === name;
|
|
|
});
|
|
|
fileList[index]['file']['percent'] = p * 100;
|
|
|
// if (p === 1) {
|
|
|
// fileList[index]['status'] = 'done'
|
|
|
// fileList[index]['file']['status'] = 'done'
|
|
|
// props.onChange(fileList)
|
|
|
// }
|
|
|
fileList[index].tempCheckpoint = checkpoint;
|
|
|
setFileList(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_0___default()(fileList));
|
|
|
} catch (e) {}
|
|
|
},
|
|
|
checkpoint: fileList[fileList.findIndex(function (item) {
|
|
|
return item.name === name;
|
|
|
})].tempCheckpoint,
|
|
|
callback: {
|
|
|
customValue: {
|
|
|
id: name + ''
|
|
|
},
|
|
|
url: res === null || res === void 0 || (_res$data20 = res.data) === null || _res$data20 === void 0 ? void 0 : _res$data20.callback_url,
|
|
|
host: res === null || res === void 0 ? void 0 : res.data.bucket_host,
|
|
|
body: 'bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&my_var=${x:my_var}&' + (0,_utils_fetch__WEBPACK_IMPORTED_MODULE_7__/* .parseParams */ .rz)(obj)
|
|
|
}
|
|
|
}).then(function (result) {
|
|
|
var _result$data2;
|
|
|
var index = fileList.findIndex(function (item) {
|
|
|
return item.name === name;
|
|
|
});
|
|
|
var status = 'done';
|
|
|
if (((_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.status) === 0) {
|
|
|
var _result$data3;
|
|
|
file.response = (_result$data3 = result.data) === null || _result$data3 === void 0 ? void 0 : _result$data3.data;
|
|
|
var _index = fileList.findIndex(function (item) {
|
|
|
return item.name === name;
|
|
|
});
|
|
|
fileList[_index]['status'] = 'done';
|
|
|
fileList[_index]['file']['status'] = 'done';
|
|
|
} else {
|
|
|
var _result$data4;
|
|
|
antd__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .ZP.warning((_result$data4 = result.data) === null || _result$data4 === void 0 ? void 0 : _result$data4.message);
|
|
|
status = 'error';
|
|
|
}
|
|
|
fileList[index]['status'] = status;
|
|
|
fileList[index]['file']['status'] = status;
|
|
|
props.onChange(fileList);
|
|
|
resolve(result === null || result === void 0 ? void 0 : result.data);
|
|
|
})["catch"](function (err) {
|
|
|
fileList[fileList.findIndex(function (item) {
|
|
|
return item.name === name;
|
|
|
})]['status'] = 'error';
|
|
|
fileList[fileList.findIndex(function (item) {
|
|
|
return item.name === name;
|
|
|
})]['file']['status'] = 'error';
|
|
|
antd__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .ZP.warning("上传失败,请重新尝试");
|
|
|
setFileList(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_toConsumableArray_js__WEBPACK_IMPORTED_MODULE_0___default()(fileList));
|
|
|
props.onChange(fileList);
|
|
|
reject(err);
|
|
|
console.log("err:", err);
|
|
|
});
|
|
|
} catch (e) {
|
|
|
// debugger
|
|
|
}
|
|
|
}));
|
|
|
case 19:
|
|
|
case "end":
|
|
|
return _context4.stop();
|
|
|
}
|
|
|
}, _callee4);
|
|
|
}));
|
|
|
return function _uploadFiles(_x6, _x7) {
|
|
|
return _ref5.apply(this, arguments);
|
|
|
};
|
|
|
}();
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_6__.useEffect)(function () {
|
|
|
if (fileList.every(function (item) {
|
|
|
return item === 'done' || item === 'error';
|
|
|
})) {
|
|
|
props.onComplete(fileList);
|
|
|
}
|
|
|
}, [fileList]);
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_6__.useEffect)(function () {
|
|
|
if (cancelUpload) {
|
|
|
var _client;
|
|
|
(_client = client) === null || _client === void 0 || _client.cancel();
|
|
|
}
|
|
|
}, [cancelUpload]);
|
|
|
(0,react__WEBPACK_IMPORTED_MODULE_6__.useEffect)(function () {
|
|
|
if (props.uploading) fileList.map( /*#__PURE__*/function () {
|
|
|
var _ref6 = _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_5___default()( /*#__PURE__*/_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_4___default()().mark(function _callee5(item) {
|
|
|
var _user$userInfo, res;
|
|
|
return _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_4___default()().wrap(function _callee5$(_context5) {
|
|
|
while (1) switch (_context5.prev = _context5.next) {
|
|
|
case 0:
|
|
|
if (!((!item.status || item.status === 'error') && !cancelUpload)) {
|
|
|
_context5.next = 6;
|
|
|
break;
|
|
|
}
|
|
|
item.status = 'uploading';
|
|
|
item.file.status = 'uploading';
|
|
|
_context5.next = 5;
|
|
|
return _uploadFiles(item, {
|
|
|
login: user === null || user === void 0 || (_user$userInfo = user.userInfo) === null || _user$userInfo === void 0 ? void 0 : _user$userInfo.login,
|
|
|
container_type: props.container_type,
|
|
|
container_id: props.container_id,
|
|
|
description: props.description,
|
|
|
realFileName: props.realFileName
|
|
|
});
|
|
|
case 5:
|
|
|
res = _context5.sent;
|
|
|
case 6:
|
|
|
case "end":
|
|
|
return _context5.stop();
|
|
|
}
|
|
|
}, _callee5);
|
|
|
}));
|
|
|
return function (_x8) {
|
|
|
return _ref6.apply(this, arguments);
|
|
|
};
|
|
|
}());
|
|
|
}, [props.uploading]);
|
|
|
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(Dragger, _root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_3___default()(_root_workspace_ppte5yg23_local_v9_test4_node_modules_babel_runtime_7_23_6_babel_runtime_helpers_objectSpread2_js__WEBPACK_IMPORTED_MODULE_3___default()({}, _props), {}, {
|
|
|
height: props.height,
|
|
|
className: props.className,
|
|
|
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)("p", {
|
|
|
className: "ant-upload-hint",
|
|
|
children: props.text || '拖拽文件或者点击上传'
|
|
|
})
|
|
|
}));
|
|
|
};
|
|
|
/* harmony default export */ __webpack_exports__.ZP = ((0,umi__WEBPACK_IMPORTED_MODULE_9__.connect)(function (_ref7) {
|
|
|
var loading = _ref7.loading,
|
|
|
globalSetting = _ref7.globalSetting,
|
|
|
user = _ref7.user;
|
|
|
return {
|
|
|
globalSetting: globalSetting,
|
|
|
loading: loading.models.competitions,
|
|
|
user: user
|
|
|
};
|
|
|
})(UploadFile));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 4722:
|
|
|
/*!****************************************************************!*\
|
|
|
!*** ./src/pages/Shixuns/Detail/Dataset/index.tsx + 1 modules ***!
|
|
|
\****************************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
"use strict";
|
|
|
// ESM COMPAT FLAG
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
"default": function() { return /* binding */ Detail_Dataset; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/regeneratorRuntime.js
|
|
|
var regeneratorRuntime = __webpack_require__(7557);
|
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/toConsumableArray.js
|
|
|
var toConsumableArray = __webpack_require__(37205);
|
|
|
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/asyncToGenerator.js
|
|
|
var asyncToGenerator = __webpack_require__(41498);
|
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js
|
|
|
var slicedToArray = __webpack_require__(79800);
|
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectWithoutProperties.js
|
|
|
var objectWithoutProperties = __webpack_require__(39647);
|
|
|
var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
// EXTERNAL MODULE: ./src/.umi-production/exports.ts
|
|
|
var _umi_production_exports = __webpack_require__(80608);
|
|
|
// EXTERNAL MODULE: ./src/pages/Shixuns/Detail/components/Right/index.tsx + 4 modules
|
|
|
var Right = __webpack_require__(77379);
|
|
|
// EXTERNAL MODULE: ./node_modules/_dayjs@1.11.13@dayjs/dayjs.min.js
|
|
|
var dayjs_min = __webpack_require__(61186);
|
|
|
var dayjs_min_default = /*#__PURE__*/__webpack_require__.n(dayjs_min);
|
|
|
// EXTERNAL MODULE: ./src/components/NoData/index.tsx
|
|
|
var NoData = __webpack_require__(6638);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react-copy-to-clipboard@5.0.2@react-copy-to-clipboard/lib/index.js
|
|
|
var lib = __webpack_require__(56102);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/message/index.js + 4 modules
|
|
|
var message = __webpack_require__(8591);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/modal/index.js + 16 modules
|
|
|
var modal = __webpack_require__(43418);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/checkbox/index.js + 3 modules
|
|
|
var es_checkbox = __webpack_require__(24905);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/tooltip/index.js + 3 modules
|
|
|
var tooltip = __webpack_require__(6848);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/button/index.js
|
|
|
var es_button = __webpack_require__(3113);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/skeleton/index.js + 12 modules
|
|
|
var skeleton = __webpack_require__(66999);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/table/index.js + 85 modules
|
|
|
var table = __webpack_require__(51945);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/pagination/index.js + 10 modules
|
|
|
var pagination = __webpack_require__(86859);
|
|
|
// EXTERNAL MODULE: ./src/utils/util.tsx
|
|
|
var util = __webpack_require__(27876);
|
|
|
;// CONCATENATED MODULE: ./src/pages/Shixuns/Detail/Dataset/index.less?modules
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
/* harmony default export */ var Datasetmodules = ({"bg":"bg___NFraa","wrap":"wrap___C_Y44","content":"content___t7bDk","modal":"modal___K3UdK","action":"action___pu6F6","actionButton":"actionButton___fYPEj","grayButton":"grayButton___sbGlB"});
|
|
|
// EXTERNAL MODULE: ./src/pages/Shixuns/Edit/body/Dataset/components/UploadFile/index.tsx + 1 modules
|
|
|
var UploadFile = __webpack_require__(97396);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
|
;// CONCATENATED MODULE: ./src/pages/Shixuns/Detail/Dataset/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _excluded = ["shixunsDetail", "globalSetting", "loading", "user", "dispatch"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Dataset = function Dataset(_ref) {
|
|
|
var _shixunsDetail$detail, _shixunsDetail$detail2, _globalSetting$settin;
|
|
|
var shixunsDetail = _ref.shixunsDetail,
|
|
|
globalSetting = _ref.globalSetting,
|
|
|
loading = _ref.loading,
|
|
|
user = _ref.user,
|
|
|
dispatch = _ref.dispatch,
|
|
|
props = objectWithoutProperties_default()(_ref, _excluded);
|
|
|
var shixunId = (0,_react_17_0_2_react.useRef)();
|
|
|
var _useState = (0,_react_17_0_2_react.useState)([]),
|
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
|
dataList = _useState2[0],
|
|
|
setDataList = _useState2[1];
|
|
|
var _useState3 = (0,_react_17_0_2_react.useState)(0),
|
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
|
count = _useState4[0],
|
|
|
setCount = _useState4[1];
|
|
|
var _useState5 = (0,_react_17_0_2_react.useState)([]),
|
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
|
selectList = _useState6[0],
|
|
|
setSelectList = _useState6[1];
|
|
|
var _useState7 = (0,_react_17_0_2_react.useState)(),
|
|
|
_useState8 = slicedToArray_default()(_useState7, 2),
|
|
|
selectAll = _useState8[0],
|
|
|
setSelectAll = _useState8[1];
|
|
|
var _useState9 = (0,_react_17_0_2_react.useState)(false),
|
|
|
_useState10 = slicedToArray_default()(_useState9, 2),
|
|
|
showUploadList = _useState10[0],
|
|
|
setShowUploadList = _useState10[1];
|
|
|
var _useState11 = (0,_react_17_0_2_react.useState)(false),
|
|
|
_useState12 = slicedToArray_default()(_useState11, 2),
|
|
|
showUploadFile = _useState12[0],
|
|
|
setShowUploadFile = _useState12[1];
|
|
|
var _useState13 = (0,_react_17_0_2_react.useState)({
|
|
|
id: null,
|
|
|
page: 1,
|
|
|
limit: 10
|
|
|
}),
|
|
|
_useState14 = slicedToArray_default()(_useState13, 2),
|
|
|
params = _useState14[0],
|
|
|
setParams = _useState14[1];
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
var _location$pathname;
|
|
|
shixunId.current = (_location$pathname = location.pathname) === null || _location$pathname === void 0 || (_location$pathname = _location$pathname.split('/')) === null || _location$pathname === void 0 ? void 0 : _location$pathname[2];
|
|
|
params.id = shixunId.current;
|
|
|
setParams(params);
|
|
|
getSetData(params);
|
|
|
}, []);
|
|
|
var getSetData = /*#__PURE__*/function () {
|
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(query) {
|
|
|
var res;
|
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
|
while (1) switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
_context.next = 2;
|
|
|
return dispatch({
|
|
|
type: 'shixunsDetail/getSetData',
|
|
|
payload: query
|
|
|
});
|
|
|
case 2:
|
|
|
res = _context.sent;
|
|
|
if (res) {
|
|
|
setDataList(toConsumableArray_default()(res.data_sets));
|
|
|
setCount(res.data_sets_count);
|
|
|
setSelectList([]);
|
|
|
setSelectAll(false);
|
|
|
}
|
|
|
case 4:
|
|
|
case "end":
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}, _callee);
|
|
|
}));
|
|
|
return function getSetData(_x) {
|
|
|
return _ref2.apply(this, arguments);
|
|
|
};
|
|
|
}();
|
|
|
var handleChangePage = function handleChangePage(page) {
|
|
|
params.page = page;
|
|
|
setParams(params);
|
|
|
getSetData(params);
|
|
|
};
|
|
|
var handleChangeCheckbox = function handleChangeCheckbox(id, checked) {
|
|
|
if (checked) {
|
|
|
setSelectList([].concat(toConsumableArray_default()(selectList), [id]));
|
|
|
} else {
|
|
|
setSelectList(selectList.filter(function (item) {
|
|
|
return item !== id;
|
|
|
}));
|
|
|
}
|
|
|
};
|
|
|
var handleSelectAll = function handleSelectAll(checked) {
|
|
|
setSelectAll(checked);
|
|
|
if (checked) {
|
|
|
setSelectList(dataList.map(function (item) {
|
|
|
return item.id;
|
|
|
}));
|
|
|
} else {
|
|
|
setSelectList([]);
|
|
|
}
|
|
|
};
|
|
|
var handleDelete = function handleDelete() {
|
|
|
if (!selectList.length) {
|
|
|
message/* default */.ZP.info('请选择要删除的文件');
|
|
|
return;
|
|
|
}
|
|
|
modal/* default */.Z.confirm({
|
|
|
centered: true,
|
|
|
title: '确定要删除文件吗?',
|
|
|
okText: '确定',
|
|
|
cancelText: '取消',
|
|
|
onOk: function () {
|
|
|
var _onOk = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
|
|
|
var res;
|
|
|
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
|
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
|
case 0:
|
|
|
_context2.next = 2;
|
|
|
return dispatch({
|
|
|
type: 'shixunsDetail/deleteDataSet',
|
|
|
payload: {
|
|
|
id: shixunId.current,
|
|
|
deleteId: selectList
|
|
|
}
|
|
|
});
|
|
|
case 2:
|
|
|
res = _context2.sent;
|
|
|
if (res) {
|
|
|
message/* default */.ZP.success('删除成功');
|
|
|
params.page = 1;
|
|
|
setParams(params);
|
|
|
getSetData(params);
|
|
|
}
|
|
|
case 4:
|
|
|
case "end":
|
|
|
return _context2.stop();
|
|
|
}
|
|
|
}, _callee2);
|
|
|
}));
|
|
|
function onOk() {
|
|
|
return _onOk.apply(this, arguments);
|
|
|
}
|
|
|
return onOk;
|
|
|
}()
|
|
|
});
|
|
|
};
|
|
|
var columns = [{
|
|
|
title: "",
|
|
|
dataIndex: "title",
|
|
|
width: 40,
|
|
|
ellipsis: true,
|
|
|
render: function render(add, record) {
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
|
checked: selectList.includes(record.id),
|
|
|
onChange: function onChange(e) {
|
|
|
return handleChangeCheckbox(record.id, e.target.checked);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}, {
|
|
|
title: '文件',
|
|
|
dataIndex: 'title',
|
|
|
key: 'title',
|
|
|
align: 'left',
|
|
|
className: "font14",
|
|
|
width: '220px',
|
|
|
render: function render(text, record) {
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
children: record.title
|
|
|
});
|
|
|
}
|
|
|
}, {
|
|
|
title: '创建时间',
|
|
|
dataIndex: 'created_on',
|
|
|
key: 'created_on',
|
|
|
align: 'center',
|
|
|
className: "font14",
|
|
|
width: '150px',
|
|
|
render: function render(text, record) {
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
children: dayjs_min_default()(record.created_on).format('YYYY-MM-DD HH:mm')
|
|
|
});
|
|
|
}
|
|
|
}, {
|
|
|
title: '最后修改人',
|
|
|
dataIndex: 'author',
|
|
|
key: 'author',
|
|
|
align: 'center',
|
|
|
className: "font14",
|
|
|
render: function render(text, record) {
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
children: record.author
|
|
|
});
|
|
|
}
|
|
|
}, {
|
|
|
title: '文件大小',
|
|
|
dataIndex: 'filesize',
|
|
|
key: 'filesize',
|
|
|
align: 'center',
|
|
|
className: "font14",
|
|
|
render: function render(text, record) {
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
children: record.filesize
|
|
|
});
|
|
|
}
|
|
|
}, {
|
|
|
title: '操作',
|
|
|
dataIndex: 'operation',
|
|
|
key: 'operation',
|
|
|
align: 'center',
|
|
|
className: "font14 current",
|
|
|
render: function render(text, record) {
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(lib.CopyToClipboard, {
|
|
|
text: record.file_path,
|
|
|
onCopy: function onCopy() {
|
|
|
return message/* default */.ZP.success('复制成功');
|
|
|
},
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
|
title: "\u590D\u5236",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
|
className: "iconfont icon-fuzhi3 font18 ml2"
|
|
|
})
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
|
title: "\u4E0B\u8F7D",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: "current ml15 iconfont icon-xiazai2",
|
|
|
onClick: function onClick() {
|
|
|
(0,util/* downLoadLink */.Nd)(record.title, record === null || record === void 0 ? void 0 : record.download_url);
|
|
|
}
|
|
|
})
|
|
|
})]
|
|
|
});
|
|
|
}
|
|
|
}];
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
|
className: Datasetmodules.bg,
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
className: Datasetmodules.wrap,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: Datasetmodules.content,
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: Datasetmodules.action,
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
|
checked: selectAll,
|
|
|
onChange: function onChange(e) {
|
|
|
return handleSelectAll(e.target.checked);
|
|
|
}
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: "ml5",
|
|
|
children: "\u5168\u9009"
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
|
type: "primary",
|
|
|
danger: !!selectList.length,
|
|
|
className: "mr5 ".concat(Datasetmodules.actionButton, " ").concat(selectList.length ? '' : Datasetmodules.grayButton),
|
|
|
onClick: handleDelete,
|
|
|
children: "\u5220\u9664"
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
|
type: "primary",
|
|
|
onClick: function onClick() {
|
|
|
return setShowUploadFile(true);
|
|
|
},
|
|
|
children: "\u4E0A\u4F20\u6587\u4EF6"
|
|
|
})]
|
|
|
})]
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(skeleton/* default */.Z, {
|
|
|
loading: loading.effects['shixunsDetail/getSetData'],
|
|
|
active: true,
|
|
|
avatar: {
|
|
|
size: 40
|
|
|
},
|
|
|
paragraph: {
|
|
|
rows: 5
|
|
|
},
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
className: "mt20",
|
|
|
children: !!dataList.length ? /*#__PURE__*/(0,jsx_runtime.jsx)(table/* default */.Z, {
|
|
|
columns: columns,
|
|
|
dataSource: dataList,
|
|
|
pagination: false,
|
|
|
loading: loading.effects['shixunsDetail/getSetData']
|
|
|
}) : /*#__PURE__*/(0,jsx_runtime.jsx)(NoData/* default */.Z, {})
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("aside", {
|
|
|
className: "tc mt20",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(pagination/* default */.Z, {
|
|
|
showQuickJumper: true,
|
|
|
showSizeChanger: false,
|
|
|
total: count,
|
|
|
hideOnSinglePage: true,
|
|
|
onChange: function onChange(page) {
|
|
|
return handleChangePage(page);
|
|
|
},
|
|
|
pageSize: params.limit,
|
|
|
current: params.page
|
|
|
})
|
|
|
})]
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(Right/* default */.Z, {}), /*#__PURE__*/(0,jsx_runtime.jsx)(UploadFile/* default */.Z, {
|
|
|
rootIdentifier: shixunsDetail === null || shixunsDetail === void 0 || (_shixunsDetail$detail = shixunsDetail.detail) === null || _shixunsDetail$detail === void 0 ? void 0 : _shixunsDetail$detail.root_identifier,
|
|
|
wrapClassName: Datasetmodules.uploadFileModal,
|
|
|
id: params.id,
|
|
|
containerId: shixunsDetail === null || shixunsDetail === void 0 || (_shixunsDetail$detail2 = shixunsDetail.detail) === null || _shixunsDetail$detail2 === void 0 ? void 0 : _shixunsDetail$detail2.id,
|
|
|
local: globalSetting === null || globalSetting === void 0 || (_globalSetting$settin = globalSetting.setting) === null || _globalSetting$settin === void 0 ? void 0 : _globalSetting$settin.is_local
|
|
|
// local={true}
|
|
|
,
|
|
|
dispatch: dispatch,
|
|
|
visible: showUploadFile,
|
|
|
onClose: function onClose() {
|
|
|
return setShowUploadFile(false);
|
|
|
},
|
|
|
onOK: function onOK() {
|
|
|
return handleChangePage(1);
|
|
|
}
|
|
|
})]
|
|
|
});
|
|
|
};
|
|
|
/* harmony default export */ var Detail_Dataset = ((0,_umi_production_exports.connect)(function (_ref3) {
|
|
|
var shixunsDetail = _ref3.shixunsDetail,
|
|
|
loading = _ref3.loading,
|
|
|
globalSetting = _ref3.globalSetting,
|
|
|
user = _ref3.user;
|
|
|
return {
|
|
|
shixunsDetail: shixunsDetail,
|
|
|
globalSetting: globalSetting,
|
|
|
user: user,
|
|
|
loading: loading
|
|
|
};
|
|
|
})(Dataset));
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 97396:
|
|
|
/*!*****************************************************************************************!*\
|
|
|
!*** ./src/pages/Shixuns/Edit/body/Dataset/components/UploadFile/index.tsx + 1 modules ***!
|
|
|
\*****************************************************************************************/
|
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
// EXPORTS
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
Z: function() { return /* binding */ Dataset_components_UploadFile; }
|
|
|
});
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectSpread2.js
|
|
|
var objectSpread2 = __webpack_require__(82242);
|
|
|
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/regeneratorRuntime.js
|
|
|
var regeneratorRuntime = __webpack_require__(7557);
|
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/toConsumableArray.js
|
|
|
var toConsumableArray = __webpack_require__(37205);
|
|
|
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/asyncToGenerator.js
|
|
|
var asyncToGenerator = __webpack_require__(41498);
|
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js
|
|
|
var slicedToArray = __webpack_require__(79800);
|
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
|
// EXTERNAL MODULE: ./src/utils/env.ts + 1 modules
|
|
|
var env = __webpack_require__(71681);
|
|
|
// EXTERNAL MODULE: ./src/utils/fetch.ts
|
|
|
var fetch = __webpack_require__(49105);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/upload/index.js
|
|
|
var upload = __webpack_require__(60028);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/form/index.js + 19 modules
|
|
|
var es_form = __webpack_require__(78241);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/message/index.js + 4 modules
|
|
|
var message = __webpack_require__(8591);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/modal/index.js + 16 modules
|
|
|
var modal = __webpack_require__(43418);
|
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input/index.js + 3 modules
|
|
|
var input = __webpack_require__(92832);
|
|
|
;// CONCATENATED MODULE: ./src/pages/Shixuns/Edit/body/Dataset/components/UploadFile/index.less?modules
|
|
|
// extracted by mini-css-extract-plugin
|
|
|
/* harmony default export */ var UploadFilemodules = ({"wrap":"wrap___EmsVa","colorBlue":"colorBlue___XqtfP","repeatedName":"repeatedName___yMQsm"});
|
|
|
// EXTERNAL MODULE: ./src/components/UploadFile/index.tsx
|
|
|
var components_UploadFile = __webpack_require__(56609);
|
|
|
// EXTERNAL MODULE: ./src/utils/util.tsx
|
|
|
var util = __webpack_require__(27876);
|
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
|
;// CONCATENATED MODULE: ./src/pages/Shixuns/Edit/body/Dataset/components/UploadFile/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Dragger = upload/* default */.Z.Dragger;
|
|
|
var UploadFile = function UploadFile(_ref) {
|
|
|
var _formValue$commitMess;
|
|
|
var dispatch = _ref.dispatch,
|
|
|
id = _ref.id,
|
|
|
onClose = _ref.onClose,
|
|
|
onOK = _ref.onOK,
|
|
|
visible = _ref.visible,
|
|
|
wrapClassName = _ref.wrapClassName,
|
|
|
local = _ref.local,
|
|
|
containerId = _ref.containerId,
|
|
|
rootIdentifier = _ref.rootIdentifier;
|
|
|
var _useState = (0,_react_17_0_2_react.useState)({}),
|
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
|
formValue = _useState2[0],
|
|
|
setFormValue = _useState2[1];
|
|
|
var _useState3 = (0,_react_17_0_2_react.useState)([]),
|
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
|
repeatedName = _useState4[0],
|
|
|
setRepeatedName = _useState4[1];
|
|
|
var _useState5 = (0,_react_17_0_2_react.useState)([]),
|
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
|
xhrItems = _useState6[0],
|
|
|
setXhrItems = _useState6[1];
|
|
|
var _useState7 = (0,_react_17_0_2_react.useState)(0),
|
|
|
_useState8 = slicedToArray_default()(_useState7, 2),
|
|
|
disabled = _useState8[0],
|
|
|
setDisabled = _useState8[1];
|
|
|
var _useState9 = (0,_react_17_0_2_react.useState)(false),
|
|
|
_useState10 = slicedToArray_default()(_useState9, 2),
|
|
|
cancelUpload = _useState10[0],
|
|
|
setCancelUpload = _useState10[1];
|
|
|
var _useState11 = (0,_react_17_0_2_react.useState)(false),
|
|
|
_useState12 = slicedToArray_default()(_useState11, 2),
|
|
|
btnLoading = _useState12[0],
|
|
|
setBtnLoading = _useState12[1];
|
|
|
var _Form$useForm = es_form/* default */.Z.useForm(),
|
|
|
_Form$useForm2 = slicedToArray_default()(_Form$useForm, 1),
|
|
|
form = _Form$useForm2[0];
|
|
|
var _useState13 = (0,_react_17_0_2_react.useState)([]),
|
|
|
_useState14 = slicedToArray_default()(_useState13, 2),
|
|
|
fileList = _useState14[0],
|
|
|
setFileList = _useState14[1];
|
|
|
var savedFileList = (0,_react_17_0_2_react.useRef)([]);
|
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
|
if (visible) {
|
|
|
form.resetFields();
|
|
|
setFileList([]);
|
|
|
setXhrItems([]);
|
|
|
setRepeatedName([]);
|
|
|
setDisabled(0);
|
|
|
setBtnLoading(false);
|
|
|
setCancelUpload(false);
|
|
|
}
|
|
|
}, [visible]);
|
|
|
var handleChangeFile = function handleChangeFile(info) {
|
|
|
if (info.file.status === 'done' || info.file.status === "uploading") {
|
|
|
var _info$file$response, _info$file$response2, _info$file$response3;
|
|
|
setFileList(info.fileList);
|
|
|
if (!info.file.response) {
|
|
|
return;
|
|
|
}
|
|
|
if ((_info$file$response = info.file.response) !== null && _info$file$response !== void 0 && _info$file$response.id) {
|
|
|
message/* default */.ZP.success("上传成功!");
|
|
|
return;
|
|
|
}
|
|
|
setFileList(fileList.filter(function (item) {
|
|
|
return item.uid !== info.file.uid;
|
|
|
}));
|
|
|
((_info$file$response2 = info.file.response) === null || _info$file$response2 === void 0 ? void 0 : _info$file$response2.message) && message/* default */.ZP.info((_info$file$response3 = info.file.response) === null || _info$file$response3 === void 0 ? void 0 : _info$file$response3.message);
|
|
|
}
|
|
|
};
|
|
|
var handleRemoveFile = /*#__PURE__*/function () {
|
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(info) {
|
|
|
var _info$response;
|
|
|
var newFileList, res;
|
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
|
while (1) switch (_context.prev = _context.next) {
|
|
|
case 0:
|
|
|
if (disabled) {
|
|
|
_context.next = 8;
|
|
|
break;
|
|
|
}
|
|
|
newFileList = fileList.filter(function (item) {
|
|
|
return item.uid !== info.uid;
|
|
|
});
|
|
|
setFileList(newFileList);
|
|
|
savedFileList.current = toConsumableArray_default()(newFileList);
|
|
|
setRepeatedName(repeatedName.filter(function (item) {
|
|
|
return item !== info.name;
|
|
|
}));
|
|
|
message/* default */.ZP.info("删除成功");
|
|
|
if (!newFileList.length) {
|
|
|
form.setFieldsValue({
|
|
|
file: undefined
|
|
|
});
|
|
|
form.validateFields();
|
|
|
}
|
|
|
return _context.abrupt("return");
|
|
|
case 8:
|
|
|
if (info.response) {
|
|
|
_context.next = 11;
|
|
|
break;
|
|
|
}
|
|
|
message/* default */.ZP.info("还未上传完成,无法进行删除操作!");
|
|
|
return _context.abrupt("return");
|
|
|
case 11:
|
|
|
_context.next = 13;
|
|
|
return (0,fetch/* default */.ZP)("/api/shixuns/".concat(id, "/destroy_data_sets.json"), {
|
|
|
method: 'Delete',
|
|
|
body: {
|
|
|
id: [info === null || info === void 0 || (_info$response = info.response) === null || _info$response === void 0 ? void 0 : _info$response.id]
|
|
|
}
|
|
|
});
|
|
|
case 13:
|
|
|
res = _context.sent;
|
|
|
if (res.status === 0) {
|
|
|
setFileList(fileList.filter(function (item) {
|
|
|
return item.uid !== info.uid;
|
|
|
}));
|
|
|
message/* default */.ZP.info("删除成功");
|
|
|
}
|
|
|
case 15:
|
|
|
case "end":
|
|
|
return _context.stop();
|
|
|
}
|
|
|
}, _callee);
|
|
|
}));
|
|
|
return function handleRemoveFile(_x) {
|
|
|
return _ref2.apply(this, arguments);
|
|
|
};
|
|
|
}();
|
|
|
var handleBeforeUpload = function handleBeforeUpload(info) {
|
|
|
if (fileList !== null && fileList !== void 0 && fileList.some(function (e) {
|
|
|
return e.name === info.name;
|
|
|
})) {
|
|
|
message/* default */.ZP.info("".concat(info.name, "\u6587\u4EF6\u5DF2\u5B58\u5728"));
|
|
|
return false;
|
|
|
}
|
|
|
// if (info.size / 1024 / 1024 > 500) {
|
|
|
// message.info("文件超过500M,不符合上传要求");
|
|
|
// return false;
|
|
|
// }
|
|
|
var param = {
|
|
|
name: info.name,
|
|
|
uid: info.uid,
|
|
|
file: info,
|
|
|
percent: 0
|
|
|
};
|
|
|
fileList.push(param);
|
|
|
savedFileList.current = toConsumableArray_default()(fileList);
|
|
|
setFileList(toConsumableArray_default()(fileList));
|
|
|
return false;
|
|
|
};
|
|
|
var draggerProps = {
|
|
|
height: 300,
|
|
|
multiple: true,
|
|
|
disabled: disabled > 0,
|
|
|
withCredentials: true,
|
|
|
fileList: fileList,
|
|
|
action: "".concat(env/* default */.Z.API_SERVER, "/api/attachments.json"),
|
|
|
onChange: handleChangeFile,
|
|
|
onRemove: handleRemoveFile,
|
|
|
beforeUpload: handleBeforeUpload
|
|
|
};
|
|
|
var uploadRequest = function uploadRequest(params, url, callback, progressFunction, error) {
|
|
|
var formData = new FormData();
|
|
|
Object.keys(params).forEach(function (key) {
|
|
|
formData.append(key, params[key]);
|
|
|
});
|
|
|
var xhr = new window.XMLHttpRequest();
|
|
|
xhr.withCredentials = true;
|
|
|
xhr.addEventListener('load', function (res) {
|
|
|
var _res$target;
|
|
|
callback(JSON.parse(res === null || res === void 0 || (_res$target = res.target) === null || _res$target === void 0 ? void 0 : _res$target.response));
|
|
|
}, false);
|
|
|
xhr.addEventListener('error', function (err) {
|
|
|
if (error) {
|
|
|
error(err);
|
|
|
}
|
|
|
}, false);
|
|
|
xhr.upload.onprogress = function (e) {
|
|
|
if (progressFunction) {
|
|
|
progressFunction(e);
|
|
|
}
|
|
|
};
|
|
|
// xhr.ontimeout = function () {
|
|
|
// error('超时');
|
|
|
// },
|
|
|
// xhr.timeout = 10 * 1000
|
|
|
xhr.open('POST', url);
|
|
|
xhr.send(formData);
|
|
|
return xhr;
|
|
|
};
|
|
|
var getProgress = function getProgress(event, item) {
|
|
|
if (event.lengthComputable) {
|
|
|
var percent = Math.floor(event.loaded / event.total * 100);
|
|
|
var param = objectSpread2_default()(objectSpread2_default()({}, item), {}, {
|
|
|
percent: percent,
|
|
|
status: percent === 100 ? 'done' : 'uploading'
|
|
|
});
|
|
|
console.log(savedFileList.current, 333);
|
|
|
// ;
|
|
|
savedFileList.current = savedFileList.current.map(function (e) {
|
|
|
return e.uid === item.uid ? param : e;
|
|
|
});
|
|
|
setFileList(savedFileList.current);
|
|
|
}
|
|
|
};
|
|
|
var error = function error(res, item) {
|
|
|
var param = objectSpread2_default()(objectSpread2_default()({}, item), {}, {
|
|
|
status: 'error'
|
|
|
});
|
|
|
message/* default */.ZP.warning("上传失败,请重新尝试");
|
|
|
savedFileList.current = savedFileList.current.map(function (e) {
|
|
|
return e.uid === item.uid ? param : e;
|
|
|
});
|
|
|
if (savedFileList.current.every(function (e) {
|
|
|
return e.status === 'done' || e.status === 'error';
|
|
|
})) {
|
|
|
setBtnLoading(false);
|
|
|
setDisabled(2);
|
|
|
}
|
|
|
setFileList(savedFileList.current);
|
|
|
};
|
|
|
var callback = function callback(res, item) {
|
|
|
var param = objectSpread2_default()(objectSpread2_default()({}, item), {}, {
|
|
|
status: 'done'
|
|
|
});
|
|
|
if (res.status === 0) {
|
|
|
// message.success('上传成功!')
|
|
|
} else {
|
|
|
param = objectSpread2_default()(objectSpread2_default()({}, item), {}, {
|
|
|
status: 'error'
|
|
|
});
|
|
|
message/* default */.ZP.error('上传失败!');
|
|
|
}
|
|
|
savedFileList.current = savedFileList.current.map(function (e) {
|
|
|
return e.uid === item.uid ? param : e;
|
|
|
});
|
|
|
if (savedFileList.current.every(function (e) {
|
|
|
return e.status === 'done';
|
|
|
})) {
|
|
|
message/* default */.ZP.success('上传完成!');
|
|
|
cancelEnd(true);
|
|
|
return;
|
|
|
}
|
|
|
if (savedFileList.current.every(function (e) {
|
|
|
return e.status === 'done' || e.status === 'error';
|
|
|
})) {
|
|
|
setBtnLoading(false);
|
|
|
setDisabled(2);
|
|
|
}
|
|
|
setFileList(savedFileList.current);
|
|
|
};
|
|
|
var isOnLine = function isOnLine() {
|
|
|
var netStatus = true;
|
|
|
if (window.navigator.onLine == true) {
|
|
|
netStatus = true; //网络链接正常
|
|
|
} else {
|
|
|
netStatus = false; //网络连接失败
|
|
|
}
|
|
|
;
|
|
|
return netStatus;
|
|
|
};
|
|
|
var handleFinish = /*#__PURE__*/function () {
|
|
|
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2(values) {
|
|
|
var _ref4, _ref4$commitMessage, commitMessage, _ref4$fileOss, fileOss, filesItems, names, res;
|
|
|
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
|
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
|
case 0:
|
|
|
setBtnLoading(true);
|
|
|
if (!(disabled === 3)) {
|
|
|
_context2.next = 4;
|
|
|
break;
|
|
|
}
|
|
|
setDisabled(2);
|
|
|
return _context2.abrupt("return");
|
|
|
case 4:
|
|
|
if (!(disabled === 2 || disabled === 1)) {
|
|
|
_context2.next = 7;
|
|
|
break;
|
|
|
}
|
|
|
onUploadAgain();
|
|
|
return _context2.abrupt("return");
|
|
|
case 7:
|
|
|
_ref4 = values || {}, _ref4$commitMessage = _ref4.commitMessage, commitMessage = _ref4$commitMessage === void 0 ? '' : _ref4$commitMessage, _ref4$fileOss = _ref4.fileOss, fileOss = _ref4$fileOss === void 0 ? [] : _ref4$fileOss;
|
|
|
filesItems = local ? fileList : fileOss;
|
|
|
names = filesItems.map(function (e) {
|
|
|
return e.name;
|
|
|
});
|
|
|
if (!(names.filter(function (item) {
|
|
|
return item.indexOf('、') != -1 || item.indexOf(' ') != -1;
|
|
|
}).length > 0)) {
|
|
|
_context2.next = 14;
|
|
|
break;
|
|
|
}
|
|
|
message/* default */.ZP.info('数据集名称禁止有空格与、');
|
|
|
setBtnLoading(false);
|
|
|
return _context2.abrupt("return");
|
|
|
case 14:
|
|
|
_context2.next = 16;
|
|
|
return (0,fetch/* default */.ZP)("/api/shixuns/".concat(id, "/check_data_sets"), {
|
|
|
method: 'post',
|
|
|
body: {
|
|
|
files_name: names
|
|
|
}
|
|
|
});
|
|
|
case 16:
|
|
|
res = _context2.sent;
|
|
|
if (!(res.status === -3)) {
|
|
|
_context2.next = 21;
|
|
|
break;
|
|
|
}
|
|
|
setRepeatedName(res === null || res === void 0 ? void 0 : res.exist_files);
|
|
|
setBtnLoading(false);
|
|
|
return _context2.abrupt("return");
|
|
|
case 21:
|
|
|
if (!(JSON.stringify(res) === '{}')) {
|
|
|
_context2.next = 25;
|
|
|
break;
|
|
|
}
|
|
|
// savedFileList.current = savedFileList.current.map((e: any) => ({...e, status: 'error'}))
|
|
|
// setBtnLoading(false);
|
|
|
// setDisabled(2)
|
|
|
// setFileList(savedFileList.current)
|
|
|
setBtnLoading(false);
|
|
|
message/* default */.ZP.error('网络已断开,请稍后重试!');
|
|
|
return _context2.abrupt("return");
|
|
|
case 25:
|
|
|
if (res.status === 0) {
|
|
|
fileList.forEach(function (item) {
|
|
|
var xhr = uploadRequest({
|
|
|
file: item.file,
|
|
|
description: commitMessage
|
|
|
}, "".concat(env/* default */.Z.API_SERVER, "/api/shixuns/").concat(id, "/upload_data_sets.json"), function (e) {
|
|
|
return callback(e, item);
|
|
|
}, function (e) {
|
|
|
return getProgress(e, item);
|
|
|
}, function (e) {
|
|
|
return error(e, item);
|
|
|
});
|
|
|
xhrItems.push(xhr);
|
|
|
});
|
|
|
setDisabled(1);
|
|
|
}
|
|
|
case 26:
|
|
|
case "end":
|
|
|
return _context2.stop();
|
|
|
}
|
|
|
}, _callee2);
|
|
|
}));
|
|
|
return function handleFinish(_x2) {
|
|
|
return _ref3.apply(this, arguments);
|
|
|
};
|
|
|
}();
|
|
|
var onUploadAgain = function onUploadAgain() {
|
|
|
var _ref5 = objectSpread2_default()({}, form.getFieldsValue()) || {},
|
|
|
_ref5$commitMessage = _ref5.commitMessage,
|
|
|
commitMessage = _ref5$commitMessage === void 0 ? '' : _ref5$commitMessage;
|
|
|
var errorFileList = savedFileList.current.filter(function (item) {
|
|
|
return item.status === 'error';
|
|
|
});
|
|
|
var t = savedFileList.current.map(function (e) {
|
|
|
return objectSpread2_default()(objectSpread2_default()({}, e), {}, {
|
|
|
status: e.status === 'error' ? 'uploading' : e.status
|
|
|
});
|
|
|
});
|
|
|
setFileList(t);
|
|
|
errorFileList.forEach(function (item) {
|
|
|
var xhr = uploadRequest({
|
|
|
file: item.file,
|
|
|
description: commitMessage
|
|
|
}, "".concat(env/* default */.Z.API_SERVER, "/api/shixuns/").concat(id, "/upload_data_sets.json"), function (e) {
|
|
|
return callback(e, item);
|
|
|
}, function (e) {
|
|
|
return getProgress(e, item);
|
|
|
}, function (e) {
|
|
|
return error(e, item);
|
|
|
});
|
|
|
xhrItems.push(xhr);
|
|
|
});
|
|
|
};
|
|
|
var handleValuesChange = function handleValuesChange(changedValues) {
|
|
|
console.log(changedValues, 'changedValues');
|
|
|
if ('fileOss' in changedValues) {
|
|
|
var _changedValues$fileOs, _changedValues$fileOs2;
|
|
|
if (changedValues !== null && changedValues !== void 0 && changedValues.fileOss.every(function (e) {
|
|
|
return e.status === 'done';
|
|
|
}) && changedValues !== null && changedValues !== void 0 && (_changedValues$fileOs = changedValues.fileOss) !== null && _changedValues$fileOs !== void 0 && _changedValues$fileOs.length) {
|
|
|
message/* default */.ZP.success('上传完成!');
|
|
|
cancelEnd(true);
|
|
|
return;
|
|
|
}
|
|
|
if (changedValues !== null && changedValues !== void 0 && changedValues.fileOss.every(function (e) {
|
|
|
return e.status === 'done' || e.status === 'error';
|
|
|
}) && changedValues !== null && changedValues !== void 0 && (_changedValues$fileOs2 = changedValues.fileOss) !== null && _changedValues$fileOs2 !== void 0 && _changedValues$fileOs2.length) {
|
|
|
setDisabled(3);
|
|
|
setBtnLoading(false);
|
|
|
return;
|
|
|
}
|
|
|
setRepeatedName(repeatedName.filter(function (item) {
|
|
|
var _changedValues$fileOs3;
|
|
|
return changedValues === null || changedValues === void 0 || (_changedValues$fileOs3 = changedValues.fileOss) === null || _changedValues$fileOs3 === void 0 ? void 0 : _changedValues$fileOs3.some(function (e) {
|
|
|
return e.name === item;
|
|
|
});
|
|
|
}));
|
|
|
}
|
|
|
setFormValue(objectSpread2_default()({}, form.getFieldsValue()));
|
|
|
};
|
|
|
var cancelEnd = function cancelEnd(bool) {
|
|
|
if (!bool) {
|
|
|
setCancelUpload(true);
|
|
|
xhrItems.forEach(function (e) {
|
|
|
e.abort();
|
|
|
});
|
|
|
}
|
|
|
onOK();
|
|
|
onClose();
|
|
|
};
|
|
|
var handleCancel = function handleCancel() {
|
|
|
var _ref6 = objectSpread2_default()({}, form.getFieldsValue()) || {},
|
|
|
_ref6$fileOss = _ref6.fileOss,
|
|
|
fileOss = _ref6$fileOss === void 0 ? [] : _ref6$fileOss;
|
|
|
var fileListItems = fileList === null || fileList === void 0 ? void 0 : fileList.every(function (e) {
|
|
|
return e.status === 'done';
|
|
|
});
|
|
|
var ossItems = fileOss === null || fileOss === void 0 ? void 0 : fileOss.every(function (e) {
|
|
|
return e.status === 'done';
|
|
|
});
|
|
|
if (!fileListItems || !ossItems) {
|
|
|
modal/* default */.Z.confirm({
|
|
|
title: "关闭弹框提示",
|
|
|
content: "有文件未上传,是否确定离开?",
|
|
|
okText: "离开",
|
|
|
cancelText: "取消",
|
|
|
onOk: function onOk() {
|
|
|
cancelEnd();
|
|
|
}
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
cancelEnd();
|
|
|
};
|
|
|
var returnDom = function returnDom() {
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(_react_17_0_2_react.Fragment, {
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
|
className: "iconfont icon-shangchuan font50 ".concat(UploadFilemodules.colorBlue)
|
|
|
})
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
className: "font14 mt30",
|
|
|
children: ["\u62D6\u62FD\u6587\u4EF6\u6216", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: "".concat(UploadFilemodules.colorBlue, " ml5"),
|
|
|
children: "\u70B9\u51FB\u6B64\u5904\u4E0A\u4F20"
|
|
|
})]
|
|
|
})]
|
|
|
});
|
|
|
};
|
|
|
var handleComplete = function handleComplete(item) {
|
|
|
console.log(item, 444);
|
|
|
};
|
|
|
|
|
|
// console.log(fileList, 4444)
|
|
|
|
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(modal/* default */.Z, {
|
|
|
open: visible
|
|
|
// wrapClassName={wrapClassName}
|
|
|
,
|
|
|
onOk: function onOk() {
|
|
|
(0,util/* trackEvent */.L9)(['实践项目', '设置', '数据集', '上传文件']);
|
|
|
form.submit();
|
|
|
},
|
|
|
centered: true,
|
|
|
okText: disabled === 0 ? '确定' : disabled === 1 ? '上传中' : '重新上传',
|
|
|
okButtonProps: {
|
|
|
loading: btnLoading
|
|
|
},
|
|
|
onCancel: handleCancel,
|
|
|
width: "1000px",
|
|
|
title: "\u4E0A\u4F20\u6587\u4EF6",
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
|
className: UploadFilemodules.wrap,
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, {
|
|
|
className: "mt10",
|
|
|
form: form,
|
|
|
scrollToFirstError: true,
|
|
|
layout: "vertical",
|
|
|
onFinish: handleFinish,
|
|
|
onValuesChange: handleValuesChange,
|
|
|
children: [local ? /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
|
label: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
children: ["\u9009\u62E9\u6587\u4EF6 ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
style: {
|
|
|
visibility: 'hidden'
|
|
|
},
|
|
|
className: "c-light-black",
|
|
|
children: "(\u5355\u4E2A\u6587\u4EF6\u4E0D\u8D85\u8FC7500M)"
|
|
|
})]
|
|
|
}),
|
|
|
name: "file",
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请选择文件'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(Dragger, objectSpread2_default()(objectSpread2_default()({}, draggerProps), {}, {
|
|
|
children: [" ", returnDom()]
|
|
|
}))
|
|
|
}) : /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
|
label: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
|
children: ["\u9009\u62E9\u6587\u4EF6 ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
|
className: "c-light-black",
|
|
|
children: "(\u5355\u4E2A\u6587\u4EF6\u4E0D\u8D85\u8FC7100GB)"
|
|
|
})]
|
|
|
}),
|
|
|
name: "fileOss",
|
|
|
rules: [{
|
|
|
required: true,
|
|
|
message: '请选择文件'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(components_UploadFile/* default */.ZP, {
|
|
|
identifier: rootIdentifier,
|
|
|
cancelUpload: cancelUpload,
|
|
|
container_type: "Shixun",
|
|
|
container_id: containerId,
|
|
|
uploading: disabled < 3 ? disabled : 0,
|
|
|
disabled: disabled > 0,
|
|
|
height: 300,
|
|
|
maxSize: 100 * 1024 * 1024 * 1024 //字节
|
|
|
,
|
|
|
description: formValue.commitMessage || "",
|
|
|
text: returnDom(),
|
|
|
onComplete: handleComplete,
|
|
|
realFileName: true
|
|
|
})
|
|
|
}), !!repeatedName.length && /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
|
className: UploadFilemodules.repeatedName,
|
|
|
children: [repeatedName.join('、'), "\u5DF2\u5B58\u5728,\u8BF7\u5220\u9664\u540E\u518D\u4E0A\u4F20"]
|
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
|
name: "commitMessage",
|
|
|
label: "\u5907\u6CE8:",
|
|
|
rules: [{
|
|
|
whitespace: true,
|
|
|
message: '请勿输入空格'
|
|
|
}],
|
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
|
|
|
bordered: false,
|
|
|
disabled: disabled > 0,
|
|
|
maxLength: 100,
|
|
|
suffix: "".concat(((_formValue$commitMess = formValue.commitMessage) === null || _formValue$commitMess === void 0 ? void 0 : _formValue$commitMess.length) || 0, "/100"),
|
|
|
placeholder: "\u8BF7\u586B\u5199\u5907\u6CE8\u4FE1\u606F"
|
|
|
})
|
|
|
})]
|
|
|
})
|
|
|
})
|
|
|
});
|
|
|
};
|
|
|
/* harmony default export */ var Dataset_components_UploadFile = (UploadFile);
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 25769:
|
|
|
/*!**************************************************************************!*\
|
|
|
!*** ./node_modules/_copy-to-clipboard@3.3.3@copy-to-clipboard/index.js ***!
|
|
|
\**************************************************************************/
|
|
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
var deselectCurrent = __webpack_require__(/*! toggle-selection */ 98040);
|
|
|
|
|
|
var clipboardToIE11Formatting = {
|
|
|
"text/plain": "Text",
|
|
|
"text/html": "Url",
|
|
|
"default": "Text"
|
|
|
}
|
|
|
|
|
|
var defaultMessage = "Copy to clipboard: #{key}, Enter";
|
|
|
|
|
|
function format(message) {
|
|
|
var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
|
|
|
return message.replace(/#{\s*key\s*}/g, copyKey);
|
|
|
}
|
|
|
|
|
|
function copy(text, options) {
|
|
|
var debug,
|
|
|
message,
|
|
|
reselectPrevious,
|
|
|
range,
|
|
|
selection,
|
|
|
mark,
|
|
|
success = false;
|
|
|
if (!options) {
|
|
|
options = {};
|
|
|
}
|
|
|
debug = options.debug || false;
|
|
|
try {
|
|
|
reselectPrevious = deselectCurrent();
|
|
|
|
|
|
range = document.createRange();
|
|
|
selection = document.getSelection();
|
|
|
|
|
|
mark = document.createElement("span");
|
|
|
mark.textContent = text;
|
|
|
// avoid screen readers from reading out loud the text
|
|
|
mark.ariaHidden = "true"
|
|
|
// reset user styles for span element
|
|
|
mark.style.all = "unset";
|
|
|
// prevents scrolling to the end of the page
|
|
|
mark.style.position = "fixed";
|
|
|
mark.style.top = 0;
|
|
|
mark.style.clip = "rect(0, 0, 0, 0)";
|
|
|
// used to preserve spaces and line breaks
|
|
|
mark.style.whiteSpace = "pre";
|
|
|
// do not inherit user-select (it may be `none`)
|
|
|
mark.style.webkitUserSelect = "text";
|
|
|
mark.style.MozUserSelect = "text";
|
|
|
mark.style.msUserSelect = "text";
|
|
|
mark.style.userSelect = "text";
|
|
|
mark.addEventListener("copy", function(e) {
|
|
|
e.stopPropagation();
|
|
|
if (options.format) {
|
|
|
e.preventDefault();
|
|
|
if (typeof e.clipboardData === "undefined") { // IE 11
|
|
|
debug && console.warn("unable to use e.clipboardData");
|
|
|
debug && console.warn("trying IE specific stuff");
|
|
|
window.clipboardData.clearData();
|
|
|
var format = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"]
|
|
|
window.clipboardData.setData(format, text);
|
|
|
} else { // all other browsers
|
|
|
e.clipboardData.clearData();
|
|
|
e.clipboardData.setData(options.format, text);
|
|
|
}
|
|
|
}
|
|
|
if (options.onCopy) {
|
|
|
e.preventDefault();
|
|
|
options.onCopy(e.clipboardData);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
document.body.appendChild(mark);
|
|
|
|
|
|
range.selectNodeContents(mark);
|
|
|
selection.addRange(range);
|
|
|
|
|
|
var successful = document.execCommand("copy");
|
|
|
if (!successful) {
|
|
|
throw new Error("copy command was unsuccessful");
|
|
|
}
|
|
|
success = true;
|
|
|
} catch (err) {
|
|
|
debug && console.error("unable to copy using execCommand: ", err);
|
|
|
debug && console.warn("trying IE specific stuff");
|
|
|
try {
|
|
|
window.clipboardData.setData(options.format || "text", text);
|
|
|
options.onCopy && options.onCopy(window.clipboardData);
|
|
|
success = true;
|
|
|
} catch (err) {
|
|
|
debug && console.error("unable to copy using clipboardData: ", err);
|
|
|
debug && console.error("falling back to prompt");
|
|
|
message = format("message" in options ? options.message : defaultMessage);
|
|
|
window.prompt(message, text);
|
|
|
}
|
|
|
} finally {
|
|
|
if (selection) {
|
|
|
if (typeof selection.removeRange == "function") {
|
|
|
selection.removeRange(range);
|
|
|
} else {
|
|
|
selection.removeAllRanges();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (mark) {
|
|
|
document.body.removeChild(mark);
|
|
|
}
|
|
|
reselectPrevious();
|
|
|
}
|
|
|
|
|
|
return success;
|
|
|
}
|
|
|
|
|
|
module.exports = copy;
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 83145:
|
|
|
/*!**********************************************************************************************!*\
|
|
|
!*** ./node_modules/_react-copy-to-clipboard@5.0.2@react-copy-to-clipboard/lib/Component.js ***!
|
|
|
\**********************************************************************************************/
|
|
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
|
value: true
|
|
|
}));
|
|
|
exports.CopyToClipboard = void 0;
|
|
|
|
|
|
var _react = _interopRequireDefault(__webpack_require__(/*! react */ 59301));
|
|
|
|
|
|
var _copyToClipboard = _interopRequireDefault(__webpack_require__(/*! copy-to-clipboard */ 25769));
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
|
|
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
|
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
|
|
|
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
|
|
|
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
|
|
|
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
|
|
var CopyToClipboard =
|
|
|
/*#__PURE__*/
|
|
|
function (_React$PureComponent) {
|
|
|
_inherits(CopyToClipboard, _React$PureComponent);
|
|
|
|
|
|
function CopyToClipboard() {
|
|
|
var _getPrototypeOf2;
|
|
|
|
|
|
var _this;
|
|
|
|
|
|
_classCallCheck(this, CopyToClipboard);
|
|
|
|
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
|
args[_key] = arguments[_key];
|
|
|
}
|
|
|
|
|
|
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(CopyToClipboard)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
|
|
|
|
|
_defineProperty(_assertThisInitialized(_this), "onClick", function (event) {
|
|
|
var _this$props = _this.props,
|
|
|
text = _this$props.text,
|
|
|
onCopy = _this$props.onCopy,
|
|
|
children = _this$props.children,
|
|
|
options = _this$props.options;
|
|
|
|
|
|
var elem = _react["default"].Children.only(children);
|
|
|
|
|
|
var result = (0, _copyToClipboard["default"])(text, options);
|
|
|
|
|
|
if (onCopy) {
|
|
|
onCopy(text, result);
|
|
|
} // Bypass onClick if it was present
|
|
|
|
|
|
|
|
|
if (elem && elem.props && typeof elem.props.onClick === 'function') {
|
|
|
elem.props.onClick(event);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return _this;
|
|
|
}
|
|
|
|
|
|
_createClass(CopyToClipboard, [{
|
|
|
key: "render",
|
|
|
value: function render() {
|
|
|
var _this$props2 = this.props,
|
|
|
_text = _this$props2.text,
|
|
|
_onCopy = _this$props2.onCopy,
|
|
|
_options = _this$props2.options,
|
|
|
children = _this$props2.children,
|
|
|
props = _objectWithoutProperties(_this$props2, ["text", "onCopy", "options", "children"]);
|
|
|
|
|
|
var elem = _react["default"].Children.only(children);
|
|
|
|
|
|
return _react["default"].cloneElement(elem, _objectSpread({}, props, {
|
|
|
onClick: this.onClick
|
|
|
}));
|
|
|
}
|
|
|
}]);
|
|
|
|
|
|
return CopyToClipboard;
|
|
|
}(_react["default"].PureComponent);
|
|
|
|
|
|
exports.CopyToClipboard = CopyToClipboard;
|
|
|
|
|
|
_defineProperty(CopyToClipboard, "defaultProps", {
|
|
|
onCopy: undefined,
|
|
|
options: undefined
|
|
|
});
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 56102:
|
|
|
/*!******************************************************************************************!*\
|
|
|
!*** ./node_modules/_react-copy-to-clipboard@5.0.2@react-copy-to-clipboard/lib/index.js ***!
|
|
|
\******************************************************************************************/
|
|
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
var _require = __webpack_require__(/*! ./Component */ 83145),
|
|
|
CopyToClipboard = _require.CopyToClipboard;
|
|
|
|
|
|
CopyToClipboard.CopyToClipboard = CopyToClipboard;
|
|
|
module.exports = CopyToClipboard;
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 98040:
|
|
|
/*!************************************************************************!*\
|
|
|
!*** ./node_modules/_toggle-selection@1.0.6@toggle-selection/index.js ***!
|
|
|
\************************************************************************/
|
|
|
/***/ (function(module) {
|
|
|
|
|
|
|
|
|
module.exports = function () {
|
|
|
var selection = document.getSelection();
|
|
|
if (!selection.rangeCount) {
|
|
|
return function () {};
|
|
|
}
|
|
|
var active = document.activeElement;
|
|
|
|
|
|
var ranges = [];
|
|
|
for (var i = 0; i < selection.rangeCount; i++) {
|
|
|
ranges.push(selection.getRangeAt(i));
|
|
|
}
|
|
|
|
|
|
switch (active.tagName.toUpperCase()) { // .toUpperCase handles XHTML
|
|
|
case 'INPUT':
|
|
|
case 'TEXTAREA':
|
|
|
active.blur();
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
active = null;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
selection.removeAllRanges();
|
|
|
return function () {
|
|
|
selection.type === 'Caret' &&
|
|
|
selection.removeAllRanges();
|
|
|
|
|
|
if (!selection.rangeCount) {
|
|
|
ranges.forEach(function(range) {
|
|
|
selection.addRange(range);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
active &&
|
|
|
active.focus();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
/***/ 3828:
|
|
|
/*!************************!*\
|
|
|
!*** crypto (ignored) ***!
|
|
|
\************************/
|
|
|
/***/ (function() {
|
|
|
|
|
|
/* (ignored) */
|
|
|
|
|
|
/***/ })
|
|
|
|
|
|
}]); |