@bytenew/bn-applet-ui 1.1.78 → 1.1.80

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.
@@ -28761,6 +28761,7 @@ var es_array_sort = __webpack_require__(6910);
28761
28761
 
28762
28762
 
28763
28763
 
28764
+
28764
28765
 
28765
28766
 
28766
28767
  var defaultData = []; //不包括省市级code的数据
@@ -30015,68 +30016,112 @@ function shouldFallbackToAIWhenEmpty(parse, originalAddress) {
30015
30016
  }
30016
30017
 
30017
30018
  /**
30018
- * 本地识别错误时,使用原生 fetch 调用大模型接口重新识别
30019
- * options.platform == 'plugin'(插件端):POST /project/column/addressBychat,请求体 {content: 待识别文本}
30020
- * 其他端:GET /v2/project/column/addressBychat?contents={待识别文本}
30021
- * 接口返回 data.content 为大模型识别结果的 JSON 字符串(name/mobile/tel/province/city/area/street/addr)
30022
- * @param {string} address 原始地址字符串
30023
- * @param {object} [options] 可选配置,platform === 'plugin' 表示插件端
30019
+ * 解析大模型识别接口的响应体
30020
+ * @param {object} res 接口响应体
30021
+ * @returns {{aiResult?: object, failMsg?: string}}
30022
+ */
30023
+ function parseChatResponse(res) {
30024
+ // 兼容调用方 post 直接返回 axios 完整响应对象({status, data})的情况
30025
+ if (res && typeof res.status === 'number' && res.data && _typeof(res.data) === 'object') {
30026
+ res = res.data;
30027
+ }
30028
+ if (res && !res.code && res.data && res.data.content) {
30029
+ try {
30030
+ return {
30031
+ aiResult: JSON.parse(res.data.content)
30032
+ };
30033
+ } catch (e) {
30034
+ console.error('大模型识别结果解析失败:', res.data.content);
30035
+ return {
30036
+ failMsg: '识别结果解析失败'
30037
+ };
30038
+ }
30039
+ }
30040
+ // 接口失败(如未开通 address_aIautorecognition 功能):返回接口 msg
30041
+ return {
30042
+ failMsg: res ? res.msg : '请求失败'
30043
+ };
30044
+ }
30045
+
30046
+ /**
30047
+ * 接口异常统一处理
30048
+ * @param {Error} error 异常对象
30049
+ * @returns {{failMsg: string}}
30050
+ */
30051
+ function handleChatError(error) {
30052
+ console.error('大模型地址识别接口调用失败:', error);
30053
+ return {
30054
+ failMsg: error && error.message ? error.message : '请求异常'
30055
+ };
30056
+ }
30057
+
30058
+ /**
30059
+ * 开发环境(localhost/127.0.0.1 等)返回 devServer 代理前缀 /proxyWay,线上同域部署返回空串
30060
+ * @returns {string}
30061
+ */
30062
+ function getDevProxyPrefix() {
30063
+ if (typeof window === 'undefined' || !window.location) {
30064
+ return '';
30065
+ }
30066
+ var hostname = window.location.hostname;
30067
+ var isLocal = hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '0.0.0.0' || hostname === '[::1]';
30068
+ return isLocal ? '/proxyWay' : '';
30069
+ }
30070
+
30071
+ /**
30072
+ * 原生 fetch 请求地址识别接口(调用方未注入 post 时的兜底)
30073
+ * @param {string} url 完整请求地址
30074
+ * @param {object} fetchOptions fetch 参数
30024
30075
  * @returns {Promise<{aiResult?: object, failMsg?: string}|null>}
30025
- * 成功返回 {aiResult}(content 解析后的对象);失败返回 {failMsg}(接口 msg);不支持 fetch 返回 null
30026
30076
  */
