Showing
3 changed files
with
72 additions
and
7 deletions
@@ -89,6 +89,7 @@ import Core from '../../index'; | @@ -89,6 +89,7 @@ import Core from '../../index'; | ||
89 | var confirm = _Modal.confirm; // import {useVT} from 'virtualizedtableforantd4'; | 89 | var confirm = _Modal.confirm; // import {useVT} from 'virtualizedtableforantd4'; |
90 | 90 | ||
91 | import QxIcon from './icon'; | 91 | import QxIcon from './icon'; |
92 | +import * as dd from 'dingtalk-jsapi'; | ||
92 | var BUTTON_ICONS_MAP = { | 93 | var BUTTON_ICONS_MAP = { |
93 | PlusOutlined: /*#__PURE__*/React.createElement(_PlusOutlined, null), | 94 | PlusOutlined: /*#__PURE__*/React.createElement(_PlusOutlined, null), |
94 | MinusOutlined: /*#__PURE__*/React.createElement(_MinusOutlined, null), | 95 | MinusOutlined: /*#__PURE__*/React.createElement(_MinusOutlined, null), |
@@ -1114,7 +1115,14 @@ function handleDownload(_x, _x2, _x3) { | @@ -1114,7 +1115,14 @@ function handleDownload(_x, _x2, _x3) { | ||
1114 | 1115 | ||
1115 | function _handleDownload() { | 1116 | function _handleDownload() { |
1116 | _handleDownload = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(url, name, request) { | 1117 | _handleDownload = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(url, name, request) { |
1118 | + var _dd$env; | ||
1119 | + | ||
1117 | var isDownload, | 1120 | var isDownload, |
1121 | + isInDing, | ||
1122 | + needToken, | ||
1123 | + dingUrl, | ||
1124 | + prev, | ||
1125 | + append, | ||
1118 | link, | 1126 | link, |
1119 | blob, | 1127 | blob, |
1120 | downloadUrl, | 1128 | downloadUrl, |
@@ -1130,18 +1138,42 @@ function _handleDownload() { | @@ -1130,18 +1138,42 @@ function _handleDownload() { | ||
1130 | _message.warning('即将开始下载,请勿重复点击。'); | 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 | link = document.createElement('a'); | 1165 | link = document.createElement('a'); |
1134 | link.href = url; | 1166 | link.href = url; |
1135 | link.download = name; | 1167 | link.download = name; |
1136 | link.target = '_blank'; | 1168 | link.target = '_blank'; |
1137 | document.body.appendChild(link); //TODO 文件过大时,看不到下载进度 | 1169 | document.body.appendChild(link); //TODO 文件过大时,看不到下载进度 |
1138 | 1170 | ||
1139 | - _context2.next = 9; | 1171 | + _context2.next = 15; |
1140 | return request.get(url, { | 1172 | return request.get(url, { |
1141 | autoShowError: true | 1173 | autoShowError: true |
1142 | }); | 1174 | }); |
1143 | 1175 | ||
1144 | - case 9: | 1176 | + case 15: |
1145 | blob = _context2.sent; | 1177 | blob = _context2.sent; |
1146 | 1178 | ||
1147 | if (blob !== null) { | 1179 | if (blob !== null) { |
@@ -1152,7 +1184,7 @@ function _handleDownload() { | @@ -1152,7 +1184,7 @@ function _handleDownload() { | ||
1152 | URL.revokeObjectURL(downloadUrl); | 1184 | URL.revokeObjectURL(downloadUrl); |
1153 | } | 1185 | } |
1154 | 1186 | ||
1155 | - case 11: | 1187 | + case 17: |
1156 | case "end": | 1188 | case "end": |
1157 | return _context2.stop(); | 1189 | return _context2.stop(); |
1158 | } | 1190 | } |
@@ -101,6 +101,8 @@ var _index2 = _interopRequireDefault(require("../../index")); | @@ -101,6 +101,8 @@ var _index2 = _interopRequireDefault(require("../../index")); | ||
101 | 101 | ||
102 | var _icon = _interopRequireDefault(require("./icon")); | 102 | var _icon = _interopRequireDefault(require("./icon")); |
103 | 103 | ||
104 | +var dd = _interopRequireWildcard(require("dingtalk-jsapi")); | ||
105 | + | ||
104 | var _excluded = ["scrollY", "summary", "batchKey", "type", "bar", "line", "searchKey", "rowSelection", "size"]; | 106 | var _excluded = ["scrollY", "summary", "batchKey", "type", "bar", "line", "searchKey", "rowSelection", "size"]; |
105 | 107 | ||
106 | 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); } | 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,7 +1178,14 @@ function handleDownload(_x, _x2, _x3) { | ||
1176 | 1178 | ||
1177 | function _handleDownload() { | 1179 | function _handleDownload() { |
1178 | _handleDownload = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(url, name, request) { | 1180 | _handleDownload = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(url, name, request) { |
1181 | + var _dd$env; | ||
1182 | + | ||
1179 | var isDownload, | 1183 | var isDownload, |
1184 | + isInDing, | ||
1185 | + needToken, | ||
1186 | + dingUrl, | ||
1187 | + prev, | ||
1188 | + append, | ||
1180 | link, | 1189 | link, |
1181 | blob, | 1190 | blob, |
1182 | downloadUrl, | 1191 | downloadUrl, |
@@ -1192,18 +1201,42 @@ function _handleDownload() { | @@ -1192,18 +1201,42 @@ function _handleDownload() { | ||
1192 | _message2.default.warning('即将开始下载,请勿重复点击。'); | 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 | link = document.createElement('a'); | 1228 | link = document.createElement('a'); |
1196 | link.href = url; | 1229 | link.href = url; |
1197 | link.download = name; | 1230 | link.download = name; |
1198 | link.target = '_blank'; | 1231 | link.target = '_blank'; |
1199 | document.body.appendChild(link); //TODO 文件过大时,看不到下载进度 | 1232 | document.body.appendChild(link); //TODO 文件过大时,看不到下载进度 |
1200 | 1233 | ||
1201 | - _context2.next = 9; | 1234 | + _context2.next = 15; |
1202 | return request.get(url, { | 1235 | return request.get(url, { |
1203 | autoShowError: true | 1236 | autoShowError: true |
1204 | }); | 1237 | }); |
1205 | 1238 | ||
1206 | - case 9: | 1239 | + case 15: |
1207 | blob = _context2.sent; | 1240 | blob = _context2.sent; |
1208 | 1241 | ||
1209 | if (blob !== null) { | 1242 | if (blob !== null) { |
@@ -1214,7 +1247,7 @@ function _handleDownload() { | @@ -1214,7 +1247,7 @@ function _handleDownload() { | ||
1214 | URL.revokeObjectURL(downloadUrl); | 1247 | URL.revokeObjectURL(downloadUrl); |
1215 | } | 1248 | } |
1216 | 1249 | ||
1217 | - case 11: | 1250 | + case 17: |
1218 | case "end": | 1251 | case "end": |
1219 | return _context2.stop(); | 1252 | return _context2.stop(); |
1220 | } | 1253 | } |
1 | { | 1 | { |
2 | "name": "@qx/form-render", | 2 | "name": "@qx/form-render", |
3 | - "version": "0.1.3", | 3 | + "version": "0.1.4", |
4 | "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成", | 4 | "description": "通过 JSON Schema 生成标准 Form,常用于自定义搭建配置界面生成", |
5 | "repository": { | 5 | "repository": { |
6 | "type": "git", | 6 | "type": "git", |