@bytenew/bn-applet-ui 1.1.81 → 1.1.82

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.
@@ -30053,17 +30053,9 @@ function getDevProxyPrefix() {
30053
30053
  * @param {object} fetchOptions fetch 参数
30054
30054
  * @returns {Promise<{aiResult?: object, failMsg?: string}|null>}
30055
30055
  */
30056
- function requestChat(url, fetchOptions) {
30057
- // 小程序等不支持 fetch 的环境直接跳过,保留本地识别结果
30058
- if (typeof fetch !== 'function') {
30059
- console.warn('当前环境不支持 fetch,无法调用大模型地址识别接口');
30060
- return Promise.resolve(null);
30061
- }
30062
- return fetch(url, fetchOptions).then(function (r) {
30063
- return r.json();
30064
- }).then(parseChatResponse)["catch"](handleChatError);
30056
+ function requestChat(_x, _x2) {
30057
+ return _requestChat.apply(this, arguments);
30065
30058
  }
30066
-
30067
30059
  /**
30068
30060
  * 本地识别错误时,调用大模型接口重新识别
30069
30061
  * 插件端(options.platform === 'plugin'):POST /project/column/addressBychat,请求体 {content: 待识别文本};
@@ -30075,35 +30067,32 @@ function requestChat(url, fetchOptions) {
30075
30067
  * post 为调用方传入的 post 方法 (path, data) => Promise<响应体>,接口前缀与 plugin-token 等鉴权头由宿主项目的 axios 统一处理
30076
30068
  * @returns {Promise<{aiResult?: object, failMsg?: string}|null>}
30077
30069
  */
30078
- function parseAddressByChat(address) {
30079
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30080
- // 插件端走单独接口:POST /project/column/addressBychat
30081
- if (options.platform === 'plugin') {
30082
- // 优先使用调用方传入的 post(一般是项目 axios 封装),避免组件库内直接 fetch 拼错前缀、缺少鉴权头导致 404
30083
- if (typeof options.post === 'function') {
30084
- return Promise.resolve().then(function () {
30085
- return options.post('/project/column/addressBychat', {
30086
- content: address
30087
- });
30088
- }).then(parseChatResponse)["catch"](handleChatError);
30089
- }
30090
- // 兜底:直连插件网关
30091
- return requestChat(getDevProxyPrefix() + '/gateway/project/column/addressBychat', {
30092
- method: 'POST',
30093
- headers: {
30094
- 'Content-Type': 'application/json'
30095
- },
30096
- body: JSON.stringify({
30097
- content: address
30098
- })
30099
- });
30100
- }
30101
- // 其他端:v2 的 GET 接口
30102
- return requestChat(getDevProxyPrefix() + '/v2/project/column/addressBychat?contents=' + encodeURIComponent(address), {
30103
- method: 'GET'
30104
- });
30070
+ function _requestChat() {
30071
+ _requestChat = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(url, fetchOptions) {
30072
+ return _regenerator().w(function (_context) {
30073
+ while (1) switch (_context.n) {
30074
+ case 0:
30075
+ if (!(typeof fetch !== 'function')) {
30076
+ _context.n = 1;
30077
+ break;
30078
+ }
30079
+ console.warn('当前环境不支持 fetch,无法调用大模型地址识别接口');
30080
+ return _context.a(2, Promise.resolve(null));
30081
+ case 1:
30082
+ _context.n = 2;
30083
+ return fetch(url, fetchOptions).then(function (r) {
30084
+ return r.json();
30085
+ }).then(parseChatResponse)["catch"](handleChatError);
30086
+ case 2:
30087
+ return _context.a(2, _context.v);
30088
+ }
30089
+ }, _callee);
30090
+ }));
30091
+ return _requestChat.apply(this, arguments);
30092
+ }
30093
+ function parseAddressByChat(_x3) {
30094
+ return _parseAddressByChat.apply(this, arguments);
30105
30095
  }
30106
-
30107
30096
  /**
30108
30097
  * 自动识别地址信息,格式化为省市区街道和收件人等信息
30109
30098
  * @param {string} address 原始地址字符串(可含空格、姓名、手机号等)
@@ -30115,11 +30104,57 @@ function parseAddressByChat(address) {
30115
30104
  * AI 识别成功则用其结果覆盖省市区等字段,msg 为「自动识别错误,已使用ai重新识别」;
30116
30105
  * AI 识别失败则保留原识别内容,msg 为「自动识别错误,ai识别结果+接口msg」
30117
30106
  */
30118
- function addressParse(_x, _x2) {
30107
+ function _parseAddressByChat() {
30108
+ _parseAddressByChat = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(address) {
30109
+ var options,
30110
+ _args2 = arguments;
30111
+ return _regenerator().w(function (_context2) {
30112
+ while (1) switch (_context2.n) {
30113
+ case 0:
30114
+ options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
30115
+ if (!(options.platform === 'plugin')) {
30116
+ _context2.n = 3;
30117
+ break;
30118
+ }
30119
+ if (!(typeof options.post === 'function')) {
30120
+ _context2.n = 1;
30121
+ break;
30122
+ }
30123
+ return _context2.a(2, Promise.resolve().then(function () {
30124
+ return options.post('/project/column/addressBychat', {
30125
+ content: address
30126
+ });
30127
+ }).then(parseChatResponse)["catch"](handleChatError));
30128
+ case 1:
30129
+ _context2.n = 2;
30130
+ return requestChat(getDevProxyPrefix() + '/gateway/project/column/addressBychat', {
30131
+ method: 'POST',
30132
+ headers: {
30133
+ 'Content-Type': 'application/json'
30134
+ },
30135
+ body: JSON.stringify({
30136
+ content: address
30137
+ })
30138
+ });
30139
+ case 2:
30140
+ return _context2.a(2, _context2.v);
30141
+ case 3:
30142
+ _context2.n = 4;
30143
+ return requestChat(getDevProxyPrefix() + '/v2/project/column/addressBychat?contents=' + encodeURIComponent(address), {
30144
+ method: 'GET'
30145
+ });
30146
+ case 4:
30147
+ return _context2.a(2, _context2.v);
30148
+ }
30149
+ }, _callee2);
30150
+ }));
30151
+ return _parseAddressByChat.apply(this, arguments);
30152
+ }
30153
+ function addressParse(_x4, _x5) {
30119
30154
  return _addressParse.apply(this, arguments);
30120
30155
  }