30027
- function parseAddressByChat(address) {
30028
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30077
+ function requestChat(url, fetchOptions) {
30029
30078
  // 小程序等不支持 fetch 的环境直接跳过,保留本地识别结果
30030
30079
  if (typeof fetch !== 'function') {
30031
30080
  console.warn('当前环境不支持 fetch,无法调用大模型地址识别接口');
30032
30081
  return Promise.resolve(null);
30033
30082
  }
30034
- // 本地开发环境(localhost/127.0.0.1 等)请求前加代理前缀 /proxyWay,走前端 devServer 代理转发;
30035
- // 非本地环境(线上同域部署)不加前缀
30036
- var baseUrl = '';
30037
- if (typeof window !== 'undefined' && window.location) {
30038
- var hostname = window.location.hostname;
30039
- var isLocal = hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '0.0.0.0' || hostname === '[::1]';
30040
- baseUrl = isLocal ? '/proxyWay' : '';
30041
- }
30042
- // 插件端走单独接口:POST /project/column/addressBychat;其他端走 v2 的 GET 接口
30043
- var isPlugin = options.platform === 'plugin';
30044
- var url = baseUrl + (isPlugin ? '/gateway/project/column/addressBychat' : '/v2/project/column/addressBychat?contents=' + encodeURIComponent(address));
30045
- var fetchOptions = isPlugin ? {
30046
- method: 'POST',
30047
- headers: {
30048
- 'Content-Type': 'application/json'
30049
- },
30050
- body: JSON.stringify({
30051
- content: address
30052
- })
30053
- } : {
30054
- method: 'GET'
30055
- };
30056
30083
  return fetch(url, fetchOptions).then(function (r) {
30057
30084
  return r.json();
30058
- }).then(function (res) {
30059
- if (res && !res.code && res.data && res.data.content) {
30060
- try {
30061
- return {
30062
- aiResult: JSON.parse(res.data.content)
30063
- };
30064
- } catch (e) {
30065
- console.error('大模型识别结果解析失败:', res.data.content);
30066
- return {
30067
- failMsg: '识别结果解析失败'
30068
- };
30069
- }
30085
+ }).then(parseChatResponse)["catch"](handleChatError);
30086
+ }
30087
+
30088
+ /**
30089
+ * 本地识别错误时,调用大模型接口重新识别
30090
+ * 插件端(options.platform === 'plugin'):POST /project/column/addressBychat,请求体 {content: 待识别文本};
30091
+ * 传了 options.post 时由宿主 axios 拼前缀、带鉴权头,未传时直连 /gateway 兜底
30092
+ * 其他端:GET /v2/project/column/addressBychat?contents={待识别文本}
30093
+ * 接口返回 data.content 为大模型识别结果的 JSON 字符串(name/mobile/tel/province/city/area/street/addr)
30094
+ * @param {string} address 原始地址字符串
30095
+ * @param {object} [options] 可选配置,platform === 'plugin' 表示插件端;
30096
+ * post 为调用方传入的 post 方法 (path, data) => Promise<响应体>,接口前缀与 plugin-token 等鉴权头由宿主项目的 axios 统一处理
30097
+ * @returns {Promise<{aiResult?: object, failMsg?: string}|null>}
30098
+ */
30099
+ function parseAddressByChat(address) {
30100
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30101
+ // 插件端走单独接口:POST /project/column/addressBychat
30102
+ if (options.platform === 'plugin') {
30103
+ // 优先使用调用方传入的 post(一般是项目 axios 封装),避免组件库内直接 fetch 拼错前缀、缺少鉴权头导致 404
30104
+ if (typeof options.post === 'function') {
30105
+ return Promise.resolve().then(function () {
30106
+ return options.post('/project/column/addressBychat', {
30107
+ content: address
30108
+ });
30109
+ }).then(parseChatResponse)["catch"](handleChatError);
30070
30110
  }
30071
- // 接口失败(如未开通 address_aIautorecognition 功能):返回接口 msg
30072
- return {
30073
- failMsg: res ? res.msg : '请求失败'
30074
- };
30075
- })["catch"](function (error) {
30076
- console.error('大模型地址识别接口调用失败:', error);
30077
- return {
30078
- failMsg: error && error.message ? error.message : '请求异常'
30079
- };
30111
+ // 兜底:直连插件网关
30112
+ return requestChat(getDevProxyPrefix() + '/gateway/project/column/addressBychat', {
30113
+ method: 'POST',
30114
+ headers: {
30115
+ 'Content-Type': 'application/json'
30116
+ },
30117
+ body: JSON.stringify({
30118
+ content: address
30119
+ })
30120
+ });
30121
+ }
30122
+ // 其他端:v2 的 GET 接口
30123
+ return requestChat(getDevProxyPrefix() + '/v2/project/column/addressBychat?contents=' + encodeURIComponent(address), {
30124
+ method: 'GET'
30080
30125
  });
30081
30126
  }
30082
30127
 
@@ -31442,6 +31487,8 @@ function formatComponent(component, power, platformType) {
31442
31487
  behaviorType: component.behaviorType,
31443
31488
  defaultInfo: component.defaultInfo,
31444
31489
  columnCode: component.columnCode,
31490
+ // 组件语义标识(如 order / waybillNo),与数据键 columnCode 不同
31491
+ key: component.key,
31445
31492
  name: component.name,
31446
31493
  extraInfo: component.extraInfo || {},
31447
31494
  style: component.style || {},
@@ -31626,6 +31673,8 @@ function formatColumnVal(component, values, power, platformType) {
31626
31673
  type: component.type,
31627
31674
  behaviorType: component.behaviorType,
31628
31675
  columnCode: component.columnCode,
31676
+ // 组件语义标识(如 order / waybillNo),与数据键 columnCode 不同
31677
+ key: component.key,
31629
31678
  defaultInfo: component.defaultInfo,
31630
31679
  name: component.name,
31631
31680
  extraInfo: component.extraInfo || {},