Showing
3 changed files
with
72 additions
and
7 deletions
... | ... | @@ -89,6 +89,7 @@ import Core from '../../index'; |
89 | 89 | var confirm = _Modal.confirm; // import {useVT} from 'virtualizedtableforantd4'; |
90 | 90 | |
91 | 91 | import QxIcon from './icon'; |
92 | +import * as dd from 'dingtalk-jsapi'; | |
92 | 93 | var BUTTON_ICONS_MAP = { |
93 | 94 | PlusOutlined: /*#__PURE__*/React.createElement(_PlusOutlined, null), |
94 | 95 | MinusOutlined: /*#__PURE__*/React.createElement(_MinusOutlined, null), |
... | ... | @@ -1114,7 +1115,14 @@ function handleDownload(_x, _x2, _x3) { |
1114 | 1115 | |
1115 | 1116 | function _handleDownload() { |
1116 | 1117 | _handleDownload = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(url, name, request) { |
1118 | + var _dd$env; | |
1119 | + | |
1117 | 1120 | var isDownload, |
1121 | + isInDing, | |
1122 | + needToken, | |
1123 | + dingUrl, | |
1124 | + prev, | |
1125 | + append, | |
1118 | 1126 | link, |
1119 | 1127 | blob, |
1120 | 1128 | downloadUrl, |
... | ... | @@ -1130,18 +1138,42 @@ function _handleDownload() { |
1130 | 1138 | _message.warning('即将开始下载,请勿重复点击。'); |
1131 | 1139 | } |
1132 | 1140 | |
1141 | + isInDing = (dd === null || dd === void 0 ? void 0 : (_dd$env = dd.env) === null || _dd$env === void 0 ? void 0 : _dd$env.platform) !== 'notInDingTalk'; | |
1142 | + | |
1143 | + if (!isInDing) { | |
1144 | + _context2.next = 8; | |
1145 | + break; | |
1146 | + } | |
1147 | + | |
1148 | + // 比如导出 导入 | |
1149 | + needToken = !(url.includes('http://') || url.includes('https://')); | |
1150 | + | |
1151 | + if (needToken) { | |
1152 | + prev = "".concat(process.env.apiUrl).concat(url); | |
1153 | + append = "_token=".concat(QIXIAO_TOKEN).concat(isDesignPage() ? '&_bizCode=design' : ''); | |
1154 | + dingUrl = "".concat(prev).concat(prev.includes('?') ? '&' : '?').concat(append); // 文件服务器 不能加参数 | |
1155 | + } else { | |
1156 | + dingUrl = url; | |
1157 | + } | |
1158 | + | |
1159 | + dd.biz.util.downloadFile({ | |
1160 | + url: dingUrl | |
1161 | + }); | |
1162 | + return _context2.abrupt("return"); | |
1163 | + | |
1164 | + case 8: | |
1133 | 1165 | link = document.createElement('a'); |
1134 | 1166 | link.href = url; |
1135 | 1167 | link.download = name; |
1136 | 1168 | link.target = '_blank'; |
1137 | 1169 | document.body.appendChild(link); //TODO 文件过大时,看不到下载进度 |
1138 | 1170 | |
1139 | - _context2.next = 9; | |
1171 | + _context2.next = 15; | |
1140 | 1172 | return request.get(url, { |
1141 | 1173 | autoShowError: true |
1142 | 1174 | }); |
1143 | 1175 | |
1144 | - case 9: | |
1176 | + case 15: | |
1145 | 1177 | blob = _context2.sent; |
1146 | 1178 | |
1147 | 1179 | if (blob !== null) { |
... | ... | @@ -1152,7 +1184,7 @@ function _handleDownload() { |
1152 | 1184 | URL.revokeObjectURL(downloadUrl); |
1153 | 1185 | } |
1154 | 1186 | |
1155 | - case 11: | |
1187 | + case 17: | |
1156 | 1188 | case "end": |
1157 | 1189 | return _context2.stop(); |
1158 | 1190 | } | ... | ... |
... | ... | @@ -101,6 +101,8 @@ var _index2 = _interopRequireDefault(require("../../index")); |
101 | 101 | |
102 | 102 | var _icon = _interopRequireDefault(require("./icon")); |
103 | 103 | |
104 | +var dd = _interopRequireWildcard(require("dingtalk-jsapi")); | |
105 | + | |
104 | 106 | var _excluded = ["scrollY", "summary", "batchKey", "type", "bar", "line", "searchKey", "rowSelection", "size"]; |
105 | 107 | |
106 | 108 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } |
... | ... | @@ -1176,7 +1178,14 @@ function handleDownload(_x, _x2, _x3) { |
1176 | 1178 | |
1177 | 1179 | function _handleDownload() { |
1178 | 1180 | _handleDownload = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(url, name, request) { |
1181 | + var _dd$env; | |
1182 | + | |
1179 | 1183 | var isDownload, |
1184 | + isInDing, | |
1185 | + needToken, | |
1186 | + dingUrl, | |
1187 | + prev, | |
1188 | + append, | |
1180 | 1189 | link, |
1181 | 1190 | blob, |
1182 | 1191 | downloadUrl, |
... | ... | @@ -1192,18 +1201,42 @@ function _handleDownload() { |
1192 | 1201 | _message2.default.warning('即将开始下载,请勿重复点击。'); |
1193 | 1202 | } |
1194 | 1203 | |
1204 | + isInDing = (dd === null || dd === void 0 ? void 0 : (_dd$env = dd.env) === null || _dd$env === void 0 ? void 0 : _dd$env.platform) !== 'notInDingTalk'; | |
1205 | + | |
1206 | + if (!isInDing) { | |
1207 | + _context2.next = 8; | |
1208 | + break; | |
1209 | + } | |
1210 | + | |
1211 | + // 比如导出 导入 | |
1212 | + needToken = !(url.includes('http://') || url.includes('https://')); | |
1213 | + | |
1214 | + if (needToken) { | |
1215 | + prev = "".concat(process.env.apiUrl).concat(url); | |
1216 | + append = "_token=".concat(QIXIAO_TOKEN).concat(isDesignPage() ? '&_bizCode=design' : ''); | |
1217 | + dingUrl = "".concat(prev).concat(prev.includes('?') ? '&' : '?').concat(append); // 文件服务器 不能加参数 | |
1218 | + } else { | |
1219 | + dingUrl = url; | |
1220 | + } | |
1221 | + | |
1222 | + dd.biz.util.downloadFile({ | |
1223 | + url: dingUrl | |
1224 | + }); | |
1225 | + return _context2.abrupt("return"); | |
1226 | + | |
1227 | + case 8: | |
1195 | 1228 | link = document.createElement('a'); |
1196 | 1229 | link.href = url; |
1197 | 1230 | link.download = name; |
1198 | 1231 | link.target = '_blank'; |
1199 | 1232 | document.body.appendChild(link); //TODO 文件过大时,看不到下载进度 |
1200 | 1233 | |
1201 | - _context2.next = 9; | |
1234 | + _context2.next = 15; | |
1202 | 1235 | return request.get(url, { |
1203 | 1236 | autoShowError: true |
1204 | 1237 | }); |
1205 | 1238 | |
1206 | - case 9: | |
1239 | + case 15: | |
1207 | 1240 | blob = _context2.sent; |
1208 | 1241 | |
1209 | 1242 | if (blob !== null) { |
... | ... | @@ -1214,7 +1247,7 @@ function _handleDownload() { |
1214 | 1247 | URL.revokeObjectURL(downloadUrl); |
1215 | 1248 | } |
1216 | 1249 | |
1217 | - case 11: | |
1250 | + case 17: | |
1218 | 1251 | case "end": |
1219 | 1252 | return _context2.stop(); |
1220 | 1253 | } | ... | ... |