@bytenew/bn-applet-ui 1.1.75 → 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.
|
@@ -29985,13 +29985,16 @@ function findParsedRegionConflict(parse, originalAddress) {
|
|
|
29985
29985
|
|
|
29986
29986
|
/**
|
|
29987
29987
|
* 本地识别错误时,使用原生 fetch 调用大模型接口重新识别
|
|
29988
|
-
*
|
|
29988
|
+
* options.platform == 'plugin'(插件端):POST /project/column/addressBychat,请求体 {content: 待识别文本}
|
|
29989
|
+
* 其他端:GET /v2/project/column/addressBychat?contents={待识别文本}
|
|
29989
29990
|
* 接口返回 data.content 为大模型识别结果的 JSON 字符串(name/mobile/tel/province/city/area/street/addr)
|
|
29990
29991
|
* @param {string} address 原始地址字符串
|
|
29992
|
+
* @param {object} [options] 可选配置,platform === 'plugin' 表示插件端
|
|
29991
29993
|
* @returns {Promise<{aiResult?: object, failMsg?: string}|null>}
|
|
29992
29994
|
* 成功返回 {aiResult}(content 解析后的对象);失败返回 {failMsg}(接口 msg);不支持 fetch 返回 null
|
|
29993
29995
|
*/
|
|
29994
29996
|
function parseAddressByChat(address) {
|
|
29997
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
29995
29998
|
// 小程序等不支持 fetch 的环境直接跳过,保留本地识别结果
|
|
29996
29999
|
if (typeof fetch !== 'function') {
|
|
29997
30000
|
console.warn('当前环境不支持 fetch,无法调用大模型地址识别接口');
|
|
@@ -30005,10 +30008,21 @@ function parseAddressByChat(address) {
|
|
|
30005
30008
|
var isLocal = hostname === 'localhost' || hostname === '127.0.0.1' || hostname === '0.0.0.0' || hostname === '[::1]';
|
|
30006
30009
|
baseUrl = isLocal ? '/proxyWay' : '';
|
|
30007
30010
|
}
|
|
30008
|
-
|
|
30009
|
-
|
|
30011
|
+
// 插件端走单独接口:POST /project/column/addressBychat;其他端走 v2 的 GET 接口
|
|
30012
|
+
var isPlugin = options.platform === 'plugin';
|
|
30013
|
+
var url = baseUrl + (isPlugin ? '/project/column/addressBychat' : '/v2/project/column/addressBychat?contents=' + encodeURIComponent(address));
|
|
30014
|
+
var fetchOptions = isPlugin ? {
|
|
30015
|
+
method: 'POST',
|
|
30016
|
+
headers: {
|
|
30017
|
+
'Content-Type': 'application/json'
|
|
30018
|
+
},
|
|
30019
|
+
body: JSON.stringify({
|
|
30020
|
+
content: address
|
|
30021
|
+
})
|
|
30022
|
+
} : {
|
|
30010
30023
|
method: 'GET'
|
|
30011
|
-
}
|
|
30024
|
+
};
|
|
30025
|
+
return fetch(url, fetchOptions).then(function (r) {
|
|
30012
30026
|
return r.json();
|
|
30013
30027
|
}).then(function (res) {
|
|
30014
30028
|
if (res && !res.code && res.data && res.data.content) {
|
|
@@ -30075,7 +30089,7 @@ function _addressParse() {
|
|
|
30075
30089
|
break;
|
|
30076
30090
|
}
|
|
30077
30091
|
_context.n = 1;
|
|
30078
|
-
return parseAddressByChat(address);
|
|
30092
|
+
return parseAddressByChat(address, options);
|
|
30079
30093
|
case 1:
|
|
30080
30094
|
chatResult = _context.v;
|
|
30081
30095
|
if (chatResult && chatResult.aiResult) {
|