30121
30156
  function _addressParse() {
30122
- _addressParse = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(address, sourceData) {
30157
+ _addressParse = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(address, sourceData) {
30123
30158
  var options,
30124
30159
  list,
30125
30160
  cleanAddress,
@@ -30127,11 +30162,11 @@ function _addressParse() {
30127
30162
  conflictLevel,
30128
30163
  chatResult,
30129
30164
  aiResult,
30130
- _args = arguments;
30131
- return _regenerator().w(function (_context) {
30132
- while (1) switch (_context.n) {
30165
+ _args3 = arguments;
30166
+ return _regenerator().w(function (_context3) {
30167
+ while (1) switch (_context3.n) {
30133
30168
  case 0:
30134
- options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
30169
+ options = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {};
30135
30170
  list = getGlobalAreaList(options);
30136
30171
  if (list) {
30137
30172
  parseArea(list);
@@ -30141,13 +30176,13 @@ function _addressParse() {
30141
30176
  // 省市区识别全为空但输入中出现省市区等行政区划文字时,同样调用大模型接口重新识别
30142
30177
  conflictLevel = findParsedRegionConflict(parse, address);
30143
30178
  if (!(conflictLevel || shouldFallbackToAIWhenEmpty(parse, address))) {
30144
- _context.n = 2;
30179
+ _context3.n = 2;
30145
30180
  break;
30146
30181
  }
30147
- _context.n = 1;
30182
+ _context3.n = 1;
30148
30183
  return parseAddressByChat(address, options);
30149
30184
  case 1:
30150
- chatResult = _context.v;
30185
+ chatResult = _context3.v;
30151
30186
  console.log("33333333");
30152
30187
  console.log(chatResult);
30153
30188
  if (chatResult && chatResult.aiResult) {
@@ -30167,9 +30202,9 @@ function _addressParse() {
30167
30202
  parse.msg = '自动识别错误,ai识别结果' + chatResult.failMsg;
30168
30203
  }
30169
30204
  case 2:
30170
- return _context.a(2, parse);
30205
+ return _context3.a(2, parse);
30171
30206
  }
30172
- }, _callee);
30207
+ }, _callee3);
30173
30208
  }));
30174
30209
  return _addressParse.apply(this, arguments);
30175
30210
  }