|
|
|
|
@ -13164,6 +13164,7 @@ var uploadOffice_excluded = ["user", "cancelUpload", "defaultFilelist", "getData
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var decrypt = function decrypt(word) {
|
|
|
|
|
var ENC_KEY = "bf3c199c2470cb477d907b1e0917c17b";
|
|
|
|
|
var IV = "5183666c72eec9e4";
|
|
|
|
|
@ -13203,16 +13204,19 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
|
|
}, [defaultFilelist]);
|
|
|
|
|
var _props = {
|
|
|
|
|
onPreview: function onPreview(e) {
|
|
|
|
|
setData(e.download_url);
|
|
|
|
|
// debugger
|
|
|
|
|
setData(e.response.url);
|
|
|
|
|
},
|
|
|
|
|
action: env/* default */.Z.API_SERVER + '/api/attachments.json',
|
|
|
|
|
onRemove: function () {
|
|
|
|
|
var _onRemove = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(e) {
|
|
|
|
|
var _e$response;
|
|
|
|
|
var res;
|
|
|
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
|
|
|
while (1) switch (_context.prev = _context.next) {
|
|
|
|
|
case 0:
|
|
|
|
|
_context.next = 2;
|
|
|
|
|
return (0,utils_fetch/* default */.ZP)("/api/tasks/".concat(props.identifier, "/destroy_attachment"), {
|
|
|
|
|
return (0,utils_fetch/* default */.ZP)("/api/attachments/".concat(e.id || (e === null || e === void 0 || (_e$response = e.response) === null || _e$response === void 0 ? void 0 : _e$response.id), ".json"), {
|
|
|
|
|
method: "delete",
|
|
|
|
|
body: {
|
|
|
|
|
id: e.id
|
|
|
|
|
@ -13238,76 +13242,51 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
|
|
}
|
|
|
|
|
return onRemove;
|
|
|
|
|
}(),
|
|
|
|
|
data: {
|
|
|
|
|
game_identifier: props.identifier
|
|
|
|
|
},
|
|
|
|
|
disabled: props.disabled,
|
|
|
|
|
onChange: function onChange(info) {
|
|
|
|
|
setFileList(info.fileList);
|
|
|
|
|
},
|
|
|
|
|
multiple: true,
|
|
|
|
|
fileList: fileList,
|
|
|
|
|
customRequest: function () {
|
|
|
|
|
var _customRequest = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2(options) {
|
|
|
|
|
var _user$userInfo, _res$data, _res$data2;
|
|
|
|
|
var res;
|
|
|
|
|
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
|
|
|
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
|
|
|
case 0:
|
|
|
|
|
_context2.next = 2;
|
|
|
|
|
return _uploadFiles(options.file, {
|
|
|
|
|
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.identifier,
|
|
|
|
|
description: props.description,
|
|
|
|
|
realFileName: props.realFileName
|
|
|
|
|
});
|
|
|
|
|
case 2:
|
|
|
|
|
res = _context2.sent;
|
|
|
|
|
options.onSuccess({
|
|
|
|
|
file: options.file,
|
|
|
|
|
uid: res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.attachment_id,
|
|
|
|
|
id: res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.attachment_id
|
|
|
|
|
});
|
|
|
|
|
case 4:
|
|
|
|
|
case "end":
|
|
|
|
|
return _context2.stop();
|
|
|
|
|
}
|
|
|
|
|
}, _callee2);
|
|
|
|
|
}));
|
|
|
|
|
function customRequest(_x2) {
|
|
|
|
|
return _customRequest.apply(this, arguments);
|
|
|
|
|
}
|
|
|
|
|
return customRequest;
|
|
|
|
|
}(),
|
|
|
|
|
beforeUpload: function () {
|
|
|
|
|
var _beforeUpload = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(file) {
|
|
|
|
|
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
|
|
|
|
|
while (1) switch (_context3.prev = _context3.next) {
|
|
|
|
|
case 0:
|
|
|
|
|
case "end":
|
|
|
|
|
return _context3.stop();
|
|
|
|
|
}
|
|
|
|
|
}, _callee3);
|
|
|
|
|
}));
|
|
|
|
|
function beforeUpload(_x3) {
|
|
|
|
|
return _beforeUpload.apply(this, arguments);
|
|
|
|
|
}
|
|
|
|
|
return beforeUpload;
|
|
|
|
|
}()
|
|
|
|
|
fileList: fileList
|
|
|
|
|
// customRequest: async (options: any) => {
|
|
|
|
|
// const res: any = await _uploadFiles(options.file, {
|
|
|
|
|
// login: user?.userInfo?.login,
|
|
|
|
|
// container_type: props.container_type,
|
|
|
|
|
// container_id: props.identifier,
|
|
|
|
|
// description: props.description,
|
|
|
|
|
// realFileName: props.realFileName
|
|
|
|
|
// })
|
|
|
|
|
// options.onSuccess({
|
|
|
|
|
// file: options.file,
|
|
|
|
|
// uid: res?.data?.attachment_id,
|
|
|
|
|
// id: res?.data?.attachment_id,
|
|
|
|
|
// })
|
|
|
|
|
// },
|
|
|
|
|
// beforeUpload: async (file: any) => {
|
|
|
|
|
// }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var _uploadFiles = /*#__PURE__*/function () {
|
|
|
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4(file, obj) {
|
|
|
|
|
var _res$data3, _res$data4, _res$data5, _res$data6, _res$data7, _res$data8;
|
|
|
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2(file, obj) {
|
|
|
|
|
var _res$data, _res$data2, _res$data3, _res$data4, _res$data5, _res$data6;
|
|
|
|
|
var name, res, namearrs, filename;
|
|
|
|
|
return regeneratorRuntime_default()().wrap(function _callee4$(_context4) {
|
|
|
|
|
while (1) switch (_context4.prev = _context4.next) {
|
|
|
|
|
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
|
|
|
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
|
|
|
case 0:
|
|
|
|
|
obj.file_name = file.name;
|
|
|
|
|
name = file.name;
|
|
|
|
|
_context4.next = 4;
|
|
|
|
|
_context2.next = 4;
|
|
|
|
|
return (0,utils_fetch/* default */.ZP)('/api/buckets/get_upload_token_for_file.json', {
|
|
|
|
|
method: "get"
|
|
|
|
|
});
|
|
|
|
|
case 4:
|
|
|
|
|
res = _context4.sent;
|
|
|
|
|
res = _context2.sent;
|
|
|
|
|
res.data = JSON.parse(decrypt(res.data));
|
|
|
|
|
if (!((res === null || res === void 0 ? void 0 : res.status) !== 0)) {
|
|
|
|
|
_context4.next = 12;
|
|
|
|
|
_context2.next = 12;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
fileList[fileList.findIndex(function (item) {
|
|
|
|
|
@ -13318,15 +13297,15 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
|
|
})]['file']['status'] = 'error';
|
|
|
|
|
props.onChange(fileList);
|
|
|
|
|
message/* default */.ZP.warning("上传失败,请重新尝试");
|
|
|
|
|
return _context4.abrupt("return");
|
|
|
|
|
return _context2.abrupt("return");
|
|
|
|
|
case 12:
|
|
|
|
|
client = new (aliyun_oss_sdk_default())({
|
|
|
|
|
endpoint: res === null || res === void 0 || (_res$data3 = res.data) === null || _res$data3 === void 0 ? void 0 : _res$data3.end_point,
|
|
|
|
|
region: res === null || res === void 0 || (_res$data4 = res.data) === null || _res$data4 === void 0 ? void 0 : _res$data4.region,
|
|
|
|
|
accessKeyId: res === null || res === void 0 || (_res$data5 = res.data) === null || _res$data5 === void 0 ? void 0 : _res$data5.access_key_id,
|
|
|
|
|
accessKeySecret: res === null || res === void 0 || (_res$data6 = res.data) === null || _res$data6 === void 0 ? void 0 : _res$data6.access_key_secret,
|
|
|
|
|
bucket: res === null || res === void 0 || (_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.bucket,
|
|
|
|
|
stsToken: res === null || res === void 0 || (_res$data8 = res.data) === null || _res$data8 === void 0 ? void 0 : _res$data8.security_token
|
|
|
|
|
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
|
|
|
|
|
});
|
|
|
|
|
console.log('files:', file, res);
|
|
|
|
|
setClient(client);
|
|
|
|
|
@ -13335,8 +13314,8 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
|
|
namearrs.pop();
|
|
|
|
|
filename = obj.realFileName ? namearrs : (0,v4/* default */.Z)();
|
|
|
|
|
console.log("obj1111:", obj);
|
|
|
|
|
return _context4.abrupt("return", new Promise(function (resolve, reject) {
|
|
|
|
|
var _res$data9;
|
|
|
|
|
return _context2.abrupt("return", new Promise(function (resolve, reject) {
|
|
|
|
|
var _res$data7;
|
|
|
|
|
// try {
|
|
|
|
|
client.multipartUpload("".concat(props.identifier, "/").concat(filename.join("")).concat(name.indexOf(".") > -1 ? '.' + name.split(".").pop() : ""), new Blob([file], {
|
|
|
|
|
type: file.type
|
|
|
|
|
@ -13364,7 +13343,7 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
|
|
customValue: {
|
|
|
|
|
id: name + ''
|
|
|
|
|
},
|
|
|
|
|
url: res === null || res === void 0 || (_res$data9 = res.data) === null || _res$data9 === void 0 ? void 0 : _res$data9.callback_url,
|
|
|
|
|
url: res === null || res === void 0 || (_res$data7 = res.data) === null || _res$data7 === void 0 ? void 0 : _res$data7.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/* parseParams */.rz)(obj)
|
|
|
|
|
}
|
|
|
|
|
@ -13387,11 +13366,11 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
|
|
}));
|
|
|
|
|
case 20:
|
|
|
|
|
case "end":
|
|
|
|
|
return _context4.stop();
|
|
|
|
|
return _context2.stop();
|
|
|
|
|
}
|
|
|
|
|
}, _callee4);
|
|
|
|
|
}, _callee2);
|
|
|
|
|
}));
|
|
|
|
|
return function _uploadFiles(_x4, _x5) {
|
|
|
|
|
return function _uploadFiles(_x2, _x3) {
|
|
|
|
|
return _ref2.apply(this, arguments);
|
|
|
|
|
};
|
|
|
|
|
}();
|
|
|
|
|
@ -13410,47 +13389,47 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
|
|
}
|
|
|
|
|
}, [cancelUpload]);
|
|
|
|
|
var toUpload = /*#__PURE__*/function () {
|
|
|
|
|
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee6() {
|
|
|
|
|
return regeneratorRuntime_default()().wrap(function _callee6$(_context6) {
|
|
|
|
|
while (1) switch (_context6.prev = _context6.next) {
|
|
|
|
|
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee4() {
|
|
|
|
|
return regeneratorRuntime_default()().wrap(function _callee4$(_context4) {
|
|
|
|
|
while (1) switch (_context4.prev = _context4.next) {
|
|
|
|
|
case 0:
|
|
|
|
|
fileList.map( /*#__PURE__*/function () {
|
|
|
|
|
var _ref4 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee5(item) {
|
|
|
|
|
var _user$userInfo2, res;
|
|
|
|
|
return regeneratorRuntime_default()().wrap(function _callee5$(_context5) {
|
|
|
|
|
while (1) switch (_context5.prev = _context5.next) {
|
|
|
|
|
var _ref4 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
|
|
|
|
|
var _user$userInfo, res;
|
|
|
|
|
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
|
|
|
|
|
while (1) switch (_context3.prev = _context3.next) {
|
|
|
|
|
case 0:
|
|
|
|
|
if (!((!item.status || item.status === 'error') && !cancelUpload)) {
|
|
|
|
|
_context5.next = 6;
|
|
|
|
|
_context3.next = 6;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
item.status = 'uploading';
|
|
|
|
|
item.file.status = 'uploading';
|
|
|
|
|
_context5.next = 5;
|
|
|
|
|
_context3.next = 5;
|
|
|
|
|
return _uploadFiles(item, {
|
|
|
|
|
login: user === null || user === void 0 || (_user$userInfo2 = user.userInfo) === null || _user$userInfo2 === void 0 ? void 0 : _user$userInfo2.login,
|
|
|
|
|
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.identifier,
|
|
|
|
|
description: props.description,
|
|
|
|
|
realFileName: props.realFileName
|
|
|
|
|
});
|
|
|
|
|
case 5:
|
|
|
|
|
res = _context5.sent;
|
|
|
|
|
res = _context3.sent;
|
|
|
|
|
case 6:
|
|
|
|
|
case "end":
|
|
|
|
|
return _context5.stop();
|
|
|
|
|
return _context3.stop();
|
|
|
|
|
}
|
|
|
|
|
}, _callee5);
|
|
|
|
|
}, _callee3);
|
|
|
|
|
}));
|
|
|
|
|
return function (_x6) {
|
|
|
|
|
return function (_x4) {
|
|
|
|
|
return _ref4.apply(this, arguments);
|
|
|
|
|
};
|
|
|
|
|
}());
|
|
|
|
|
case 1:
|
|
|
|
|
case "end":
|
|
|
|
|
return _context6.stop();
|
|
|
|
|
return _context4.stop();
|
|
|
|
|
}
|
|
|
|
|
}, _callee6);
|
|
|
|
|
}, _callee4);
|
|
|
|
|
}));
|
|
|
|
|
return function toUpload() {
|
|
|
|
|
return _ref3.apply(this, arguments);
|
|
|
|
|
@ -13460,7 +13439,7 @@ var UploadFile = function UploadFile(_ref) {
|
|
|
|
|
className: OfficeUploadmodules.files,
|
|
|
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(PreviewAll/* default */.Z, {
|
|
|
|
|
close: true,
|
|
|
|
|
data: encodeURIComponent(data),
|
|
|
|
|
data: data,
|
|
|
|
|
type: !!(data !== null && data !== void 0 && data.length) ? "office" : "",
|
|
|
|
|
onClose: function onClose() {
|
|
|
|
|
return setData("");
|
|
|
|
|
|