@bytenew/bn-applet-ui 1.1.74 → 1.1.76

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.
@@ -30003,13 +30003,16 @@ function findParsedRegionConflict(parse, originalAddress) {
30003
30003
 
30004
30004
  /**
30005
30005
  * 本地识别错误时,使用原生 fetch 调用大模型接口重新识别
30006
- * GET /v2/project/column/addressBychat?contents={待识别文本}
30006
+ * options.platform == 'plugin'(插件端):POST /project/column/addressBychat,请求体 {content: 待识别文本}
30007
+ * 其他端:GET /v2/project/column/addressBychat?contents={待识别文本}
30007
30008
  * 接口返回 data.content 为大模型识别结果的 JSON 字符串(name/mobile/tel/province/city/area/street/addr)
30008
30009
  * @param {string} address 原始地址字符串
30010
+ * @param {object} [options] 可选配置,platform === 'plugin' 表示插件端
30009
30011
  * @returns {Promise<{aiResult?: object, failMsg?: string}|null>}
30010
30012
  * 成功返回 {aiResult}(content 解析后的对象);失败返回 {failMsg}(接口 msg);不支持 fetch 返回 null
30011
30013
  */
30012
30014
  function parseAddressByChat(address) {
30015
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30013
30016
  // 小程序等不支持 fetch 的环境直接跳过,保留本地识别结果
30014
30017
  if (typeof fetch !== 'function') {
30015
30018
  console.warn('当前环境不支持 fetch,无法调用大模型地址识别接口');
@@ -30023,10 +30026,21 @@ function parseAddressByChat(address) {
30023
30026
  var isLocal = hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '0.0.0.0' || hostname === '[::1]';
30024
30027
  baseUrl = isLocal ? '/proxyWay' : '';
30025
30028
  }
30026
- var url = baseUrl + '/v2/project/column/addressBychat?contents=' + encodeURIComponent(address);
30027
- return fetch(url, {
30029
+ // 插件端走单独接口:POST /project/column/addressBychat;其他端走 v2 的 GET 接口
30030
+ var isPlugin = options.platform === 'plugin';
30031
+ var url = baseUrl + (isPlugin ? '/project/column/addressBychat' : '/v2/project/column/addressBychat?contents=' + encodeURIComponent(address));
30032
+ var fetchOptions = isPlugin ? {
30033
+ method: 'POST',
30034
+ headers: {
30035
+ 'Content-Type': 'application/json'
30036
+ },
30037
+ body: JSON.stringify({
30038
+ content: address
30039
+ })
30040
+ } : {
30028
30041
  method: 'GET'
30029
- }).then(function (r) {
30042
+ };
30043
+ return fetch(url, fetchOptions).then(function (r) {
30030
30044
  return r.json();
30031
30045
  }).then(function (res) {
30032
30046
  if (res && !res.code && res.data && res.data.content) {
@@ -30092,10 +30106,8 @@ function _addressParse() {
30092
30106
  _context.n = 2;
30093
30107
  break;
30094
30108
  }
30095
- // 先设置本地识别错误提示,AI 识别成功/失败后覆盖为对应提示
30096
- parse.msg = '自动识别识别错误:识别出的' + conflictLevel + '与输入地址不一致,请检查或手动填写';
30097
30109
  _context.n = 1;
30098
- return parseAddressByChat(address);
30110
+ return parseAddressByChat(address, options);
30099
30111
  case 1:
30100
30112
  chatResult = _context.v;
30101
30113
  if (chatResult && chatResult.aiResult) {
@@ -30109,7 +30121,7 @@ function _addressParse() {
30109
30121
  parse.street = aiResult.street || '';
30110
30122
  parse.addr = aiResult.addr || '';
30111
30123
  parse.Abnormal = false;
30112
- parse.msg = '自动识别错误,已使用ai重新识别';
30124
+ parse.msg = aiResult.msg || '';
30113
30125
  } else if (chatResult && chatResult.failMsg) {
30114
30126
  // AI 识别失败:还用原来的识别内容,把接口返回的 msg 提示上来
30115
30127
  parse.msg = '自动识别错误,ai识别结果' + chatResult.failMsg;