@bytenew/bn-applet-ui 1.1.68 → 1.1.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bn-applet-ui.umd.js
CHANGED
|
@@ -12027,6 +12027,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
12027
12027
|
insertText: () => (/* reexport */ insertText),
|
|
12028
12028
|
mainAppRouterPush: () => (/* reexport */ mainAppRouterPush),
|
|
12029
12029
|
recordApiLog: () => (/* reexport */ recordApiLog),
|
|
12030
|
+
rewriteAttachmentUrls: () => (/* reexport */ rewriteAttachmentUrls),
|
|
12030
12031
|
searchValueToJson: () => (/* reexport */ searchValueToJson),
|
|
12031
12032
|
tidyComponents: () => (/* reexport */ tidyComponents),
|
|
12032
12033
|
tidyJumpSearchData: () => (/* reexport */ tidyJumpSearchData),
|
|
@@ -29675,6 +29676,51 @@ function addressParse(address, sourceData) {
|
|
|
29675
29676
|
var cleanAddress = preprocessAddress(address);
|
|
29676
29677
|
return parseAddressDetail(cleanAddress, sourceData || {}, address);
|
|
29677
29678
|
}
|
|
29679
|
+
;// ../../packages/utils/rewriteAttachmentUrl.js
|
|
29680
|
+
|
|
29681
|
+
|
|
29682
|
+
|
|
29683
|
+
|
|
29684
|
+
|
|
29685
|
+
|
|
29686
|
+
|
|
29687
|
+
|
|
29688
|
+
|
|
29689
|
+
|
|
29690
|
+
|
|
29691
|
+
|
|
29692
|
+
// 匹配任意域名的 stream 绝对地址, 捕获组1 = 去域名后的路径
|
|
29693
|
+
var STREAM_URL_RE = /https?:\/\/[^/"']+?(\/v2\/attachment\/stream\/[A-Za-z0-9._-]+)/g;
|
|
29694
|
+
|
|
29695
|
+
/**
|
|
29696
|
+
* 开发环境: 把接口数据中的附件流式地址改写为本地代理路径
|
|
29697
|
+
* 生产环境: 原样返回
|
|
29698
|
+
*/
|
|
29699
|
+
var DEV_PROXY_PREFIX = '/proxyWay';
|
|
29700
|
+
function rewriteStreamUrls(data) {
|
|
29701
|
+
if (data == null) return data;
|
|
29702
|
+
// 全文序列化替换: 附件 url 可能散落在任意层级的字段里, 逐字段遍历不可靠, 全文替换最稳
|
|
29703
|
+
var raw = typeof data === 'string' ? data : JSON.stringify(data);
|
|
29704
|
+
var rewritten = raw.replace(STREAM_URL_RE, "".concat(DEV_PROXY_PREFIX, "$1"));
|
|
29705
|
+
return typeof data === 'string' ? rewritten : JSON.parse(rewritten);
|
|
29706
|
+
}
|
|
29707
|
+
var warned = false;
|
|
29708
|
+
|
|
29709
|
+
/**
|
|
29710
|
+
* 把接口数据中的附件流式地址改写为本地代理路径
|
|
29711
|
+
* @param {*} data 接口数据, 支持字符串或对象, 返回同类型结果
|
|
29712
|
+
* @param {String} env 当前环境, 由调用方传入 process.env?.NODE_ENV, 不传则不启用改写
|
|
29713
|
+
*/
|
|
29714
|
+
function rewriteAttachmentUrls(data, env) {
|
|
29715
|
+
if (env !== 'development') {
|
|
29716
|
+
if (!warned && env === undefined) {
|
|
29717
|
+
warned = true;
|
|
29718
|
+
console.warn('[bn] rewriteAttachmentUrls 未传入环境参数, 不会启用附件地址改写');
|
|
29719
|
+
}
|
|
29720
|
+
return data;
|
|
29721
|
+
}
|
|
29722
|
+
return rewriteStreamUrls(data);
|
|
29723
|
+
}
|
|
29678
29724
|
;// ../../packages/utils/index.js
|
|
29679
29725
|
|
|
29680
29726
|
|
|
@@ -31493,6 +31539,11 @@ var bnTableWrapBind = {
|
|
|
31493
31539
|
* 地址自动识别
|
|
31494
31540
|
* */
|
|
31495
31541
|
|
|
31542
|
+
|
|
31543
|
+
/**
|
|
31544
|
+
* 附件流式地址改写(仅开发环境生效)
|
|
31545
|
+
* */
|
|
31546
|
+
|
|
31496
31547
|
;// ./install.js
|
|
31497
31548
|
// install.js - BnAppletUi 组件库入口
|
|
31498
31549
|
|
|
@@ -31556,6 +31607,7 @@ const BnAppletUi = {
|
|
|
31556
31607
|
addressParse: addressParse,
|
|
31557
31608
|
bnTableBind: bnTableBind,
|
|
31558
31609
|
bnTableWrapBind: bnTableWrapBind,
|
|
31610
|
+
rewriteAttachmentUrls: rewriteAttachmentUrls,
|
|
31559
31611
|
};
|
|
31560
31612
|
|
|
31561
31613
|
// 支持通过 CDN 方式引入时自动注册
|