@glodon-aiot/chat-app-sdk 0.0.1-alpha.14 → 0.0.1-alpha.15

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/es/index.esm.js CHANGED
@@ -120734,23 +120734,23 @@ const eventMeta = {
120734
120734
  is_release: false,
120735
120735
  dev: false
120736
120736
  };
120737
- // 新增:根据优先级获取最终的 API 地址
120737
+ var chat_ApiUrl = /*#__PURE__*/ function(ApiUrl) {
120738
+ ApiUrl["dev"] = "https://aiot-dev.glodon.com/api/cvforcepd/flow";
120739
+ ApiUrl["test"] = "https://aiot-dev.glodon.com/api/cvforce/flow";
120740
+ ApiUrl["prod"] = "https://copilot.glodon.com/api/cvforce/flow";
120741
+ ApiUrl["local"] = "http://localhost:8082/api/cvforcepd/flow";
120742
+ return ApiUrl;
120743
+ }({});
120744
+ // 修改:根据优先级获取最终的 API 地址
120738
120745
  /**
120739
120746
  * 获取最终使用的 API 地址
120740
120747
  * @param customApiUrl - 用户自定义的 API 地址(最高优先级)
120741
- * @returns 优先级:customApiUrl > 动态生成 > defaultApiUrl
120748
+ * @param env - 环境类型,默认 'prod'
120749
+ * @returns 优先级:显式 apiUrl > ApiUrl[env] > defaultApiUrl
120742
120750
  */ const defaultApiUrl = 'https://copilot.glodon.com/api/cvforce/flow';
120743
- const getApiUrl = (customApiUrl)=>{
120744
- // 优先级 1: 用户传入的自定义 API 地址
120745
- if (customApiUrl) {
120746
- return customApiUrl;
120747
- }
120748
- // 优先级 2: 动态生成(基于 location.origin)
120749
- if (typeof location !== 'undefined') {
120750
- return location.origin + genBaseURL();
120751
- }
120752
- // 优先级 3: 默认 API 地址
120753
- return defaultApiUrl;
120751
+ const getApiUrl = function(customApiUrl) {
120752
+ let env = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'prod';
120753
+ return customApiUrl || chat_ApiUrl[env] || defaultApiUrl;
120754
120754
  };
120755
120755
 
120756
120756
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/zustand@4.5.7_@types+react@18.2.37_immer@10.1.3_react@18.2.0/node_modules/zustand/esm/middleware.mjs
@@ -432876,7 +432876,14 @@ const use_core_manager_useCoreManager = (props)=>{
432876
432876
  refProps.current = props;
432877
432877
  refAppData.current = appData;
432878
432878
  // 计算最终的 API URL
432879
- const finalApiUrl = (0,react.useMemo)(()=>getApiUrl(props.apiUrl), [
432879
+ const finalApiUrl = (0,react.useMemo)(()=>{
432880
+ // 如果 props.apiUrl 有值,直接使用(从 SDK 传入的已计算好的 URL)
432881
+ if (props.apiUrl) {
432882
+ return props.apiUrl;
432883
+ }
432884
+ // 如果没有值,使用默认计算(fallback 到 prod)
432885
+ return getApiUrl();
432886
+ }, [
432880
432887
  props.apiUrl
432881
432888
  ]);
432882
432889
  return (0,react.useMemo)(()=>({
@@ -434246,7 +434253,7 @@ class WebChatClient {
434246
434253
  WebChatClient.clients = WebChatClient.clients.filter((c)=>c !== this);
434247
434254
  }
434248
434255
  constructor(options){
434249
- var _this_options_config;
434256
+ var _this_options_config, _this_options_config1;
434250
434257
  client_define_property(this, "root", void 0);
434251
434258
  client_define_property(this, "defaultRoot", void 0);
434252
434259
  client_define_property(this, "containerEl", void 0); // 新增:保存容器元素
@@ -434262,8 +434269,9 @@ class WebChatClient {
434262
434269
  this.options = client_formatOptions(options);
434263
434270
  this.authClient = new AuthClient(options);
434264
434271
  // 计算最终使用的 API 地址
434265
- this.apiUrl = getApiUrl((_this_options_config = this.options.config) === null || _this_options_config === void 0 ? void 0 : _this_options_config.apiUrl);
434266
- console.info('WebChatClient using API URL:', this.apiUrl);
434272
+ const env = (_this_options_config = this.options.config) === null || _this_options_config === void 0 ? void 0 : _this_options_config.env;
434273
+ this.apiUrl = getApiUrl((_this_options_config1 = this.options.config) === null || _this_options_config1 === void 0 ? void 0 : _this_options_config1.apiUrl, env);
434274
+ console.info('WebChatClient using API URL:', this.apiUrl, env);
434267
434275
  // 👇 新增:处理 getContainer
434268
434276
  const { getContainer, mode = 'float' } = this.options;
434269
434277
  if (getContainer) {