@gis_victory/ai-chat 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -5,7 +5,7 @@ Vue 3 AI 聊天面板组件,支持流式对话、历史记录管理、多技
5
5
  ## 安装
6
6
 
7
7
  ```bash
8
- npm install gis-victory-ai-chat
8
+ npm install @gis_victory/ai-chat
9
9
  npm install tdesign-vue-next @tdesign-vue-next/chat
10
10
  ```
11
11
 
@@ -19,6 +19,7 @@ npm install tdesign-vue-next @tdesign-vue-next/chat
19
19
  v-model:open="isOpen"
20
20
  mode="popup"
21
21
  :skills="skills"
22
+ :base-url="baseURL"
22
23
  :on-send="handleSend"
23
24
  />
24
25
  </template>
@@ -41,6 +42,8 @@ const skills = ref([
41
42
  { id: 'image', label: '图像生成', icon: '🎨' }
42
43
  ])
43
44
 
45
+ const baseURL = 'https://api.example.com/AiServer/Chat'
46
+
44
47
  const handleSend = async (message, skill, conversationId) => {
45
48
  // 调用你的 AI 接口
46
49
  const response = await fetch('your-api-endpoint', {
@@ -104,7 +107,7 @@ const handleSend = async (message, skill, conversationId) => {
104
107
  | `persistent` | `boolean` | `true` | 是否持久化对话记录到 localStorage |
105
108
  | `storageKey` | `string` | `'ai-chat-panel'` | localStorage 存储键 |
106
109
  | `maxHistory` | `number` | `50` | 最大历史对话数量 |
107
- | `baseURL` | `string` | - | API 基础 URL |
110
+ | `baseURL` | `string` | - | **必需** - API 基础 URL(如 `https://api.example.com/AiServer/Chat`) |
108
111
  | `token` | `string` | - | 认证 token |
109
112
  | `appId` | `string` | - | 应用 ID |
110
113
 
@@ -85,7 +85,8 @@
85
85
  display: flex;
86
86
  flex-direction: column;
87
87
  transform-origin: bottom right;
88
- height: 80vh; /* 固定高度,避免内容撑开 */
88
+ height: 60vh;
89
+ /* 固定高度,避免内容撑开 */
89
90
  scrollbar-width: none;
90
91
  -ms-overflow-style: none;
91
92
  }
@@ -367,9 +368,11 @@
367
368
  justify-content: center;
368
369
  padding: 40px 20px;
369
370
  text-align: center;
370
- flex: 1; /* 占满剩余空间,在固定高度弹窗中居中 */
371
+ flex: 1;
372
+ /* 占满剩余空间,在固定高度弹窗中居中 */
371
373
  width: 100%;
372
- min-height: 0; /* 允许在固定高度下收缩 */
374
+ min-height: 0;
375
+ /* 允许在固定高度下收缩 */
373
376
  }
374
377
  .empty-icon {
375
378
  width: 56px;
@@ -18153,22 +18153,6 @@ async function generateWord(data) {
18153
18153
  console.log("[WordGenerator] Done! Blob size:", blob.size, "bytes");
18154
18154
  return blob;
18155
18155
  }
18156
- const Server_BaseUrl = "https://www.gisx.work/gismap-server";
18157
- const __vite_import_meta_env__ = {};
18158
- const getApiBase = () => {
18159
- var _a;
18160
- if (typeof window !== "undefined" && ((_a = window.GisVictoryAiChart) == null ? void 0 : _a.apiBase)) {
18161
- return window.GisVictoryAiChart.apiBase;
18162
- }
18163
- if (__vite_import_meta_env__ == null ? void 0 : __vite_import_meta_env__.VITE_API_BASE) {
18164
- return void 0;
18165
- }
18166
- return `${Server_BaseUrl}/AiServer/Chat`;
18167
- };
18168
- const apiConfig = {
18169
- /** Chat API 基础路径(不含具体子路径) */
18170
- apiBase: getApiBase()
18171
- };
18172
18156
  const _hoisted_1 = {
18173
18157
  key: 0,
18174
18158
  class: "fab-icon",
@@ -18302,12 +18286,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
18302
18286
  onLoadHistory: {},
18303
18287
  defaultSkill: {},
18304
18288
  baseURL: {},
18289
+ baseUrl: {},
18305
18290
  token: {},
18306
18291
  appId: {}
18307
18292
  },
18308
18293
  emits: ["open", "close", "update:open", "send", "new-chat", "clear-history", "skill-change"],
18309
18294
  setup(__props, { emit: __emit }) {
18310
18295
  const props = __props;
18296
+ const effectiveBaseURL = computed(() => {
18297
+ return `${props.baseURL || props.baseUrl}/AiServer/Chat`;
18298
+ });
18311
18299
  const emit = __emit;
18312
18300
  const chatRef = ref();
18313
18301
  const queryText = ref("");
@@ -18551,9 +18539,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
18551
18539
  abortController = new AbortController();
18552
18540
  let baseURL = "";
18553
18541
  if (currentSkill.value === "enterprise_profile") {
18554
- baseURL = apiConfig.apiBase + "/NoStream";
18542
+ baseURL = effectiveBaseURL.value + "/NoStream";
18555
18543
  } else {
18556
- baseURL = props.baseURL || apiConfig.apiBase + "/Sse";
18544
+ baseURL = effectiveBaseURL.value + "/Sse";
18557
18545
  }
18558
18546
  if (!baseURL) {
18559
18547
  loadingMsg.content = "未配置 API 地址,请设置 baseURL 参数";
@@ -18770,7 +18758,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
18770
18758
  conv.messages.push(loadingMsg);
18771
18759
  conv.updatedAt = Date.now();
18772
18760
  abortController = new AbortController();
18773
- const baseURL = apiConfig.apiBase + "/NoStream";
18761
+ const baseURL = effectiveBaseURL.value + "/NoStream";
18774
18762
  const headers = { "Content-Type": "application/json" };
18775
18763
  const token = props.token;
18776
18764
  if (token) headers["Authorization"] = token;
@@ -18913,7 +18901,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
18913
18901
  async function callDeleteChatLogs(sessionIds) {
18914
18902
  if (sessionIds.length === 0) return;
18915
18903
  try {
18916
- const base = props.baseURL || apiConfig.apiBase + "/Sse";
18904
+ const base = effectiveBaseURL.value + "/Sse";
18917
18905
  const idx = base.lastIndexOf("/");
18918
18906
  const deleteUrl = base.substring(0, idx) + "/deleteChatLogs";
18919
18907
  const headers = { "Content-Type": "application/json" };
@@ -18965,7 +18953,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
18965
18953
  return `${date.getMonth() + 1}月${date.getDate()}日 ${hh}:${mm}`;
18966
18954
  }
18967
18955
  function getChatApiBase() {
18968
- const baseURL = apiConfig.apiBase + "/Sse";
18956
+ const baseURL = effectiveBaseURL.value + "/Sse";
18969
18957
  return baseURL.substring(0, baseURL.lastIndexOf("/"));
18970
18958
  }
18971
18959
  async function fetchChatLogs(sessionId) {
@@ -59,8 +59,10 @@ export interface AiChatPanelProps {
59
59
  /** API base URL */
60
60
  /** Default selected skill id; first skill is used if not specified */
61
61
  defaultSkill?: SkillId;
62
- /** API base URL */
62
+ /** API base URL (支持 baseUrl 和 baseURL 两种写法) */
63
63
  baseURL?: string;
64
+ /** API base URL (别名,支持小写写法) */
65
+ baseUrl?: string;
64
66
  /** Auth token */
65
67
  token?: string;
66
68
  /** Application ID */
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@gis_victory/ai-chat",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "AI Chat Panel component for Vue 3",
5
5
  "type": "module",
6
- "main": "./dist/gis-victory-ai-chat.mjs",
7
- "module": "./dist/gis-victory-ai-chat.mjs",
6
+ "main": "./dist/ai-chat.mjs",
7
+ "module": "./dist/ai-chat.mjs",
8
8
  "types": "./dist/index.d.ts",
9
9
  "private": false,
10
10
  "exports": {
11
11
  ".": {
12
- "import": "./dist/gis-victory-ai-chat.mjs",
12
+ "import": "./dist/ai-chat.mjs",
13
13
  "types": "./dist/index.d.ts"
14
14
  },
15
- "./style.css": "./dist/gis-victory-ai-chat.css"
15
+ "./style.css": "./dist/ai-chat.css"
16
16
  },
17
17
  "files": [
18
18
  "dist",