@glodon-aiot/chat-app-sdk 0.0.12 → 0.0.13
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 +777 -113
- package/libs/cn/index.js +35 -16
- package/package.json +1 -1
package/es/index.esm.js
CHANGED
|
@@ -9304,6 +9304,12 @@ ___CSS_LOADER_EXPORT___.push([module.id, `:root {
|
|
|
9304
9304
|
.coze-chat-sdk :is(.font-normal) {
|
|
9305
9305
|
font-weight: 400;
|
|
9306
9306
|
}
|
|
9307
|
+
.coze-chat-sdk :is(.uppercase) {
|
|
9308
|
+
text-transform: uppercase;
|
|
9309
|
+
}
|
|
9310
|
+
.coze-chat-sdk :is(.lowercase) {
|
|
9311
|
+
text-transform: lowercase;
|
|
9312
|
+
}
|
|
9307
9313
|
.coze-chat-sdk :is(.\\!leading-28px) {
|
|
9308
9314
|
line-height: var(--coze-28) !important;
|
|
9309
9315
|
}
|
|
@@ -10788,6 +10794,16 @@ ___CSS_LOADER_EXPORT___.push([module.id, `.c8c142b9ad89b1ac {
|
|
|
10788
10794
|
margin-left: auto;
|
|
10789
10795
|
color: #6B6B75;
|
|
10790
10796
|
}
|
|
10797
|
+
.c8c142b9ad89b1ac .fc5357218ceb1c78:hover {
|
|
10798
|
+
background-color: transparent !important;
|
|
10799
|
+
}
|
|
10800
|
+
.c8c142b9ad89b1ac .f07e95aab0abcc5a {
|
|
10801
|
+
margin-left: auto;
|
|
10802
|
+
color: #6B6B75;
|
|
10803
|
+
}
|
|
10804
|
+
.c8c142b9ad89b1ac .f07e95aab0abcc5a:hover {
|
|
10805
|
+
background-color: transparent !important;
|
|
10806
|
+
}
|
|
10791
10807
|
.a513b83ef65c6e47 .ae3efd63d21216ca {
|
|
10792
10808
|
opacity: 0.4;
|
|
10793
10809
|
}
|
|
@@ -10824,6 +10840,8 @@ ___CSS_LOADER_EXPORT___.locals = {
|
|
|
10824
10840
|
"fileText": `d8de5ac7f79d78ac`,
|
|
10825
10841
|
"retry-button": `fc5357218ceb1c78`,
|
|
10826
10842
|
"retryButton": `fc5357218ceb1c78`,
|
|
10843
|
+
"preview-button": `f07e95aab0abcc5a`,
|
|
10844
|
+
"previewButton": `f07e95aab0abcc5a`,
|
|
10827
10845
|
"normal-file-not-success": `a513b83ef65c6e47`,
|
|
10828
10846
|
"normalFileNotSuccess": `a513b83ef65c6e47`,
|
|
10829
10847
|
"file-error-text": `b91da080705f8042`,
|
|
@@ -12911,6 +12929,9 @@ var ___CSS_LOADER_EXPORT___ = _common_temp_default_node_modules_pnpm_css_loader_
|
|
|
12911
12929
|
___CSS_LOADER_EXPORT___.push([module.id, `.chat-uikit-file-card-progress-animation {
|
|
12912
12930
|
transition: width 0.3s linear;
|
|
12913
12931
|
}
|
|
12932
|
+
.chat-uikit-file-card__preview-button:hover {
|
|
12933
|
+
background: transparent !important;
|
|
12934
|
+
}
|
|
12914
12935
|
`, ""]);
|
|
12915
12936
|
// Exports
|
|
12916
12937
|
/* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
|
|
@@ -267629,10 +267650,11 @@ class PreSendLocalMessageFactory {
|
|
|
267629
267650
|
/**
|
|
267630
267651
|
* Update image message content
|
|
267631
267652
|
*/ updateImageMessageContent(message, uploadResult) {
|
|
267632
|
-
const { Uri = '', Url = '', ImageWidth = 0, ImageHeight = 0 } = uploadResult;
|
|
267653
|
+
const { Uri = '', Url = '', ImageWidth = 0, ImageHeight = 0, Id } = uploadResult;
|
|
267633
267654
|
message.content_obj.image_list[0] = {
|
|
267634
267655
|
...message.content_obj.image_list[0],
|
|
267635
267656
|
key: Uri,
|
|
267657
|
+
id: Id,
|
|
267636
267658
|
image_thumb: {
|
|
267637
267659
|
...message.content_obj.image_list[0].image_thumb,
|
|
267638
267660
|
width: ImageWidth,
|
|
@@ -267651,8 +267673,9 @@ class PreSendLocalMessageFactory {
|
|
|
267651
267673
|
/**
|
|
267652
267674
|
* Update file message content
|
|
267653
267675
|
*/ updateFileMessageContent(message, uploadResult) {
|
|
267654
|
-
const { Uri = '', Url = '' } = uploadResult;
|
|
267655
|
-
message.content_obj.file_list[0].file_key = Uri;
|
|
267676
|
+
const { Uri = '', Url = '', Id } = uploadResult;
|
|
267677
|
+
message.content_obj.file_list[0].file_key = Uri; // URI for URL generation/viewing
|
|
267678
|
+
message.content_obj.file_list[0].file_id = Id; // Backend file ID for file_id in API calls
|
|
267656
267679
|
message.content_obj.file_list[0].file_url = Url;
|
|
267657
267680
|
message.content = JSON.stringify(message.content_obj);
|
|
267658
267681
|
}
|
|
@@ -267700,6 +267723,7 @@ class PreSendLocalMessageFactory {
|
|
|
267700
267723
|
type,
|
|
267701
267724
|
file: {
|
|
267702
267725
|
file_key: item.uri,
|
|
267726
|
+
file_id: item.id,
|
|
267703
267727
|
file_name: item.file.name,
|
|
267704
267728
|
file_type: fileType,
|
|
267705
267729
|
file_size: item.file.size,
|
|
@@ -267713,6 +267737,7 @@ class PreSendLocalMessageFactory {
|
|
|
267713
267737
|
type,
|
|
267714
267738
|
image: {
|
|
267715
267739
|
key: item.uri,
|
|
267740
|
+
id: item.id,
|
|
267716
267741
|
image_thumb: {
|
|
267717
267742
|
url: blobUrl,
|
|
267718
267743
|
width: item.width,
|
|
@@ -271591,6 +271616,7 @@ class ChatCoreUploadPlugin {
|
|
|
271591
271616
|
}
|
|
271592
271617
|
});
|
|
271593
271618
|
this.dataAuth = dataAuth.data || {};
|
|
271619
|
+
// DataAuth structure may vary, using any for flexibility
|
|
271594
271620
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
271595
271621
|
const { service_id, upload_host, schema } = this.dataAuth || {};
|
|
271596
271622
|
this.uploader = getUploader({
|
|
@@ -271608,6 +271634,29 @@ class ChatCoreUploadPlugin {
|
|
|
271608
271634
|
}, false);
|
|
271609
271635
|
this.addFile(this.uploaderConfig.file, this.uploaderConfig.type);
|
|
271610
271636
|
this.uploader.on('complete', (info)=>{
|
|
271637
|
+
const extendedInfo = info;
|
|
271638
|
+
// Try to extract raw backend data from info object
|
|
271639
|
+
let backendData = null;
|
|
271640
|
+
if (extendedInfo.task) {
|
|
271641
|
+
var _extendedInfo_task_response, _extendedInfo_task_responseData, _extendedInfo_task__response, _extendedInfo_task_rawResponse;
|
|
271642
|
+
backendData = ((_extendedInfo_task_response = extendedInfo.task.response) === null || _extendedInfo_task_response === void 0 ? void 0 : _extendedInfo_task_response.data) || ((_extendedInfo_task_responseData = extendedInfo.task.responseData) === null || _extendedInfo_task_responseData === void 0 ? void 0 : _extendedInfo_task_responseData.data) || ((_extendedInfo_task__response = extendedInfo.task._response) === null || _extendedInfo_task__response === void 0 ? void 0 : _extendedInfo_task__response.data) || ((_extendedInfo_task_rawResponse = extendedInfo.task.rawResponse) === null || _extendedInfo_task_rawResponse === void 0 ? void 0 : _extendedInfo_task_rawResponse.data) || extendedInfo.task.data || null;
|
|
271643
|
+
}
|
|
271644
|
+
if (!backendData) {
|
|
271645
|
+
var _extendedInfo_response, _extendedInfo_result;
|
|
271646
|
+
backendData = extendedInfo.data || ((_extendedInfo_response = extendedInfo.response) === null || _extendedInfo_response === void 0 ? void 0 : _extendedInfo_response.data) || extendedInfo.responseData || ((_extendedInfo_result = extendedInfo.result) === null || _extendedInfo_result === void 0 ? void 0 : _extendedInfo_result.data) || null;
|
|
271647
|
+
}
|
|
271648
|
+
// If we found raw backend data, add uri and id to uploadResult
|
|
271649
|
+
if (backendData && extendedInfo.uploadResult) {
|
|
271650
|
+
if (backendData.uri) {
|
|
271651
|
+
extendedInfo.uploadResult.Uri = backendData.uri;
|
|
271652
|
+
}
|
|
271653
|
+
if (backendData.id) {
|
|
271654
|
+
extendedInfo.uploadResult.Id = backendData.id;
|
|
271655
|
+
}
|
|
271656
|
+
if (backendData.url) {
|
|
271657
|
+
extendedInfo.uploadResult.Url = backendData.url;
|
|
271658
|
+
}
|
|
271659
|
+
}
|
|
271611
271660
|
this.eventBus.emit('complete', info);
|
|
271612
271661
|
});
|
|
271613
271662
|
this.uploader.on('progress', (info)=>{
|
|
@@ -271616,9 +271665,6 @@ class ChatCoreUploadPlugin {
|
|
|
271616
271665
|
this.uploader.on('error', (info)=>{
|
|
271617
271666
|
this.eventBus.emit('error', info);
|
|
271618
271667
|
});
|
|
271619
|
-
this.uploader.on('complete', (info)=>{
|
|
271620
|
-
this.eventBus.emit('complete', info);
|
|
271621
|
-
});
|
|
271622
271668
|
this.uploader.start();
|
|
271623
271669
|
} catch (e) {
|
|
271624
271670
|
safeAsyncThrow(`upload-plugin error: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -296996,7 +297042,13 @@ const TextItemList = (param)=>{
|
|
|
296996
297042
|
showBackground
|
|
296997
297043
|
}),
|
|
296998
297044
|
style: {
|
|
296999
|
-
width: 'fit-content'
|
|
297045
|
+
width: 'fit-content',
|
|
297046
|
+
marginLeft: 'auto',
|
|
297047
|
+
// mix-content 内的文本内容应该和纯文本消息使用相同的样式
|
|
297048
|
+
background: '#F4F4F4',
|
|
297049
|
+
padding: '10px',
|
|
297050
|
+
borderRadius: '10px 0px 10px 10px',
|
|
297051
|
+
textAlign: 'right'
|
|
297000
297052
|
},
|
|
297001
297053
|
children: [
|
|
297002
297054
|
TextContentAddonTop,
|
|
@@ -297823,6 +297875,129 @@ UIKitTooltip.displayName = 'UIKitTooltip';
|
|
|
297823
297875
|
return `${digit} ${sizes[i]}`;
|
|
297824
297876
|
};
|
|
297825
297877
|
|
|
297878
|
+
;// CONCATENATED MODULE: ../../../common/chat-area/chat-uikit/src/hooks/use-doc-viewer-config.ts
|
|
297879
|
+
/*
|
|
297880
|
+
* Copyright 2025 coze-dev Authors
|
|
297881
|
+
*
|
|
297882
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
297883
|
+
* you may not use this file except in compliance with the License.
|
|
297884
|
+
* You may obtain a copy of the License at
|
|
297885
|
+
*
|
|
297886
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
297887
|
+
*
|
|
297888
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
297889
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
297890
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
297891
|
+
* See the License for the specific language governing permissions and
|
|
297892
|
+
* limitations under the License.
|
|
297893
|
+
*/ // Try to import useChatAppProps and useChatAppStore from open-chat if available
|
|
297894
|
+
|
|
297895
|
+
|
|
297896
|
+
|
|
297897
|
+
let useChatAppProps = null;
|
|
297898
|
+
let useChatAppStore = null;
|
|
297899
|
+
try {
|
|
297900
|
+
// Dynamic import, module may not be available
|
|
297901
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports -- Dynamic require needed for optional dependency
|
|
297902
|
+
const openChatModule = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module '@coze-studio/open-chat'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
|
|
297903
|
+
// eslint-disable-next-line prefer-destructuring -- Direct assignment needed for conditional hook usage
|
|
297904
|
+
useChatAppProps = openChatModule.useChatAppProps;
|
|
297905
|
+
// eslint-disable-next-line prefer-destructuring -- Direct assignment needed for conditional hook usage
|
|
297906
|
+
useChatAppStore = openChatModule.useChatAppStore;
|
|
297907
|
+
} catch (error) {
|
|
297908
|
+
// Module not available, will use default values
|
|
297909
|
+
// Error is expected when module is not available, so we can safely ignore it
|
|
297910
|
+
if (false) {}
|
|
297911
|
+
}
|
|
297912
|
+
/**
|
|
297913
|
+
* Parse domain and productCode from apiUrl
|
|
297914
|
+
* apiUrl format: 域名/api/productCode/flow
|
|
297915
|
+
* Example: https://aiot-dev.glodon.com/api/cvforce/flow
|
|
297916
|
+
* Returns: { domain: 'https://aiot-dev.glodon.com', productCode: 'cvforce' }
|
|
297917
|
+
*/ const parseApiUrl = (apiUrl)=>{
|
|
297918
|
+
const defaultDomain = 'https://aiot-dev.glodon.com';
|
|
297919
|
+
const defaultProductCode = 'cvforcepd';
|
|
297920
|
+
if (!apiUrl) {
|
|
297921
|
+
return {
|
|
297922
|
+
domain: defaultDomain,
|
|
297923
|
+
productCode: defaultProductCode
|
|
297924
|
+
};
|
|
297925
|
+
}
|
|
297926
|
+
try {
|
|
297927
|
+
// Parse URL: 域名/api/productCode/flow
|
|
297928
|
+
const url = new URL(apiUrl);
|
|
297929
|
+
const domain = `${url.protocol}//${url.host}`;
|
|
297930
|
+
const pathParts = url.pathname.split('/').filter(Boolean);
|
|
297931
|
+
// Find 'api' in path and get the next part as productCode
|
|
297932
|
+
const apiIndex = pathParts.indexOf('api');
|
|
297933
|
+
if (apiIndex >= 0 && apiIndex < pathParts.length - 1) {
|
|
297934
|
+
const productCode = pathParts[apiIndex + 1];
|
|
297935
|
+
return {
|
|
297936
|
+
domain,
|
|
297937
|
+
productCode
|
|
297938
|
+
};
|
|
297939
|
+
}
|
|
297940
|
+
} catch (urlError) {
|
|
297941
|
+
// If URL parsing fails, try regex
|
|
297942
|
+
const match = apiUrl.match(/^(https?:\/\/[^\/]+)\/api\/([^\/]+)\//);
|
|
297943
|
+
if (match) {
|
|
297944
|
+
return {
|
|
297945
|
+
domain: match[1],
|
|
297946
|
+
productCode: match[2]
|
|
297947
|
+
};
|
|
297948
|
+
}
|
|
297949
|
+
// If regex also fails, log in development mode
|
|
297950
|
+
if (false) {}
|
|
297951
|
+
}
|
|
297952
|
+
return {
|
|
297953
|
+
domain: defaultDomain,
|
|
297954
|
+
productCode: defaultProductCode
|
|
297955
|
+
};
|
|
297956
|
+
};
|
|
297957
|
+
/**
|
|
297958
|
+
* Build default doc viewer URL from apiUrl
|
|
297959
|
+
* Format: 域名/portal/_/productCode/doc-viewer/
|
|
297960
|
+
* Example: https://aiot-dev.glodon.com/api/cvforce/flow -> https://aiot-dev.glodon.com/portal/_/cvforce/doc-viewer/
|
|
297961
|
+
*/ const buildDefaultDocViewerUrl = (apiUrl)=>{
|
|
297962
|
+
const { domain, productCode } = parseApiUrl(apiUrl);
|
|
297963
|
+
return `${domain}/portal/_/${productCode}/doc-viewer/`;
|
|
297964
|
+
};
|
|
297965
|
+
/**
|
|
297966
|
+
* Get document viewer configuration from SDK config
|
|
297967
|
+
* Falls back to default values parsed from apiUrl if SDK config is not available
|
|
297968
|
+
*/ const useDocViewerConfig = ()=>{
|
|
297969
|
+
let docViewerConfig;
|
|
297970
|
+
let apiUrl;
|
|
297971
|
+
// These hooks are dynamically imported and may not be available
|
|
297972
|
+
if (useChatAppProps) {
|
|
297973
|
+
try {
|
|
297974
|
+
var _chatConfigResult_chatConfig_extra, _chatConfigResult_chatConfig;
|
|
297975
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- Hook is conditionally available
|
|
297976
|
+
const chatConfigResult = useChatAppProps();
|
|
297977
|
+
docViewerConfig = chatConfigResult === null || chatConfigResult === void 0 ? void 0 : (_chatConfigResult_chatConfig = chatConfigResult.chatConfig) === null || _chatConfigResult_chatConfig === void 0 ? void 0 : (_chatConfigResult_chatConfig_extra = _chatConfigResult_chatConfig.extra) === null || _chatConfigResult_chatConfig_extra === void 0 ? void 0 : _chatConfigResult_chatConfig_extra.docViewer;
|
|
297978
|
+
} catch (hookError) {
|
|
297979
|
+
// Hook not available in this context, use defaults
|
|
297980
|
+
if (false) {}
|
|
297981
|
+
}
|
|
297982
|
+
}
|
|
297983
|
+
if (useChatAppStore) {
|
|
297984
|
+
try {
|
|
297985
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- Hook is conditionally available
|
|
297986
|
+
apiUrl = useChatAppStore((state)=>state.apiUrl);
|
|
297987
|
+
} catch (storeError) {
|
|
297988
|
+
// Store not available in this context, use defaults
|
|
297989
|
+
if (false) {}
|
|
297990
|
+
}
|
|
297991
|
+
}
|
|
297992
|
+
// Default values: use config if provided, otherwise parse from apiUrl
|
|
297993
|
+
const baseUrl = (docViewerConfig === null || docViewerConfig === void 0 ? void 0 : docViewerConfig.baseUrl) || buildDefaultDocViewerUrl(apiUrl);
|
|
297994
|
+
const urlParam = (docViewerConfig === null || docViewerConfig === void 0 ? void 0 : docViewerConfig.urlParam) || 'url';
|
|
297995
|
+
return {
|
|
297996
|
+
baseUrl,
|
|
297997
|
+
urlParam
|
|
297998
|
+
};
|
|
297999
|
+
};
|
|
298000
|
+
|
|
297826
298001
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-uikit/src/components/contents/file-content/components/FileCard/variants.ts
|
|
297827
298002
|
/*
|
|
297828
298003
|
* Copyright 2025 coze-dev Authors
|
|
@@ -298597,7 +298772,68 @@ var file_card_update = injectStylesIntoStyleTag_default()(file_card/* ["default"
|
|
|
298597
298772
|
|
|
298598
298773
|
|
|
298599
298774
|
|
|
298600
|
-
|
|
298775
|
+
|
|
298776
|
+
/**
|
|
298777
|
+
* Get file URL from URI using GetImagexShortUrl API (same as image)
|
|
298778
|
+
* Falls back to URI if API call fails
|
|
298779
|
+
*/ const getFileUrlFromUri = async (uri)=>{
|
|
298780
|
+
try {
|
|
298781
|
+
// Build API URL using the same logic as getBaseURL from @coze-arch/bot-http
|
|
298782
|
+
const productCode = // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Window global property may not be typed
|
|
298783
|
+
window.__PRODUCT_CODE__ || {"NODE_ENV":"production","CHAT_APP_CHATFLOW_COZE_APP_ID":"","CHAT_APP_CHATFLOW_COZE_WORKFLOW_ID":"","CHAT_APP_INDEX_COZE_BOT_ID":"","CHAT_APP_COZE_TOKEN":"","CHAT_APP_COZE_BOT_USER_URL":""}.VITE_PRODUCD_CODE || location.pathname.split('/')[3];
|
|
298784
|
+
const isLocal = "production" === 'development';
|
|
298785
|
+
const baseUrl = {"NODE_ENV":"production","CHAT_APP_CHATFLOW_COZE_APP_ID":"","CHAT_APP_CHATFLOW_COZE_WORKFLOW_ID":"","CHAT_APP_INDEX_COZE_BOT_ID":"","CHAT_APP_COZE_TOKEN":"","CHAT_APP_COZE_BOT_USER_URL":""}.VITE_BASE_API || window.location.origin;
|
|
298786
|
+
const apiPath = '/api/playground_api/get_imagex_url';
|
|
298787
|
+
const apiUrl = isLocal ? `${window.location.origin}/server/api/${productCode}/flow${apiPath}` : `${baseUrl}/api/${productCode}/flow${apiPath}`;
|
|
298788
|
+
// Get auth token - try to use the same method as axiosInstance
|
|
298789
|
+
const getAuthToken = ()=>{
|
|
298790
|
+
var _document_cookie_split_find;
|
|
298791
|
+
if (window.location.hash.includes('/embed/application')) {
|
|
298792
|
+
return localStorage.getItem('embed.token');
|
|
298793
|
+
}
|
|
298794
|
+
// Try to get token from localStorage (same as getTokenWithSync)
|
|
298795
|
+
return localStorage.getItem('token') || localStorage.getItem('coze_token') || ((_document_cookie_split_find = document.cookie.split(';').find((c)=>c.trim().startsWith('token='))) === null || _document_cookie_split_find === void 0 ? void 0 : _document_cookie_split_find.split('=')[1]);
|
|
298796
|
+
};
|
|
298797
|
+
const token = getAuthToken();
|
|
298798
|
+
const headers = {
|
|
298799
|
+
'Content-Type': 'application/json',
|
|
298800
|
+
'x-requested-with': 'XMLHttpRequest',
|
|
298801
|
+
'Agw-Js-Conv': 'str'
|
|
298802
|
+
};
|
|
298803
|
+
if (token) {
|
|
298804
|
+
headers.Authorization = `Bearer ${token}`;
|
|
298805
|
+
}
|
|
298806
|
+
// Call GetImagexShortUrl API with uris array
|
|
298807
|
+
const response = await fetch(apiUrl, {
|
|
298808
|
+
method: 'POST',
|
|
298809
|
+
headers,
|
|
298810
|
+
credentials: 'include',
|
|
298811
|
+
body: JSON.stringify({
|
|
298812
|
+
uris: [
|
|
298813
|
+
uri
|
|
298814
|
+
]
|
|
298815
|
+
})
|
|
298816
|
+
});
|
|
298817
|
+
if (response.ok) {
|
|
298818
|
+
const contentType = response.headers.get('content-type');
|
|
298819
|
+
if (contentType && contentType.includes('application/json')) {
|
|
298820
|
+
var _result_data_url_info_uri, _result_data_url_info, _result_data;
|
|
298821
|
+
const result = await response.json();
|
|
298822
|
+
// Get URL from url_info map using URI as key (same as image)
|
|
298823
|
+
const url = result === null || result === void 0 ? void 0 : (_result_data = result.data) === null || _result_data === void 0 ? void 0 : (_result_data_url_info = _result_data.url_info) === null || _result_data_url_info === void 0 ? void 0 : (_result_data_url_info_uri = _result_data_url_info[uri]) === null || _result_data_url_info_uri === void 0 ? void 0 : _result_data_url_info_uri.url;
|
|
298824
|
+
if (url) {
|
|
298825
|
+
return url;
|
|
298826
|
+
}
|
|
298827
|
+
}
|
|
298828
|
+
}
|
|
298829
|
+
} catch (error) {
|
|
298830
|
+
// Silently fail and fall back to URI
|
|
298831
|
+
if (false) {}
|
|
298832
|
+
}
|
|
298833
|
+
// Fallback to URI if API call fails
|
|
298834
|
+
return uri;
|
|
298835
|
+
};
|
|
298836
|
+
// eslint-disable-next-line @coze-arch/max-line-per-function -- FileCard component requires many lines
|
|
298601
298837
|
const FileCard_FileCard = (props)=>{
|
|
298602
298838
|
const { file, attributeKeys, tooltipsCopywriting, readonly, onCancel, onCopy, onRetry, className, layout, showBackground } = props;
|
|
298603
298839
|
const { statusKey, statusEnum, percentKey } = attributeKeys;
|
|
@@ -298609,6 +298845,74 @@ const FileCard_FileCard = (props)=>{
|
|
|
298609
298845
|
const buttonsVisible = !readonly;
|
|
298610
298846
|
const { extension, nameWithoutExtension } = getFileExtensionAndName(file.file_name);
|
|
298611
298847
|
const isCanceled = file[statusKey] === statusEnum.cancelEnum;
|
|
298848
|
+
const fileStatusValue = file[statusKey];
|
|
298849
|
+
const fileUrl = file.file_url;
|
|
298850
|
+
const fileKey = file.file_key;
|
|
298851
|
+
// If upload_status is undefined but file has file_url or file_key, consider it as success
|
|
298852
|
+
// This handles files from server messages that don't have upload_status field
|
|
298853
|
+
const isSuccess = fileStatusValue === statusEnum.successEnum || fileStatusValue === undefined && (fileUrl || fileKey);
|
|
298854
|
+
const { baseUrl, urlParam } = useDocViewerConfig();
|
|
298855
|
+
const buildDocViewerUrl = (fileUrlParam)=>{
|
|
298856
|
+
const separator = baseUrl.includes('?') ? '&' : '?';
|
|
298857
|
+
return `${baseUrl}${separator}${urlParam}=${encodeURIComponent(fileUrlParam)}`;
|
|
298858
|
+
};
|
|
298859
|
+
const handlePreview = async (e)=>{
|
|
298860
|
+
e.stopPropagation();
|
|
298861
|
+
if (!isSuccess) {
|
|
298862
|
+
return;
|
|
298863
|
+
}
|
|
298864
|
+
// 优先使用 file_url,如果没有则使用 file_key (URI)
|
|
298865
|
+
if (fileUrl) {
|
|
298866
|
+
const docViewerUrl = buildDocViewerUrl(fileUrl);
|
|
298867
|
+
window.open(docViewerUrl, '_blank');
|
|
298868
|
+
return;
|
|
298869
|
+
}
|
|
298870
|
+
if (fileKey) {
|
|
298871
|
+
// Get URL from URI using API
|
|
298872
|
+
try {
|
|
298873
|
+
const resolvedUrl = await getFileUrlFromUri(fileKey);
|
|
298874
|
+
const docViewerUrl = buildDocViewerUrl(resolvedUrl);
|
|
298875
|
+
window.open(docViewerUrl, '_blank');
|
|
298876
|
+
} catch (error) {
|
|
298877
|
+
// Fallback to using URI directly
|
|
298878
|
+
if (false) {}
|
|
298879
|
+
const docViewerUrl = buildDocViewerUrl(fileKey);
|
|
298880
|
+
window.open(docViewerUrl, '_blank');
|
|
298881
|
+
}
|
|
298882
|
+
return;
|
|
298883
|
+
}
|
|
298884
|
+
};
|
|
298885
|
+
const handleClick = async (e)=>{
|
|
298886
|
+
if (!isSuccess) {
|
|
298887
|
+
return;
|
|
298888
|
+
}
|
|
298889
|
+
// 如果点击的是操作按钮或其子元素,不执行跳转
|
|
298890
|
+
const target = e.target;
|
|
298891
|
+
const isButton = target.closest('button') || target.closest('[role="button"]') || target.closest('[class*="IconButton"]');
|
|
298892
|
+
if (isButton) {
|
|
298893
|
+
return;
|
|
298894
|
+
}
|
|
298895
|
+
// 优先使用 file_url,如果没有则使用 file_key (URI)
|
|
298896
|
+
if (fileUrl) {
|
|
298897
|
+
const docViewerUrl = buildDocViewerUrl(fileUrl);
|
|
298898
|
+
window.open(docViewerUrl, '_blank');
|
|
298899
|
+
return;
|
|
298900
|
+
}
|
|
298901
|
+
if (fileKey) {
|
|
298902
|
+
// Get URL from URI using API
|
|
298903
|
+
try {
|
|
298904
|
+
const resolvedUrl = await getFileUrlFromUri(fileKey);
|
|
298905
|
+
const docViewerUrl = buildDocViewerUrl(resolvedUrl);
|
|
298906
|
+
window.open(docViewerUrl, '_blank');
|
|
298907
|
+
} catch (error) {
|
|
298908
|
+
// Fallback to using URI directly
|
|
298909
|
+
if (false) {}
|
|
298910
|
+
const docViewerUrl = buildDocViewerUrl(fileKey);
|
|
298911
|
+
window.open(docViewerUrl, '_blank');
|
|
298912
|
+
}
|
|
298913
|
+
return;
|
|
298914
|
+
}
|
|
298915
|
+
};
|
|
298612
298916
|
return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
|
|
298613
298917
|
// className={classNames(className, 'chat-uikit-file-card', {
|
|
298614
298918
|
// 'chat-uikit-file-card--error': file[statusKey] === statusEnum.failEnum,
|
|
@@ -298621,7 +298925,8 @@ const FileCard_FileCard = (props)=>{
|
|
|
298621
298925
|
isError: file[statusKey] === statusEnum.failEnum,
|
|
298622
298926
|
layout: layout === common_Layout.PC ? 'pc' : 'mobile',
|
|
298623
298927
|
showBackground
|
|
298624
|
-
}), className),
|
|
298928
|
+
}), className, 'cursor-pointer'),
|
|
298929
|
+
onClick: handleClick,
|
|
298625
298930
|
children: [
|
|
298626
298931
|
/*#__PURE__*/ (0,jsx_runtime.jsx)("img", {
|
|
298627
298932
|
src: fileIconMap[file.file_type],
|
|
@@ -298677,7 +298982,10 @@ const FileCard_FileCard = (props)=>{
|
|
|
298677
298982
|
, {}),
|
|
298678
298983
|
size: "small",
|
|
298679
298984
|
color: "secondary",
|
|
298680
|
-
onClick:
|
|
298985
|
+
onClick: (e)=>{
|
|
298986
|
+
e.stopPropagation();
|
|
298987
|
+
onCancel();
|
|
298988
|
+
}
|
|
298681
298989
|
})
|
|
298682
298990
|
}),
|
|
298683
298991
|
[
|
|
@@ -298694,21 +299002,47 @@ const FileCard_FileCard = (props)=>{
|
|
|
298694
299002
|
, {}),
|
|
298695
299003
|
size: "small",
|
|
298696
299004
|
color: "secondary",
|
|
298697
|
-
onClick:
|
|
299005
|
+
onClick: (e)=>{
|
|
299006
|
+
e.stopPropagation();
|
|
299007
|
+
onRetry();
|
|
299008
|
+
}
|
|
298698
299009
|
})
|
|
298699
299010
|
}),
|
|
299011
|
+
isSuccess ? /*#__PURE__*/ (0,jsx_runtime.jsx)(UIKitTooltip, {
|
|
299012
|
+
theme: "light",
|
|
299013
|
+
position: "top",
|
|
299014
|
+
content: (tooltipsCopywriting === null || tooltipsCopywriting === void 0 ? void 0 : tooltipsCopywriting.preview) || '预览',
|
|
299015
|
+
hideToolTip: layout === common_Layout.MOBILE,
|
|
299016
|
+
children: /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
|
|
299017
|
+
className: "chat-uikit-file-card__preview-button-wrapper",
|
|
299018
|
+
children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_IconButton, {
|
|
299019
|
+
icon: /*#__PURE__*/ (0,jsx_runtime.jsx)(__webpack_exports__IconCozEye, {}),
|
|
299020
|
+
size: "small",
|
|
299021
|
+
color: "secondary",
|
|
299022
|
+
onClick: handlePreview,
|
|
299023
|
+
className: "chat-uikit-file-card__preview-button"
|
|
299024
|
+
})
|
|
299025
|
+
})
|
|
299026
|
+
}) : null,
|
|
298700
299027
|
file[statusKey] === statusEnum.successEnum && /*#__PURE__*/ (0,jsx_runtime.jsx)(UIKitTooltip, {
|
|
298701
299028
|
theme: "light",
|
|
298702
299029
|
position: "top",
|
|
298703
299030
|
content: tooltipsCopywriting === null || tooltipsCopywriting === void 0 ? void 0 : tooltipsCopywriting.copy,
|
|
298704
299031
|
hideToolTip: layout === common_Layout.MOBILE,
|
|
298705
|
-
children: /*#__PURE__*/ (0,jsx_runtime.jsx)(
|
|
298706
|
-
|
|
298707
|
-
|
|
298708
|
-
|
|
298709
|
-
|
|
298710
|
-
|
|
298711
|
-
|
|
299032
|
+
children: /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
|
|
299033
|
+
className: "chat-uikit-file-card__copy-button-wrapper",
|
|
299034
|
+
children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_IconButton, {
|
|
299035
|
+
// chat-uikit-file-card__buttons__button
|
|
299036
|
+
icon: /*#__PURE__*/ (0,jsx_runtime.jsx)(__webpack_exports__IconCozCopy // chat-uikit-file-card__buttons__icon
|
|
299037
|
+
, {}),
|
|
299038
|
+
size: "small",
|
|
299039
|
+
color: "secondary",
|
|
299040
|
+
onClick: (e)=>{
|
|
299041
|
+
e.stopPropagation();
|
|
299042
|
+
onCopy();
|
|
299043
|
+
},
|
|
299044
|
+
className: "chat-uikit-file-card__copy-button"
|
|
299045
|
+
})
|
|
298712
299046
|
})
|
|
298713
299047
|
})
|
|
298714
299048
|
]
|
|
@@ -300098,6 +300432,7 @@ var message_box_update = injectStylesIntoStyleTag_default()(message_box/* ["defa
|
|
|
300098
300432
|
|
|
300099
300433
|
|
|
300100
300434
|
|
|
300435
|
+
|
|
300101
300436
|
const MessageBoxWrap = (props)=>{
|
|
300102
300437
|
const { children, theme, nickname, avatar, showUserInfo, renderFooter, hoverContent, right, senderId, classname, messageBubbleClassname, messageBubbleWrapperClassname, messageBoxWrapperClassname, messageHoverWrapperClassName, messageErrorWrapperClassname, isHoverShowUserInfo = true, layout, contentTime, showBackground, extendedUserInfo, topRightSlot, imageAutoSizeContainerWidth, enableImageAutoSize, messageId, eventCallbacks, onError } = props;
|
|
300103
300438
|
const { userLabel, userUniqueName } = extendedUserInfo ?? {};
|
|
@@ -300110,6 +300445,10 @@ const MessageBoxWrap = (props)=>{
|
|
|
300110
300445
|
const isMobileLayout = layout === common_Layout.MOBILE;
|
|
300111
300446
|
// 判断是否为发送消息:发送消息通常使用 'primary' 主题
|
|
300112
300447
|
const isSentMessage = theme === 'primary';
|
|
300448
|
+
// 判断是否为 mix-content 消息:mix-content 消息使用 'none' 主题,但仍然是发送的消息
|
|
300449
|
+
const isMixContentMessage = theme === 'none' && (classname === null || classname === void 0 ? void 0 : classname.includes('chat-uikit-mix-content-message-box'));
|
|
300450
|
+
// 判断是否应该应用发送消息的样式(包括纯文本和 mix-content)
|
|
300451
|
+
const shouldApplySentMessageStyle = isSentMessage || isMixContentMessage;
|
|
300113
300452
|
const refreshContainerWidthConditionally = use_event_callback_useEventCallback(()=>{
|
|
300114
300453
|
if (!messageContainerRef.current || !messageFooterRef.current) {
|
|
300115
300454
|
return;
|
|
@@ -300167,14 +300506,14 @@ const MessageBoxWrap = (props)=>{
|
|
|
300167
300506
|
// chat-uikit-message-box-container chat-uikit-message-box-container-pc
|
|
300168
300507
|
className: classnames_default()(messageBoxContainerVariants({
|
|
300169
300508
|
isMobileLayout,
|
|
300170
|
-
isSentMessage
|
|
300509
|
+
isSentMessage: shouldApplySentMessageStyle
|
|
300171
300510
|
}), messageBoxWrapperClassname),
|
|
300172
300511
|
children: [
|
|
300173
300512
|
showUserInfo ? /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
|
|
300174
300513
|
// chat-uikit-message-box-container__avatar-wrap
|
|
300175
300514
|
className: classnames_default()('w-32px h-32px', {
|
|
300176
|
-
'ml-[12px]':
|
|
300177
|
-
'mr-[12px]': !
|
|
300515
|
+
'ml-[12px]': shouldApplySentMessageStyle,
|
|
300516
|
+
'mr-[12px]': !shouldApplySentMessageStyle
|
|
300178
300517
|
}),
|
|
300179
300518
|
children: /*#__PURE__*/ (0,jsx_runtime.jsx)(AvatarWrap, {
|
|
300180
300519
|
children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_Avatar, {
|
|
@@ -300189,7 +300528,7 @@ const MessageBoxWrap = (props)=>{
|
|
|
300189
300528
|
// chat-uikit-message-box-container__message
|
|
300190
300529
|
className: classnames_default()('flex-1', {
|
|
300191
300530
|
'max-w-[calc(100%-80px)]': true,
|
|
300192
|
-
'flex justify-end':
|
|
300531
|
+
'flex justify-end': shouldApplySentMessageStyle
|
|
300193
300532
|
}),
|
|
300194
300533
|
children: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
|
|
300195
300534
|
// chat-uikit-message-box-container__message__message-box
|
|
@@ -358055,9 +358394,10 @@ const removeAllListeners = (instance)=>{
|
|
|
358055
358394
|
instance.removeAllListeners('error');
|
|
358056
358395
|
instance.removeAllListeners('progress');
|
|
358057
358396
|
};
|
|
358058
|
-
// eslint-disable-next-line max-lines-per-function
|
|
358397
|
+
// eslint-disable-next-line @coze-arch/max-line-per-function, max-lines-per-function -- Upload function requires many lines for complete functionality
|
|
358059
358398
|
function upload_uploadFile(param) {
|
|
358060
358399
|
let { file, fileType = 'image', userId, signal, onProgress, onUploaderReady, onUploadError, onGetTokenError, onSuccess } = param;
|
|
358400
|
+
// eslint-disable-next-line @coze-arch/max-line-per-function, max-lines-per-function -- Promise handler requires many lines
|
|
358061
358401
|
return new Promise((resolve)=>{
|
|
358062
358402
|
let bytedUploader = null;
|
|
358063
358403
|
let shouldContinue = true;
|
|
@@ -358107,6 +358447,34 @@ function upload_uploadFile(param) {
|
|
|
358107
358447
|
}, false);
|
|
358108
358448
|
onUploaderReady === null || onUploaderReady === void 0 ? void 0 : onUploaderReady(bytedUploader);
|
|
358109
358449
|
bytedUploader.on('complete', (inform)=>{
|
|
358450
|
+
var _informAny_response, _informAny_result, _informAny__response, _informAny_rawResponse;
|
|
358451
|
+
// Backend returns: { data: { uri: "xxx", id: "yyy", url: "zzz" } }
|
|
358452
|
+
// Upload adapter may not map data.uri correctly - check complete inform structure
|
|
358453
|
+
const informAny = inform;
|
|
358454
|
+
// Check task object for raw response data
|
|
358455
|
+
let rawResponseData = null;
|
|
358456
|
+
if (informAny.task) {
|
|
358457
|
+
var _informAny_task_response, _informAny_task_responseData, _informAny_task_result, _informAny_task__response, _informAny_task_rawResponse;
|
|
358458
|
+
// Check various possible locations in task
|
|
358459
|
+
rawResponseData = ((_informAny_task_response = informAny.task.response) === null || _informAny_task_response === void 0 ? void 0 : _informAny_task_response.data) || ((_informAny_task_responseData = informAny.task.responseData) === null || _informAny_task_responseData === void 0 ? void 0 : _informAny_task_responseData.data) || ((_informAny_task_result = informAny.task.result) === null || _informAny_task_result === void 0 ? void 0 : _informAny_task_result.data) || informAny.task.data || ((_informAny_task__response = informAny.task._response) === null || _informAny_task__response === void 0 ? void 0 : _informAny_task__response.data) || ((_informAny_task_rawResponse = informAny.task.rawResponse) === null || _informAny_task_rawResponse === void 0 ? void 0 : _informAny_task_rawResponse.data);
|
|
358460
|
+
}
|
|
358461
|
+
// Also check inform level - check all possible nested paths
|
|
358462
|
+
const informLevelData = informAny.data || ((_informAny_response = informAny.response) === null || _informAny_response === void 0 ? void 0 : _informAny_response.data) || informAny.responseData || ((_informAny_result = informAny.result) === null || _informAny_result === void 0 ? void 0 : _informAny_result.data) || ((_informAny__response = informAny._response) === null || _informAny__response === void 0 ? void 0 : _informAny__response.data) || ((_informAny_rawResponse = informAny.rawResponse) === null || _informAny_rawResponse === void 0 ? void 0 : _informAny_rawResponse.data);
|
|
358463
|
+
// Use rawResponseData or informLevelData
|
|
358464
|
+
const backendData = rawResponseData || informLevelData;
|
|
358465
|
+
if (informAny.uploadResult && backendData) {
|
|
358466
|
+
// Backend returns lowercase fields: uri, id, url
|
|
358467
|
+
// Map them correctly to uploadResult
|
|
358468
|
+
if (backendData.uri) {
|
|
358469
|
+
informAny.uploadResult.uri = backendData.uri;
|
|
358470
|
+
}
|
|
358471
|
+
if (backendData.id) {
|
|
358472
|
+
informAny.uploadResult.id = backendData.id;
|
|
358473
|
+
}
|
|
358474
|
+
if (backendData.url) {
|
|
358475
|
+
informAny.uploadResult.url = backendData.url;
|
|
358476
|
+
}
|
|
358477
|
+
}
|
|
358110
358478
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(inform);
|
|
358111
358479
|
resolve();
|
|
358112
358480
|
});
|
|
@@ -358180,7 +358548,7 @@ const checkHasFileOnDrag = (e)=>{
|
|
|
358180
358548
|
Boolean((_e_dataTransfer = e.dataTransfer) === null || _e_dataTransfer === void 0 ? void 0 : _e_dataTransfer.types.includes('Files')));
|
|
358181
358549
|
};
|
|
358182
358550
|
const formatFileDataListToMessagePayload = (fileDataList)=>fileDataList.map((data)=>{
|
|
358183
|
-
const { uri } = data;
|
|
358551
|
+
const { uri, fileId } = data;
|
|
358184
358552
|
if (!uri) {
|
|
358185
358553
|
throw new Error('failed to get file uri');
|
|
358186
358554
|
}
|
|
@@ -358188,7 +358556,8 @@ const formatFileDataListToMessagePayload = (fileDataList)=>fileDataList.map((dat
|
|
|
358188
358556
|
const filePayload = {
|
|
358189
358557
|
type: types_ContentType.File,
|
|
358190
358558
|
file: data.file,
|
|
358191
|
-
uri
|
|
358559
|
+
uri,
|
|
358560
|
+
id: fileId || undefined
|
|
358192
358561
|
};
|
|
358193
358562
|
return filePayload;
|
|
358194
358563
|
}
|
|
@@ -358198,7 +358567,8 @@ const formatFileDataListToMessagePayload = (fileDataList)=>fileDataList.map((dat
|
|
|
358198
358567
|
file: data.file,
|
|
358199
358568
|
uri,
|
|
358200
358569
|
width: (meta === null || meta === void 0 ? void 0 : meta.width) ?? 0,
|
|
358201
|
-
height: (meta === null || meta === void 0 ? void 0 : meta.height) ?? 0
|
|
358570
|
+
height: (meta === null || meta === void 0 ? void 0 : meta.height) ?? 0,
|
|
358571
|
+
id: fileId || undefined
|
|
358202
358572
|
};
|
|
358203
358573
|
return imagePayload;
|
|
358204
358574
|
});
|
|
@@ -358438,17 +358808,52 @@ const useUpload = ()=>{
|
|
|
358438
358808
|
data.percent = event.percent;
|
|
358439
358809
|
});
|
|
358440
358810
|
},
|
|
358441
|
-
onComplete: (
|
|
358442
|
-
|
|
358811
|
+
onComplete: (event, id)=>{
|
|
358812
|
+
const { uploadResult } = event;
|
|
358813
|
+
// Event structure may contain additional properties from uploader library
|
|
358814
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Event structure varies
|
|
358815
|
+
const eventAny = event;
|
|
358443
358816
|
immerUpdateFileDataById(id, (data)=>{
|
|
358444
358817
|
data.status = types_FileStatus.Success;
|
|
358445
358818
|
data.percent = MAX_UPLOAD_PROGRESS;
|
|
358446
|
-
|
|
358447
|
-
|
|
358819
|
+
// Backend returns: { data: { uri: "xxx", id: "yyy", url: "zzz" } }
|
|
358820
|
+
// Upload adapter may map data.id to uploadResult.Uri (incorrectly)
|
|
358821
|
+
// We need to check the actual structure to get both id and uri correctly
|
|
358822
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- UploadResult structure varies
|
|
358823
|
+
const uploadResultAny = uploadResult;
|
|
358824
|
+
// Try to get raw response data from event object
|
|
358825
|
+
let backendData = null;
|
|
358826
|
+
if (eventAny.task) {
|
|
358827
|
+
var _eventAny_task_response, _eventAny_task_responseData, _eventAny_task_result;
|
|
358828
|
+
backendData = ((_eventAny_task_response = eventAny.task.response) === null || _eventAny_task_response === void 0 ? void 0 : _eventAny_task_response.data) || ((_eventAny_task_responseData = eventAny.task.responseData) === null || _eventAny_task_responseData === void 0 ? void 0 : _eventAny_task_responseData.data) || ((_eventAny_task_result = eventAny.task.result) === null || _eventAny_task_result === void 0 ? void 0 : _eventAny_task_result.data) || eventAny.task.data;
|
|
358829
|
+
}
|
|
358830
|
+
if (!backendData) {
|
|
358831
|
+
var _eventAny_response, _eventAny_result;
|
|
358832
|
+
backendData = eventAny.data || ((_eventAny_response = eventAny.response) === null || _eventAny_response === void 0 ? void 0 : _eventAny_response.data) || eventAny.responseData || ((_eventAny_result = eventAny.result) === null || _eventAny_result === void 0 ? void 0 : _eventAny_result.data);
|
|
358833
|
+
}
|
|
358834
|
+
// Backend returns lowercase fields: data.uri and data.id
|
|
358835
|
+
// Check if uploadResult has these fields directly (from raw response)
|
|
358836
|
+
// Or check if they're mapped to different fields
|
|
358837
|
+
const backendId = (backendData === null || backendData === void 0 ? void 0 : backendData.id) || // From raw backend response
|
|
358838
|
+
uploadResultAny.id || // Backend returns lowercase 'id'
|
|
358839
|
+
uploadResultAny.Id || // Check uppercase variant
|
|
358840
|
+
uploadResult.Uri || // Fallback to Uri if id not available
|
|
358841
|
+
null;
|
|
358842
|
+
// Backend returns lowercase 'uri' field
|
|
358843
|
+
// This is the real URI we need for getting file URL
|
|
358844
|
+
const backendUri = (backendData === null || backendData === void 0 ? void 0 : backendData.uri) || // From raw backend response - this is the real uri!
|
|
358845
|
+
uploadResultAny.uri || // Backend returns lowercase 'uri'
|
|
358846
|
+
uploadResultAny.Uri || // Check uppercase variant
|
|
358847
|
+
null;
|
|
358848
|
+
// Save backend file ID (used for other operations)
|
|
358849
|
+
data.fileId = backendId;
|
|
358850
|
+
// Save backend URI (used to get URL) - this should be the real URI from backend
|
|
358851
|
+
data.uri = backendUri;
|
|
358852
|
+
data.url = uploadResult.Url || uploadResultAny.url || (backendData === null || backendData === void 0 ? void 0 : backendData.url) || null;
|
|
358853
|
+
if (!data.uri && !data.fileId) {
|
|
358448
358854
|
data.status = types_FileStatus.Error;
|
|
358449
|
-
throw new Error('upload complete without uri');
|
|
358855
|
+
throw new Error('upload complete without uri or id');
|
|
358450
358856
|
}
|
|
358451
|
-
data.uri = uri;
|
|
358452
358857
|
if (data.fileType !== types_FileType.Image) {
|
|
358453
358858
|
return;
|
|
358454
358859
|
}
|
|
@@ -382853,7 +383258,10 @@ const scroll_view_ScrollView = /*#__PURE__*/ (0,react.forwardRef)(function Scrol
|
|
|
382853
383258
|
value: scrollViewContentRef,
|
|
382854
383259
|
children: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
|
|
382855
383260
|
className: classnames_default()(src_scroll_view_index_module["scroll-view"], className),
|
|
382856
|
-
style:
|
|
383261
|
+
style: {
|
|
383262
|
+
...style,
|
|
383263
|
+
flexGrow: 1
|
|
383264
|
+
},
|
|
382857
383265
|
ref: wrapperRef,
|
|
382858
383266
|
children: [
|
|
382859
383267
|
before ? /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
|
|
@@ -382870,6 +383278,9 @@ const scroll_view_ScrollView = /*#__PURE__*/ (0,react.forwardRef)(function Scrol
|
|
|
382870
383278
|
className: classnames_default()(src_scroll_view_index_module.scrollable, showScrollbar && src_scroll_view_index_module["show-scrollbar"], autoShowScrollbar && src_scroll_view_index_module["auto-show-scrollbar"], scrollbarWidthNone && src_scroll_view_index_module["scrollbar-width-none"], {
|
|
382871
383279
|
[src_scroll_view_index_module.reverse]: reverse
|
|
382872
383280
|
}),
|
|
383281
|
+
style: {
|
|
383282
|
+
height: '100%'
|
|
383283
|
+
},
|
|
382873
383284
|
onScroll: handleScroll,
|
|
382874
383285
|
children: [
|
|
382875
383286
|
lodash_es_isFunction(children) ? children(controller) : children,
|
|
@@ -396331,7 +396742,10 @@ const DeleteFileButton = (param)=>{
|
|
|
396331
396742
|
};
|
|
396332
396743
|
return /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
|
|
396333
396744
|
className: batch_upload_file_list_delete_file_button_index_module["icon-close"],
|
|
396334
|
-
onClick:
|
|
396745
|
+
onClick: (e)=>{
|
|
396746
|
+
e.stopPropagation();
|
|
396747
|
+
onDelete();
|
|
396748
|
+
},
|
|
396335
396749
|
children: /*#__PURE__*/ (0,jsx_runtime.jsx)(IconCloseNoCycle, {})
|
|
396336
396750
|
});
|
|
396337
396751
|
};
|
|
@@ -396541,6 +396955,131 @@ const ui_button_Button = /*#__PURE__*/ (0,react.forwardRef)((param, ref)=>{
|
|
|
396541
396955
|
});
|
|
396542
396956
|
});
|
|
396543
396957
|
|
|
396958
|
+
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/hooks/use-doc-viewer-config.ts
|
|
396959
|
+
/*
|
|
396960
|
+
* Copyright 2025 coze-dev Authors
|
|
396961
|
+
*
|
|
396962
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
396963
|
+
* you may not use this file except in compliance with the License.
|
|
396964
|
+
* You may obtain a copy of the License at
|
|
396965
|
+
*
|
|
396966
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
396967
|
+
*
|
|
396968
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
396969
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
396970
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
396971
|
+
* See the License for the specific language governing permissions and
|
|
396972
|
+
* limitations under the License.
|
|
396973
|
+
*/ // Try to import useChatAppProps and useChatAppStore from open-chat if available
|
|
396974
|
+
|
|
396975
|
+
|
|
396976
|
+
|
|
396977
|
+
let use_doc_viewer_config_useChatAppProps = null;
|
|
396978
|
+
let use_doc_viewer_config_useChatAppStore = null;
|
|
396979
|
+
try {
|
|
396980
|
+
// Dynamic import, module may not be available
|
|
396981
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports -- Dynamic require needed for optional dependency
|
|
396982
|
+
const openChatModule = __webpack_require__(Object(function webpackMissingModule() { var e = new Error("Cannot find module '@coze-studio/open-chat'"); e.code = 'MODULE_NOT_FOUND'; throw e; }()));
|
|
396983
|
+
// eslint-disable-next-line prefer-destructuring -- Direct assignment needed for conditional hook usage
|
|
396984
|
+
use_doc_viewer_config_useChatAppProps = openChatModule.useChatAppProps;
|
|
396985
|
+
// eslint-disable-next-line prefer-destructuring -- Direct assignment needed for conditional hook usage
|
|
396986
|
+
use_doc_viewer_config_useChatAppStore = openChatModule.useChatAppStore;
|
|
396987
|
+
} catch (error) {
|
|
396988
|
+
// Module not available, will use default values
|
|
396989
|
+
// Error is expected when module is not available, so we can safely ignore it
|
|
396990
|
+
if (false) {}
|
|
396991
|
+
}
|
|
396992
|
+
/**
|
|
396993
|
+
* Parse domain and productCode from apiUrl
|
|
396994
|
+
* apiUrl format: 域名/api/productCode/flow
|
|
396995
|
+
* Example: https://aiot-dev.glodon.com/api/cvforce/flow
|
|
396996
|
+
* Returns: { domain: 'https://aiot-dev.glodon.com', productCode: 'cvforce' }
|
|
396997
|
+
*/ const use_doc_viewer_config_parseApiUrl = (apiUrl)=>{
|
|
396998
|
+
const defaultDomain = 'https://aiot-dev.glodon.com';
|
|
396999
|
+
const defaultProductCode = 'cvforcepd';
|
|
397000
|
+
if (!apiUrl) {
|
|
397001
|
+
return {
|
|
397002
|
+
domain: defaultDomain,
|
|
397003
|
+
productCode: defaultProductCode
|
|
397004
|
+
};
|
|
397005
|
+
}
|
|
397006
|
+
try {
|
|
397007
|
+
// Parse URL: 域名/api/productCode/flow
|
|
397008
|
+
const url = new URL(apiUrl);
|
|
397009
|
+
const domain = `${url.protocol}//${url.host}`;
|
|
397010
|
+
const pathParts = url.pathname.split('/').filter(Boolean);
|
|
397011
|
+
// Find 'api' in path and get the next part as productCode
|
|
397012
|
+
const apiIndex = pathParts.indexOf('api');
|
|
397013
|
+
if (apiIndex >= 0 && apiIndex < pathParts.length - 1) {
|
|
397014
|
+
const productCode = pathParts[apiIndex + 1];
|
|
397015
|
+
if (productCode) {
|
|
397016
|
+
return {
|
|
397017
|
+
domain,
|
|
397018
|
+
productCode
|
|
397019
|
+
};
|
|
397020
|
+
}
|
|
397021
|
+
}
|
|
397022
|
+
} catch (urlError) {
|
|
397023
|
+
// If URL parsing fails, try regex
|
|
397024
|
+
const match = apiUrl.match(/^(https?:\/\/[^\/]+)\/api\/([^\/]+)\//);
|
|
397025
|
+
if (match && match[1] && match[2]) {
|
|
397026
|
+
return {
|
|
397027
|
+
domain: match[1],
|
|
397028
|
+
productCode: match[2]
|
|
397029
|
+
};
|
|
397030
|
+
}
|
|
397031
|
+
// If regex also fails, log in development mode
|
|
397032
|
+
if (false) {}
|
|
397033
|
+
}
|
|
397034
|
+
return {
|
|
397035
|
+
domain: defaultDomain,
|
|
397036
|
+
productCode: defaultProductCode
|
|
397037
|
+
};
|
|
397038
|
+
};
|
|
397039
|
+
/**
|
|
397040
|
+
* Build default doc viewer URL from apiUrl
|
|
397041
|
+
* Format: 域名/portal/_/productCode/doc-viewer/
|
|
397042
|
+
* Example: https://aiot-dev.glodon.com/api/cvforce/flow -> https://aiot-dev.glodon.com/portal/_/cvforce/doc-viewer/
|
|
397043
|
+
*/ const use_doc_viewer_config_buildDefaultDocViewerUrl = (apiUrl)=>{
|
|
397044
|
+
const { domain, productCode } = use_doc_viewer_config_parseApiUrl(apiUrl);
|
|
397045
|
+
return `${domain}/portal/_/${productCode}/doc-viewer/`;
|
|
397046
|
+
};
|
|
397047
|
+
/**
|
|
397048
|
+
* Get document viewer configuration from SDK config
|
|
397049
|
+
* Falls back to default values parsed from apiUrl if SDK config is not available
|
|
397050
|
+
*/ const use_doc_viewer_config_useDocViewerConfig = ()=>{
|
|
397051
|
+
let docViewerConfig;
|
|
397052
|
+
let apiUrl;
|
|
397053
|
+
// These hooks are dynamically imported and may not be available
|
|
397054
|
+
if (use_doc_viewer_config_useChatAppProps) {
|
|
397055
|
+
try {
|
|
397056
|
+
var _chatConfigResult_chatConfig_extra, _chatConfigResult_chatConfig;
|
|
397057
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- Hook is conditionally available
|
|
397058
|
+
const chatConfigResult = use_doc_viewer_config_useChatAppProps();
|
|
397059
|
+
docViewerConfig = chatConfigResult === null || chatConfigResult === void 0 ? void 0 : (_chatConfigResult_chatConfig = chatConfigResult.chatConfig) === null || _chatConfigResult_chatConfig === void 0 ? void 0 : (_chatConfigResult_chatConfig_extra = _chatConfigResult_chatConfig.extra) === null || _chatConfigResult_chatConfig_extra === void 0 ? void 0 : _chatConfigResult_chatConfig_extra.docViewer;
|
|
397060
|
+
} catch (hookError) {
|
|
397061
|
+
// Hook not available in this context, use defaults
|
|
397062
|
+
if (false) {}
|
|
397063
|
+
}
|
|
397064
|
+
}
|
|
397065
|
+
if (use_doc_viewer_config_useChatAppStore) {
|
|
397066
|
+
try {
|
|
397067
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- Hook is conditionally available
|
|
397068
|
+
apiUrl = use_doc_viewer_config_useChatAppStore((state)=>state.apiUrl);
|
|
397069
|
+
} catch (storeError) {
|
|
397070
|
+
// Store not available in this context, use defaults
|
|
397071
|
+
if (false) {}
|
|
397072
|
+
}
|
|
397073
|
+
}
|
|
397074
|
+
// Default values: use config if provided, otherwise parse from apiUrl
|
|
397075
|
+
const baseUrl = (docViewerConfig === null || docViewerConfig === void 0 ? void 0 : docViewerConfig.baseUrl) || use_doc_viewer_config_buildDefaultDocViewerUrl(apiUrl);
|
|
397076
|
+
const urlParam = (docViewerConfig === null || docViewerConfig === void 0 ? void 0 : docViewerConfig.urlParam) || 'url';
|
|
397077
|
+
return {
|
|
397078
|
+
baseUrl,
|
|
397079
|
+
urlParam
|
|
397080
|
+
};
|
|
397081
|
+
};
|
|
397082
|
+
|
|
396544
397083
|
// EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/css-loader@6.11.0_@rspack+core@1.5.8_webpack@5.91.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[7].use[1]!../../../../../common/temp/default/node_modules/.pnpm/postcss-loader@7.3.4_postcss@8.5.6_typescript@5.8.2_webpack@5.91.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[7].use[2]!../../../../../common/temp/default/node_modules/.pnpm/less-loader@11.1.4_less@4.4.2_webpack@5.91.0/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[7].use[3]!../../../common/chat-area/chat-area/src/components/batch-upload-file-list/common-file/index.module.less
|
|
396545
397084
|
var common_file_index_module = __webpack_require__(26758);
|
|
396546
397085
|
;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/components/batch-upload-file-list/common-file/index.module.less
|
|
@@ -396628,8 +397167,12 @@ const ProgressMask = (param)=>{
|
|
|
396628
397167
|
|
|
396629
397168
|
|
|
396630
397169
|
|
|
397170
|
+
|
|
397171
|
+
|
|
397172
|
+
|
|
397173
|
+
|
|
396631
397174
|
const CommonFile = (param)=>{
|
|
396632
|
-
let { file, status, percent, id, className } = param;
|
|
397175
|
+
let { file, status, percent, id, className, uri, url } = param;
|
|
396633
397176
|
const ref = (0,react.useRef)(null);
|
|
396634
397177
|
const isHover = es_useHover(ref);
|
|
396635
397178
|
const retryUpload = useRetryUpload();
|
|
@@ -396638,9 +397181,59 @@ const CommonFile = (param)=>{
|
|
|
396638
397181
|
const isSuccess = status === types_FileStatus.Success;
|
|
396639
397182
|
const fileTypeConfig = getFileTypConfig(file);
|
|
396640
397183
|
const { extension, nameWithoutExtension } = getFileExtensionAndName(file.name);
|
|
397184
|
+
const { baseUrl, urlParam } = use_doc_viewer_config_useDocViewerConfig();
|
|
397185
|
+
const buildDocViewerUrl = (fileUrl)=>{
|
|
397186
|
+
const separator = baseUrl.includes('?') ? '&' : '?';
|
|
397187
|
+
return `${baseUrl}${separator}${urlParam}=${encodeURIComponent(fileUrl)}`;
|
|
397188
|
+
};
|
|
397189
|
+
const handlePreview = (e)=>{
|
|
397190
|
+
e.stopPropagation();
|
|
397191
|
+
if (!isSuccess) {
|
|
397192
|
+
return;
|
|
397193
|
+
}
|
|
397194
|
+
// 如果已经有 url,直接使用
|
|
397195
|
+
if (url) {
|
|
397196
|
+
const docViewerUrl = buildDocViewerUrl(url);
|
|
397197
|
+
window.open(docViewerUrl, '_blank');
|
|
397198
|
+
return;
|
|
397199
|
+
}
|
|
397200
|
+
if (!uri) {
|
|
397201
|
+
console.warn('File URI is not available, cannot open file');
|
|
397202
|
+
return;
|
|
397203
|
+
}
|
|
397204
|
+
const docViewerUrl = buildDocViewerUrl(uri);
|
|
397205
|
+
window.open(docViewerUrl, '_blank');
|
|
397206
|
+
};
|
|
397207
|
+
const handleClick = (e)=>{
|
|
397208
|
+
if (!isSuccess) {
|
|
397209
|
+
return;
|
|
397210
|
+
}
|
|
397211
|
+
// 如果点击的是操作按钮或其子元素,不执行跳转
|
|
397212
|
+
// 操作按钮已经通过 stopPropagation 阻止冒泡,这里作为额外保护
|
|
397213
|
+
const target = e.target;
|
|
397214
|
+
if (target.closest(`.${batch_upload_file_list_common_file_index_module["retry-button"]}`) || target.closest(`.${batch_upload_file_list_common_file_index_module["preview-button"]}`) || target.closest('[class*="icon-close"]') || target.closest('button')) {
|
|
397215
|
+
return;
|
|
397216
|
+
}
|
|
397217
|
+
// 如果已经有 url,直接使用
|
|
397218
|
+
if (url) {
|
|
397219
|
+
const docViewerUrl = buildDocViewerUrl(url);
|
|
397220
|
+
window.open(docViewerUrl, '_blank');
|
|
397221
|
+
return;
|
|
397222
|
+
}
|
|
397223
|
+
if (!uri) {
|
|
397224
|
+
console.warn('File URI is not available, cannot open file');
|
|
397225
|
+
return;
|
|
397226
|
+
}
|
|
397227
|
+
const docViewerUrl = buildDocViewerUrl(uri);
|
|
397228
|
+
window.open(docViewerUrl, '_blank');
|
|
397229
|
+
};
|
|
396641
397230
|
return /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
|
|
396642
397231
|
ref: ref,
|
|
396643
397232
|
className: classnames_default()(batch_upload_file_list_common_file_index_module["normal-file"], !isSuccess && batch_upload_file_list_common_file_index_module["normal-file-not-success"], className),
|
|
397233
|
+
style: {
|
|
397234
|
+
cursor: 'pointer'
|
|
397235
|
+
},
|
|
397236
|
+
onClick: handleClick,
|
|
396644
397237
|
children: [
|
|
396645
397238
|
/*#__PURE__*/ (0,jsx_runtime.jsx)("img", {
|
|
396646
397239
|
src: getCommonFileIcon(fileTypeConfig === null || fileTypeConfig === void 0 ? void 0 : fileTypeConfig.fileType),
|
|
@@ -396675,10 +397268,24 @@ const CommonFile = (param)=>{
|
|
|
396675
397268
|
}),
|
|
396676
397269
|
isError ? /*#__PURE__*/ (0,jsx_runtime.jsx)(ui_button_Button, {
|
|
396677
397270
|
icon: /*#__PURE__*/ (0,jsx_runtime.jsx)(src_IconRefresh, {}),
|
|
396678
|
-
onClick:
|
|
397271
|
+
onClick: (e)=>{
|
|
397272
|
+
e.stopPropagation();
|
|
397273
|
+
onRetry();
|
|
397274
|
+
},
|
|
396679
397275
|
theme: "borderless",
|
|
396680
397276
|
className: batch_upload_file_list_common_file_index_module["retry-button"]
|
|
396681
397277
|
}) : null,
|
|
397278
|
+
isSuccess ? /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_Tooltip, {
|
|
397279
|
+
content: "预览",
|
|
397280
|
+
theme: "light",
|
|
397281
|
+
position: "top",
|
|
397282
|
+
children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ui_button_Button, {
|
|
397283
|
+
icon: /*#__PURE__*/ (0,jsx_runtime.jsx)(__webpack_exports__IconCozEye, {}),
|
|
397284
|
+
onClick: handlePreview,
|
|
397285
|
+
theme: "borderless",
|
|
397286
|
+
className: batch_upload_file_list_common_file_index_module["preview-button"]
|
|
397287
|
+
})
|
|
397288
|
+
}) : null,
|
|
396682
397289
|
!isError && !isSuccess && /*#__PURE__*/ (0,jsx_runtime.jsx)(ProgressMask, {
|
|
396683
397290
|
percent: percent
|
|
396684
397291
|
}),
|
|
@@ -398290,9 +398897,6 @@ const ChatAreaMain = (param)=>{
|
|
|
398290
398897
|
[src_chat_area_main_index_modules["chat-area-main-pc"]]: layout === common_Layout.PC,
|
|
398291
398898
|
[src_chat_area_main_index_modules["chat-area-main-mobile"]]: layout === common_Layout.MOBILE
|
|
398292
398899
|
}, classname),
|
|
398293
|
-
style: {
|
|
398294
|
-
justifyContent: !hasMessages ? 'center' : 'auto'
|
|
398295
|
-
},
|
|
398296
398900
|
children: [
|
|
398297
398901
|
/*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
|
|
398298
398902
|
className: src_chat_area_main_index_modules["header-node"],
|
|
@@ -398523,6 +399127,31 @@ class upload_plugin_UploadPlugin {
|
|
|
398523
399127
|
this.eventBus.emit('error', errorEvent);
|
|
398524
399128
|
},
|
|
398525
399129
|
onSuccess: (event)=>{
|
|
399130
|
+
// Event structure may contain additional properties from uploader library
|
|
399131
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Event structure varies
|
|
399132
|
+
const eventAny = event;
|
|
399133
|
+
// Try to get raw response from task if it exists
|
|
399134
|
+
let backendData = null;
|
|
399135
|
+
if (eventAny.task) {
|
|
399136
|
+
var _eventAny_task_response, _eventAny_task_responseData, _eventAny_task__response, _eventAny_task_rawResponse;
|
|
399137
|
+
backendData = ((_eventAny_task_response = eventAny.task.response) === null || _eventAny_task_response === void 0 ? void 0 : _eventAny_task_response.data) || ((_eventAny_task_responseData = eventAny.task.responseData) === null || _eventAny_task_responseData === void 0 ? void 0 : _eventAny_task_responseData.data) || ((_eventAny_task__response = eventAny.task._response) === null || _eventAny_task__response === void 0 ? void 0 : _eventAny_task__response.data) || ((_eventAny_task_rawResponse = eventAny.task.rawResponse) === null || _eventAny_task_rawResponse === void 0 ? void 0 : _eventAny_task_rawResponse.data) || eventAny.task.data;
|
|
399138
|
+
}
|
|
399139
|
+
if (!backendData) {
|
|
399140
|
+
var _eventAny_response, _eventAny_result;
|
|
399141
|
+
backendData = eventAny.data || ((_eventAny_response = eventAny.response) === null || _eventAny_response === void 0 ? void 0 : _eventAny_response.data) || eventAny.responseData || ((_eventAny_result = eventAny.result) === null || _eventAny_result === void 0 ? void 0 : _eventAny_result.data);
|
|
399142
|
+
}
|
|
399143
|
+
// If we found raw data, add uri and id to uploadResult
|
|
399144
|
+
if (backendData && eventAny.uploadResult) {
|
|
399145
|
+
if (backendData.uri) {
|
|
399146
|
+
eventAny.uploadResult.uri = backendData.uri;
|
|
399147
|
+
}
|
|
399148
|
+
if (backendData.id) {
|
|
399149
|
+
eventAny.uploadResult.id = backendData.id;
|
|
399150
|
+
}
|
|
399151
|
+
if (backendData.url) {
|
|
399152
|
+
eventAny.uploadResult.url = backendData.url;
|
|
399153
|
+
}
|
|
399154
|
+
}
|
|
398526
399155
|
const completeEvent = event;
|
|
398527
399156
|
this.eventBus.emit('complete', completeEvent);
|
|
398528
399157
|
}
|
|
@@ -398574,7 +399203,9 @@ class UploadController {
|
|
|
398574
399203
|
type: batch_file_upload_isImage(file) ? 'image' : 'object'
|
|
398575
399204
|
});
|
|
398576
399205
|
this.uploadPlugin.on('progress', (event)=>onProgress(event, fileId));
|
|
398577
|
-
this.uploadPlugin.on('complete', (event)=>
|
|
399206
|
+
this.uploadPlugin.on('complete', (event)=>{
|
|
399207
|
+
onComplete(event, fileId);
|
|
399208
|
+
});
|
|
398578
399209
|
this.uploadPlugin.on('error', (event)=>onError(event, fileId));
|
|
398579
399210
|
this.uploadPlugin.on('ready', (event)=>onReady(event, fileId));
|
|
398580
399211
|
}
|
|
@@ -403173,7 +403804,9 @@ const createBatchFileUploadStore = (mark)=>esm_create()(devtools((set, get)=>({
|
|
|
403173
403804
|
set(immer_produce((state)=>{
|
|
403174
403805
|
const baseFileData = {
|
|
403175
403806
|
percent: 0,
|
|
403807
|
+
fileId: null,
|
|
403176
403808
|
uri: null,
|
|
403809
|
+
url: null,
|
|
403177
403810
|
file,
|
|
403178
403811
|
id,
|
|
403179
403812
|
status: types_FileStatus.Uploading
|
|
@@ -406908,8 +407541,8 @@ const usePaginationRequest = (param)=>{
|
|
|
406908
407541
|
// eslint-disable-next-line @coze-arch/max-line-per-function
|
|
406909
407542
|
const useConversationList = (conversationListParams)=>{
|
|
406910
407543
|
const { pageSize = 20, initialPageNum = 1, order = 'updated_at' } = conversationListParams ?? {};
|
|
406911
|
-
const { chatConfig: { bot_id: botId, appInfo, type: chatType, auth: { connectorId } = {} } } =
|
|
406912
|
-
const { cozeApiSdk, currentConversationInfo, updateCurrentConversationInfo, conversations, updateConversations } =
|
|
407544
|
+
const { chatConfig: { bot_id: botId, appInfo, type: chatType, auth: { connectorId } = {} } } = context_useChatAppProps();
|
|
407545
|
+
const { cozeApiSdk, currentConversationInfo, updateCurrentConversationInfo, conversations, updateConversations } = context_useChatAppStore(shallow_useShallow((state)=>({
|
|
406913
407546
|
cozeApiSdk: state.cozeApi,
|
|
406914
407547
|
conversations: state.conversations,
|
|
406915
407548
|
updateCurrentConversationInfo: state.updateCurrentConversationInfo,
|
|
@@ -406936,7 +407569,7 @@ const useConversationList = (conversationListParams)=>{
|
|
|
406936
407569
|
}
|
|
406937
407570
|
setAppModeLoading(true);
|
|
406938
407571
|
try {
|
|
406939
|
-
var _res_data;
|
|
407572
|
+
var _res_data, _res_data1;
|
|
406940
407573
|
const res = await cozeApiSdk.get('/v1/workflow/conversations', {
|
|
406941
407574
|
app_id: appId,
|
|
406942
407575
|
workflow_id: workflowId,
|
|
@@ -406965,8 +407598,9 @@ const useConversationList = (conversationListParams)=>{
|
|
|
406965
407598
|
title: item.title
|
|
406966
407599
|
}
|
|
406967
407600
|
}));
|
|
406968
|
-
//
|
|
406969
|
-
|
|
407601
|
+
// 使用 API 返回的 has_more 字段来判断是否还有更多数据
|
|
407602
|
+
// 如果 API 没有返回 has_more,则根据返回的数据量判断(兼容旧版本)
|
|
407603
|
+
const hasMoreData = ((_res_data1 = res.data) === null || _res_data1 === void 0 ? void 0 : _res_data1.has_more) !== undefined ? res.data.has_more : convertedConversations.length >= pageSize;
|
|
406970
407604
|
if (beforeTimestamp === undefined) {
|
|
406971
407605
|
// 首次加载,替换数据
|
|
406972
407606
|
setAppModeData(convertedConversations);
|
|
@@ -406979,9 +407613,9 @@ const useConversationList = (conversationListParams)=>{
|
|
|
406979
407613
|
}
|
|
406980
407614
|
// 更新 before_updated_at:使用返回数据中最小的 updated_at(原始毫秒级时间戳)
|
|
406981
407615
|
if (convertedConversations.length > 0) {
|
|
406982
|
-
var
|
|
407616
|
+
var _res_data2;
|
|
406983
407617
|
// 从原始数据中找到最小的 updated_at(毫秒级)
|
|
406984
|
-
const minUpdatedAtMs = Math.min(...(((
|
|
407618
|
+
const minUpdatedAtMs = Math.min(...(((_res_data2 = res.data) === null || _res_data2 === void 0 ? void 0 : _res_data2.conversations) || []).map((item)=>item.updated_at || 0));
|
|
406985
407619
|
if (minUpdatedAtMs > 0) {
|
|
406986
407620
|
setBeforeUpdatedAt(minUpdatedAtMs);
|
|
406987
407621
|
} else {
|
|
@@ -406991,6 +407625,7 @@ const useConversationList = (conversationListParams)=>{
|
|
|
406991
407625
|
// 如果没有返回数据,说明没有更多了
|
|
406992
407626
|
setAppModeHasMore(false);
|
|
406993
407627
|
}
|
|
407628
|
+
// 根据 API 返回的 has_more 字段设置状态
|
|
406994
407629
|
setAppModeHasMore(hasMoreData);
|
|
406995
407630
|
} catch (e) {
|
|
406996
407631
|
console.error(e);
|
|
@@ -407010,8 +407645,9 @@ const useConversationList = (conversationListParams)=>{
|
|
|
407010
407645
|
appModeLoading
|
|
407011
407646
|
]);
|
|
407012
407647
|
// App 模式:首次加载
|
|
407648
|
+
// 只在列表为空且 hasMore 为 true 时才加载,避免 has_more: false 时重复请求
|
|
407013
407649
|
(0,react.useEffect)(()=>{
|
|
407014
|
-
if (isAppType && cozeApiSdk && hasValidId && appModeData.length === 0) {
|
|
407650
|
+
if (isAppType && cozeApiSdk && hasValidId && appModeData.length === 0 && appModeHasMore && !appModeLoading) {
|
|
407015
407651
|
loadAppModeConversations();
|
|
407016
407652
|
}
|
|
407017
407653
|
}, [
|
|
@@ -407019,9 +407655,12 @@ const useConversationList = (conversationListParams)=>{
|
|
|
407019
407655
|
cozeApiSdk,
|
|
407020
407656
|
hasValidId,
|
|
407021
407657
|
loadAppModeConversations,
|
|
407022
|
-
appModeData.length
|
|
407658
|
+
appModeData.length,
|
|
407659
|
+
appModeHasMore,
|
|
407660
|
+
appModeLoading
|
|
407023
407661
|
]);
|
|
407024
407662
|
// App 模式:loadMore 函数
|
|
407663
|
+
// 只在 has_more 为 true 时才发送请求
|
|
407025
407664
|
const appModeLoadMore = (0,react.useCallback)(async ()=>{
|
|
407026
407665
|
if (appModeHasMore && !appModeLoading && beforeUpdatedAt !== undefined) {
|
|
407027
407666
|
await loadAppModeConversations(beforeUpdatedAt);
|
|
@@ -407802,7 +408441,7 @@ var conversation_list_index_module_update = injectStylesIntoStyleTag_default()(c
|
|
|
407802
408441
|
const ConversationList = /*#__PURE__*/ (0,react.forwardRef)(// eslint-disable-next-line @coze-arch/max-line-per-function
|
|
407803
408442
|
(param, ref)=>{
|
|
407804
408443
|
let { onRename, onDelete, loading, groupedConversations, conversations, hasMore, loadMore, removeConversation } = param;
|
|
407805
|
-
const { currentConversationInfo, updateCurrentConversationInfo, cozeApi, updateConversations } =
|
|
408444
|
+
const { currentConversationInfo, updateCurrentConversationInfo, cozeApi, updateConversations } = context_useChatAppStore(shallow_useShallow((state)=>({
|
|
407806
408445
|
currentConversationInfo: state.currentConversationInfo,
|
|
407807
408446
|
updateCurrentConversationInfo: state.updateCurrentConversationInfo,
|
|
407808
408447
|
cozeApi: state.cozeApi,
|
|
@@ -407811,7 +408450,7 @@ const ConversationList = /*#__PURE__*/ (0,react.forwardRef)(// eslint-disable-ne
|
|
|
407811
408450
|
const conversationRef = (0,react.useRef)();
|
|
407812
408451
|
const [addLoading, setAddLoading] = (0,react.useState)(false);
|
|
407813
408452
|
const isCreatingRef = (0,react.useRef)(false);
|
|
407814
|
-
const { layout, chatConfig: { type: chatType } } =
|
|
408453
|
+
const { layout, chatConfig: { type: chatType } } = context_useChatAppProps();
|
|
407815
408454
|
// 确保 conversationRef 与 currentConversationInfo 保持同步
|
|
407816
408455
|
// 这样在重载页面后,getConversationInfo 也能返回正确的值
|
|
407817
408456
|
// 注意:即使 id 为空字符串,也要更新 conversationRef,以便 getConversationInfo 返回空会话
|
|
@@ -408140,13 +408779,13 @@ var conversation_list_sider_index_module_update = injectStylesIntoStyleTag_defau
|
|
|
408140
408779
|
/* eslint-disable @coze-arch/max-line-per-function -- This component handles complex conversation list sidebar logic */ const ConversationListSider = /*#__PURE__*/ (0,react.forwardRef)((param, ref)=>{
|
|
408141
408780
|
let { children } = param;
|
|
408142
408781
|
const conversationListRef = (0,react.useRef)(null);
|
|
408143
|
-
const { currentConversationInfo, updateConversations, updateCurrentConversationInfo, cozeApi } =
|
|
408782
|
+
const { currentConversationInfo, updateConversations, updateCurrentConversationInfo, cozeApi } = context_useChatAppStore(shallow_useShallow((state)=>({
|
|
408144
408783
|
currentConversationInfo: state.currentConversationInfo,
|
|
408145
408784
|
updateConversations: state.updateConversations,
|
|
408146
408785
|
updateCurrentConversationInfo: state.updateCurrentConversationInfo,
|
|
408147
408786
|
cozeApi: state.cozeApi
|
|
408148
408787
|
})));
|
|
408149
|
-
const { chatConfig: { type: chatType } } =
|
|
408788
|
+
const { chatConfig: { type: chatType } } = context_useChatAppProps();
|
|
408150
408789
|
const { loading, conversations, hasMore, loadMore, removeConversation } = useConversationList();
|
|
408151
408790
|
const groupedConversations = useGroupedConversations(conversations);
|
|
408152
408791
|
const [isModalLoading, setIsModalLoading] = (0,react.useState)(false);
|
|
@@ -408814,7 +409453,7 @@ const ChatPropsProvider = (param)=>{
|
|
|
408814
409453
|
}) : children
|
|
408815
409454
|
});
|
|
408816
409455
|
};
|
|
408817
|
-
const
|
|
409456
|
+
const context_useChatAppProps = ()=>{
|
|
408818
409457
|
const { appProps } = (0,react.useContext)(ChatPropsContext);
|
|
408819
409458
|
const { chatConfig = {
|
|
408820
409459
|
conversation_id: index_browser_nanoid(),
|
|
@@ -408828,7 +409467,7 @@ const useChatAppProps = ()=>{
|
|
|
408828
409467
|
enableReplacePrologueNicknameWithVar
|
|
408829
409468
|
};
|
|
408830
409469
|
};
|
|
408831
|
-
const
|
|
409470
|
+
const context_useChatAppStore = (selector)=>{
|
|
408832
409471
|
const { store } = (0,react.useContext)(ChatPropsContext);
|
|
408833
409472
|
if (!store) {
|
|
408834
409473
|
throw ChatSdkError.create(error_SDKErrorCode.StoreProvider);
|
|
@@ -408854,8 +409493,8 @@ const useChatAppStore = (selector)=>{
|
|
|
408854
409493
|
*/
|
|
408855
409494
|
const useIsShowBackground = ()=>{
|
|
408856
409495
|
var _backgroundInfo_mobile_background_image;
|
|
408857
|
-
const backgroundInfo =
|
|
408858
|
-
const { isCustomBackground } =
|
|
409496
|
+
const backgroundInfo = context_useChatAppStore((s)=>s.backgroundInfo);
|
|
409497
|
+
const { isCustomBackground } = context_useChatAppProps();
|
|
408859
409498
|
// 自定义背景图,或者背景图有数据,则有背景状态
|
|
408860
409499
|
return isCustomBackground || !!(backgroundInfo === null || backgroundInfo === void 0 ? void 0 : (_backgroundInfo_mobile_background_image = backgroundInfo.mobile_background_image) === null || _backgroundInfo_mobile_background_image === void 0 ? void 0 : _backgroundInfo_mobile_background_image.origin_image_url) || false;
|
|
408861
409500
|
};
|
|
@@ -412906,13 +413545,23 @@ const createSDKUploadPluginClass = (param)=>{
|
|
|
412906
413545
|
this.file = props.file;
|
|
412907
413546
|
this.fileType = props.type;
|
|
412908
413547
|
this.upload().then((meta)=>{
|
|
413548
|
+
// Backend returns: { uri: "xxx", id: "yyy", url: "zzz" }
|
|
413549
|
+
// meta.uri should be the real URI (not the id)
|
|
413550
|
+
// meta.id should be the backend file ID
|
|
413551
|
+
// UploadResult structure requires dynamic properties, using type assertion
|
|
413552
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- UploadResult structure requires dynamic properties
|
|
413553
|
+
const uploadResult = {
|
|
413554
|
+
Uri: meta.uri,
|
|
413555
|
+
Url: meta.url
|
|
413556
|
+
};
|
|
413557
|
+
// Add id if available
|
|
413558
|
+
if (meta.id) {
|
|
413559
|
+
uploadResult.Id = meta.id;
|
|
413560
|
+
}
|
|
412909
413561
|
this.eventBus.emit('complete', {
|
|
412910
413562
|
percent: 100,
|
|
412911
413563
|
status: types_FileStatus.Success,
|
|
412912
|
-
uploadResult
|
|
412913
|
-
Uri: meta.uri,
|
|
412914
|
-
Url: meta.url
|
|
412915
|
-
},
|
|
413564
|
+
uploadResult,
|
|
412916
413565
|
type: 'success'
|
|
412917
413566
|
});
|
|
412918
413567
|
}).catch((err)=>{
|
|
@@ -413011,7 +413660,7 @@ studioOpenClientReporter.init(studio_open_client_reporter_slardarInstance);
|
|
|
413011
413660
|
|
|
413012
413661
|
const useUpdateConversationNameByMessage = ()=>{
|
|
413013
413662
|
const currentConversationNameRef = (0,react.useRef)();
|
|
413014
|
-
const { updateCurrentConversationNameByMessage, currentConversationInfo } =
|
|
413663
|
+
const { updateCurrentConversationNameByMessage, currentConversationInfo } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
413015
413664
|
updateCurrentConversationNameByMessage: s.updateCurrentConversationNameByMessage,
|
|
413016
413665
|
currentConversationInfo: s.currentConversationInfo
|
|
413017
413666
|
})));
|
|
@@ -413055,7 +413704,7 @@ const useUpdateConversationNameByMessage = ()=>{
|
|
|
413055
413704
|
|
|
413056
413705
|
|
|
413057
413706
|
const useUserInfo = ()=>{
|
|
413058
|
-
const userInfo =
|
|
413707
|
+
const userInfo = context_useChatAppStore((s)=>s.userInfo);
|
|
413059
413708
|
return (0,react.useMemo)(()=>{
|
|
413060
413709
|
const openUserInfo = userInfo;
|
|
413061
413710
|
if (!openUserInfo || !openUserInfo.id) {
|
|
@@ -416016,9 +416665,9 @@ class CozeApiCustom extends CozeAPI {
|
|
|
416016
416665
|
|
|
416017
416666
|
|
|
416018
416667
|
const useApiClient = ()=>{
|
|
416019
|
-
const { debug } =
|
|
416668
|
+
const { debug } = context_useChatAppProps();
|
|
416020
416669
|
const { token = '', refreshToken: refreshTokenRaw, setToken, setCozeApi, // 从 store 中获取 apiUrl
|
|
416021
|
-
apiUrl } =
|
|
416670
|
+
apiUrl } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
416022
416671
|
token: s.token,
|
|
416023
416672
|
setToken: s.setToken,
|
|
416024
416673
|
refreshToken: s.refreshToken,
|
|
@@ -416145,9 +416794,20 @@ const useUploadFileApi = ()=>{
|
|
|
416145
416794
|
const result = await (cozeApiSdk === null || cozeApiSdk === void 0 ? void 0 : cozeApiSdk.files.upload({
|
|
416146
416795
|
file
|
|
416147
416796
|
}));
|
|
416797
|
+
// Backend response structure may vary, using type assertion for flexibility
|
|
416798
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Backend response structure varies
|
|
416799
|
+
const resultAny = result;
|
|
416800
|
+
// Backend returns: { data: { uri: "xxx", id: "yyy", url: "zzz" } }
|
|
416801
|
+
// Or possibly: { id: "yyy", uri: "xxx", url: "zzz" }
|
|
416802
|
+
// We need to extract both uri and id correctly
|
|
416803
|
+
const backendData = (resultAny === null || resultAny === void 0 ? void 0 : resultAny.data) || resultAny;
|
|
416804
|
+
const uri = (backendData === null || backendData === void 0 ? void 0 : backendData.uri) || ''; // Real URI from backend
|
|
416805
|
+
const id = (backendData === null || backendData === void 0 ? void 0 : backendData.id) || (resultAny === null || resultAny === void 0 ? void 0 : resultAny.id) || ''; // Backend file ID
|
|
416806
|
+
const url = (backendData === null || backendData === void 0 ? void 0 : backendData.url) || (resultAny === null || resultAny === void 0 ? void 0 : resultAny.url) || '';
|
|
416148
416807
|
return {
|
|
416149
|
-
uri:
|
|
416150
|
-
url
|
|
416808
|
+
uri: uri || id,
|
|
416809
|
+
url,
|
|
416810
|
+
id: id || undefined
|
|
416151
416811
|
};
|
|
416152
416812
|
}, [
|
|
416153
416813
|
cozeApiSdk
|
|
@@ -416485,7 +417145,7 @@ const messageConverterToCoze = new MessageConverseToCoze();
|
|
|
416485
417145
|
|
|
416486
417146
|
const useMessageList = ()=>{
|
|
416487
417147
|
const getMessageListByPairs = useGetMessageListByPairs();
|
|
416488
|
-
const { chatConfig } =
|
|
417148
|
+
const { chatConfig } = context_useChatAppProps();
|
|
416489
417149
|
const { bot_id: botId } = chatConfig || {};
|
|
416490
417150
|
const { refMessageListLeft } = useChatCozeSdk();
|
|
416491
417151
|
return (0,react.useMemo)(()=>{
|
|
@@ -416716,14 +417376,14 @@ const getCustomInitInfo = async (param)=>{
|
|
|
416716
417376
|
};
|
|
416717
417377
|
const useRequestInit = ()=>{
|
|
416718
417378
|
var _chatConfig_auth;
|
|
416719
|
-
const { chatConfig, openRequestInit, defaultHistoryMessage = [], onDefaultHistoryClear } =
|
|
417379
|
+
const { chatConfig, openRequestInit, defaultHistoryMessage = [], onDefaultHistoryClear } = context_useChatAppProps();
|
|
416720
417380
|
const { cozeApiSdk } = useChatCozeSdk();
|
|
416721
|
-
const setInitError =
|
|
416722
|
-
const setDefaultInputMode =
|
|
416723
|
-
const updateShortcuts =
|
|
416724
|
-
const setIsStartBotVoiceCall =
|
|
416725
|
-
const updateBackgroundInfo =
|
|
416726
|
-
const { currentConversationInfo, updateCurrentConversationInfo, conversations } =
|
|
417381
|
+
const setInitError = context_useChatAppStore((s)=>s.setInitError);
|
|
417382
|
+
const setDefaultInputMode = context_useChatAppStore((s)=>s.setDefaultInputMode);
|
|
417383
|
+
const updateShortcuts = context_useChatAppStore((s)=>s.updateShortcuts);
|
|
417384
|
+
const setIsStartBotVoiceCall = context_useChatAppStore((s)=>s.setIsStartBotVoiceCall);
|
|
417385
|
+
const updateBackgroundInfo = context_useChatAppStore((s)=>s.updateBackgroundInfo);
|
|
417386
|
+
const { currentConversationInfo, updateCurrentConversationInfo, conversations } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
416727
417387
|
currentConversationInfo: s.currentConversationInfo,
|
|
416728
417388
|
updateCurrentConversationInfo: s.updateCurrentConversationInfo,
|
|
416729
417389
|
conversations: s.conversations
|
|
@@ -416911,7 +417571,7 @@ const useRequestInit = ()=>{
|
|
|
416911
417571
|
|
|
416912
417572
|
|
|
416913
417573
|
const useClearMessageContextAdapter = ()=>{
|
|
416914
|
-
const { chatConfig: { type: chatType } } =
|
|
417574
|
+
const { chatConfig: { type: chatType } } = context_useChatAppProps();
|
|
416915
417575
|
return (0,react.useMemo)(()=>{
|
|
416916
417576
|
const isAppType = chatType === client_ChatType.APP;
|
|
416917
417577
|
const baseUrl = isAppType ? '/v1/workflow/conversations/:conversation_id/clear' : '/v1/conversations/:conversation_id/clear';
|
|
@@ -417208,10 +417868,12 @@ class MessageConverterToSdk {
|
|
|
417208
417868
|
case types_ContentType.Image:
|
|
417209
417869
|
{
|
|
417210
417870
|
var _item_image_image_ori;
|
|
417871
|
+
// Use id (backend file ID) if available, fallback to key (URI) for backward compatibility
|
|
417872
|
+
const fileId = item.image.id || item.image.key;
|
|
417211
417873
|
return {
|
|
417212
417874
|
type: 'image',
|
|
417213
|
-
file_id:
|
|
417214
|
-
file_url: isNeedFileUrl || !
|
|
417875
|
+
file_id: fileId,
|
|
417876
|
+
file_url: isNeedFileUrl || !fileId ? (_item_image_image_ori = item.image.image_ori) === null || _item_image_image_ori === void 0 ? void 0 : _item_image_image_ori.url : undefined,
|
|
417215
417877
|
// @ts-expect-error -- linter-disable-autofix
|
|
417216
417878
|
is_refer: item.is_refer || undefined
|
|
417217
417879
|
};
|
|
@@ -417219,9 +417881,11 @@ class MessageConverterToSdk {
|
|
|
417219
417881
|
case types_ContentType.File:
|
|
417220
417882
|
{
|
|
417221
417883
|
var _item_file;
|
|
417884
|
+
// Use file_id (backend file ID) if available, fallback to file_key (URI) for backward compatibility
|
|
417885
|
+
const fileId = item.file.file_id || item.file.file_key;
|
|
417222
417886
|
return {
|
|
417223
417887
|
type: 'file',
|
|
417224
|
-
file_id:
|
|
417888
|
+
file_id: fileId,
|
|
417225
417889
|
file_url: isNeedFileUrl ? (_item_file = item.file) === null || _item_file === void 0 ? void 0 : _item_file.file_url : undefined,
|
|
417226
417890
|
// @ts-expect-error -- linter-disable-autofix
|
|
417227
417891
|
is_refer: item.is_refer || undefined
|
|
@@ -419238,8 +419902,8 @@ class MessageParser {
|
|
|
419238
419902
|
|
|
419239
419903
|
/* eslint-disable @coze-arch/max-line-per-function -- This adapter function handles complex message sending logic */ const useSendMessageAdapter = (userInfo, refChatFunc)=>{
|
|
419240
419904
|
var _chatConfig_auth;
|
|
419241
|
-
const { debug, chatConfig } =
|
|
419242
|
-
const { shortcuts, apiUrl, updateConversations, updateCurrentConversationInfo, currentConversationInfo, conversations, cozeApi } =
|
|
419905
|
+
const { debug, chatConfig } = context_useChatAppProps();
|
|
419906
|
+
const { shortcuts, apiUrl, updateConversations, updateCurrentConversationInfo, currentConversationInfo, conversations, cozeApi } = context_useChatAppStore(shallow_useShallow((state)=>({
|
|
419243
419907
|
shortcuts: state.shortcuts,
|
|
419244
419908
|
apiUrl: state.apiUrl,
|
|
419245
419909
|
updateConversations: state.updateConversations,
|
|
@@ -419616,7 +420280,7 @@ class MessageParser {
|
|
|
419616
420280
|
const useClearHistoryAdapter = (param)=>{
|
|
419617
420281
|
let { refChatFunc } = param;
|
|
419618
420282
|
var _chatConfig_auth;
|
|
419619
|
-
const { chatConfig } =
|
|
420283
|
+
const { chatConfig } = context_useChatAppProps();
|
|
419620
420284
|
const refConnectorId = (0,react.useRef)('');
|
|
419621
420285
|
refConnectorId.current = (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_auth = chatConfig.auth) === null || _chatConfig_auth === void 0 ? void 0 : _chatConfig_auth.connectorId) || '';
|
|
419622
420286
|
return (0,react.useMemo)(()=>{
|
|
@@ -419680,7 +420344,7 @@ const useClearHistoryAdapter = (param)=>{
|
|
|
419680
420344
|
|
|
419681
420345
|
|
|
419682
420346
|
const useCommonOnBeforeRequestHooks = ()=>{
|
|
419683
|
-
const { debug } =
|
|
420347
|
+
const { debug } = context_useChatAppProps();
|
|
419684
420348
|
return [
|
|
419685
420349
|
// 去除无用的头部
|
|
419686
420350
|
(requestConfig)=>{
|
|
@@ -419805,7 +420469,7 @@ const useCoreManager = (param)=>{
|
|
|
419805
420469
|
const userInfo = useUserInfo();
|
|
419806
420470
|
const { refreshToken } = useChatCozeSdk();
|
|
419807
420471
|
// 获取 apiUrl
|
|
419808
|
-
const { apiUrl } =
|
|
420472
|
+
const { apiUrl } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
419809
420473
|
apiUrl: s.apiUrl
|
|
419810
420474
|
})));
|
|
419811
420475
|
const clearMessageContextAdapter = useClearMessageContextAdapter();
|
|
@@ -419817,7 +420481,7 @@ const useCoreManager = (param)=>{
|
|
|
419817
420481
|
const commonOnAfterResponseHooks = useCommonOnAfterResponseHooks(refreshToken);
|
|
419818
420482
|
const commonErrorResponseHooks = useCommonErrorResponseHooks(refreshToken);
|
|
419819
420483
|
const messageListAdapter = useMessageList();
|
|
419820
|
-
const { requestManagerOptions } =
|
|
420484
|
+
const { requestManagerOptions } = context_useChatAppProps();
|
|
419821
420485
|
const breakMessageAdapter = useBreakMessage();
|
|
419822
420486
|
// 计算最终的 baseURL
|
|
419823
420487
|
const finalBaseURL = apiUrl || openApiHostByRegionWithToken;
|
|
@@ -419871,7 +420535,7 @@ const useCoreManager = (param)=>{
|
|
|
419871
420535
|
|
|
419872
420536
|
const useCoreOverrideConfig = (param)=>{
|
|
419873
420537
|
let { refChatFunc } = param;
|
|
419874
|
-
const { chatConfig } =
|
|
420538
|
+
const { chatConfig } = context_useChatAppProps();
|
|
419875
420539
|
const { tokenManager } = useChatCozeSdk();
|
|
419876
420540
|
const requestManagerOptions = useCoreManager({
|
|
419877
420541
|
refChatFunc
|
|
@@ -420025,10 +420689,10 @@ const services_life_cycle_bizLifeCycleServiceGenerator = (plugin)=>({
|
|
|
420025
420689
|
|
|
420026
420690
|
const useMessageGroupFooterInfo = (messageGroup)=>{
|
|
420027
420691
|
var _messageInfo_extra_info;
|
|
420028
|
-
const feedbackInfo =
|
|
420692
|
+
const feedbackInfo = context_useChatAppStore((s)=>s.feedbackInfo);
|
|
420029
420693
|
const { useMessagesStore } = use_chat_area_context_useChatAreaStoreSet();
|
|
420030
420694
|
const { findMessage } = useMessagesStore.getState();
|
|
420031
|
-
const lastGroupFeedbackInfo =
|
|
420695
|
+
const lastGroupFeedbackInfo = context_useChatAppStore((s)=>s.lastGroupFeedbackInfo);
|
|
420032
420696
|
const { messageId } = lastGroupFeedbackInfo;
|
|
420033
420697
|
const messageInfo = findMessage(messageId || '');
|
|
420034
420698
|
// @ts-expect-error -- linter-disable-autofix, 新添加参数,接口未支持
|
|
@@ -421705,7 +422369,7 @@ const BotTriggerConfigButtonGroup = (param)=>{
|
|
|
421705
422369
|
const useCurMessageInfo = ()=>{
|
|
421706
422370
|
var _chatConfig_ui_chatBot, _chatConfig_ui;
|
|
421707
422371
|
const { message } = message_box_useMessageBoxContext();
|
|
421708
|
-
const { chatConfig } =
|
|
422372
|
+
const { chatConfig } = context_useChatAppProps();
|
|
421709
422373
|
// @ts-expect-error -- linter-disable-autofix, 新添加参数,接口未支持
|
|
421710
422374
|
const cozeApiMessageId = message.extra_info.coze_api_message_id;
|
|
421711
422375
|
// @ts-expect-error -- linter-disable-autofix, 新添加参数,接口未支持
|
|
@@ -421812,7 +422476,7 @@ const delete_message_DeleteMessage = (param)=>{
|
|
|
421812
422476
|
const { useGlobalInitStore } = storeSet;
|
|
421813
422477
|
const { groupId } = message_box_useMessageBoxContext();
|
|
421814
422478
|
const isDeleteMessageLock = use_is_delete_message_lock_useIsDeleteMessageLock(groupId);
|
|
421815
|
-
const { chatConfig } =
|
|
422479
|
+
const { chatConfig } = context_useChatAppProps();
|
|
421816
422480
|
const deleteMessage = useDeleteMessage();
|
|
421817
422481
|
const conversationId = useGlobalInitStore((state)=>state.conversationId);
|
|
421818
422482
|
const { messageId, cozeApiMessageId, isShowDelete } = useCurMessageInfo();
|
|
@@ -421913,7 +422577,7 @@ const useMessageHoverInfo = ()=>{
|
|
|
421913
422577
|
const UIKitMessageBoxHoverSlot = ()=>{
|
|
421914
422578
|
const { meta } = message_box_useMessageBoxContext();
|
|
421915
422579
|
const { message } = message_box_useMessageBoxContext();
|
|
421916
|
-
const { readonly } =
|
|
422580
|
+
const { readonly } = context_useChatAppProps();
|
|
421917
422581
|
const isLastGroupMessage = meta.isGroupLastMessage && meta.isFromLatestGroup && (message === null || message === void 0 ? void 0 : message.type) === 'answer';
|
|
421918
422582
|
if (isLastGroupMessage || readonly) {
|
|
421919
422583
|
/*
|
|
@@ -422091,7 +422755,7 @@ const UIKitMessageBoxFooter = (param)=>{
|
|
|
422091
422755
|
const { meta } = message_box_useMessageBoxContext();
|
|
422092
422756
|
const { message } = message_box_useMessageBoxContext();
|
|
422093
422757
|
const { useWaitingStore } = use_chat_area_context_useChatAreaStoreSet();
|
|
422094
|
-
const { readonly } =
|
|
422758
|
+
const { readonly } = context_useChatAppProps();
|
|
422095
422759
|
const waiting = useWaitingStore((state)=>!!state.waiting);
|
|
422096
422760
|
const isAnswerMessage = message.type === 'answer';
|
|
422097
422761
|
const isLastGroupMessage = meta.isGroupLastMessage && meta.isFromLatestGroup;
|
|
@@ -422582,8 +423246,8 @@ const createChatBackgroundPlugin = ()=>{
|
|
|
422582
423246
|
|
|
422583
423247
|
const useBgBackgroundPlugin = ()=>{
|
|
422584
423248
|
const { ChatBackgroundPlugin, chatBackgroundEvent } = (0,react.useMemo)(()=>createChatBackgroundPlugin(), []);
|
|
422585
|
-
const { isCustomBackground } =
|
|
422586
|
-
const backgroundInfo =
|
|
423249
|
+
const { isCustomBackground } = context_useChatAppProps();
|
|
423250
|
+
const backgroundInfo = context_useChatAppStore((s)=>s.backgroundInfo);
|
|
422587
423251
|
const backgroundInfoToShow = isCustomBackground ? undefined : backgroundInfo;
|
|
422588
423252
|
(0,react.useEffect)(()=>{
|
|
422589
423253
|
// 监听用户设置背景图,将更新的背景图信息传入插件
|
|
@@ -422643,8 +423307,8 @@ const useBgBackgroundPlugin = ()=>{
|
|
|
422643
423307
|
const ChatProviderFuncComp = /*#__PURE__*/ (0,react.forwardRef)((param, ref)=>{
|
|
422644
423308
|
let { children } = param;
|
|
422645
423309
|
var _chatConfig_ui_conversations, _chatConfig_ui;
|
|
422646
|
-
const { chatConfig } =
|
|
422647
|
-
const { updateCurrentConversationInfo, currentConversationInfo, updateConversations, conversations } =
|
|
423310
|
+
const { chatConfig } = context_useChatAppProps();
|
|
423311
|
+
const { updateCurrentConversationInfo, currentConversationInfo, updateConversations, conversations } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
422648
423312
|
updateCurrentConversationInfo: s.updateCurrentConversationInfo,
|
|
422649
423313
|
currentConversationInfo: s.currentConversationInfo,
|
|
422650
423314
|
updateConversations: s.updateConversations,
|
|
@@ -422759,12 +423423,12 @@ const ChatProviderImpl = (param)=>{
|
|
|
422759
423423
|
var _chatConfig_ui, _chatConfig_appInfo, _chatConfig_ui_chatBot, _chatConfig_ui1;
|
|
422760
423424
|
const refLastIsError = (0,react.useRef)(false);
|
|
422761
423425
|
const { refreshToken } = useChatCozeSdk();
|
|
422762
|
-
const { initError, setInitError } =
|
|
423426
|
+
const { initError, setInitError } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
422763
423427
|
initError: s.initError,
|
|
422764
423428
|
setInitError: s.setInitError
|
|
422765
423429
|
})));
|
|
422766
423430
|
const refChatFunc = (0,react.useRef)();
|
|
422767
|
-
const { chatConfig, onImageClick, initErrorFallbackFC: ErrorFallback } =
|
|
423431
|
+
const { chatConfig, onImageClick, initErrorFallbackFC: ErrorFallback } = context_useChatAppProps();
|
|
422768
423432
|
const userInfoRaw = useUserInfo();
|
|
422769
423433
|
// 确保 userInfo 始终有效,即使 useUserInfo 返回 null(虽然不应该)
|
|
422770
423434
|
const userInfo = userInfoRaw && userInfoRaw.id ? userInfoRaw : {
|
|
@@ -422933,8 +423597,8 @@ const ChatProvider = (param)=>{
|
|
|
422933
423597
|
const provider_ChatProvider = (param)=>{
|
|
422934
423598
|
let { children, plugins } = param;
|
|
422935
423599
|
var _chatConfig_extra;
|
|
422936
|
-
const { chatConfig, onImageClick, onThemeChange } =
|
|
422937
|
-
const setInitError =
|
|
423600
|
+
const { chatConfig, onImageClick, onThemeChange } = context_useChatAppProps();
|
|
423601
|
+
const setInitError = context_useChatAppStore((s)=>s.setInitError);
|
|
422938
423602
|
// plugin初始化
|
|
422939
423603
|
const commonChatPlugin = getChatCommonPlugin({
|
|
422940
423604
|
onImageClick,
|
|
@@ -434413,7 +435077,7 @@ const shortcut_bar_ShortcutBar = (param)=>{
|
|
|
434413
435077
|
var _shortcuts_at;
|
|
434414
435078
|
const activeShortcutRef = (0,react.useRef)(undefined);
|
|
434415
435079
|
const showBackground = useIsShowBackground();
|
|
434416
|
-
const shortcuts =
|
|
435080
|
+
const shortcuts = context_useChatAppStore((store)=>store.shortcuts);
|
|
434417
435081
|
const defaultId = (_shortcuts_at = shortcuts.at(0)) === null || _shortcuts_at === void 0 ? void 0 : _shortcuts_at.command_id;
|
|
434418
435082
|
if (!(shortcuts === null || shortcuts === void 0 ? void 0 : shortcuts.length)) {
|
|
434419
435083
|
return null;
|
|
@@ -434523,7 +435187,7 @@ const IconAddNewConversation = (param)=>{
|
|
|
434523
435187
|
|
|
434524
435188
|
const useChatOpInfo = ()=>{
|
|
434525
435189
|
var _chatConfig_ui_header, _chatConfig_ui;
|
|
434526
|
-
const { chatConfig } =
|
|
435190
|
+
const { chatConfig } = context_useChatAppProps();
|
|
434527
435191
|
const chatInputLeftOps = [];
|
|
434528
435192
|
const headerTopLeftOps = [];
|
|
434529
435193
|
console.log('useChatOpInfo:', chatConfig);
|
|
@@ -434565,7 +435229,7 @@ const useChatOpInfo = ()=>{
|
|
|
434565
435229
|
};
|
|
434566
435230
|
const useChatChatButtonInfo = (opList)=>{
|
|
434567
435231
|
const { isClearHistoryButtonDisabled, isClearContextButtonDisabled } = useBuiltinButtonStatus({});
|
|
434568
|
-
const { readonly } =
|
|
435232
|
+
const { readonly } = context_useChatAppProps();
|
|
434569
435233
|
const { clearHistory } = useChatAreaController();
|
|
434570
435234
|
const clearContext = useClearContext();
|
|
434571
435235
|
const buttonList = (0,react.useMemo)(()=>opList.map((item)=>{
|
|
@@ -434678,7 +435342,7 @@ const MoreBtn = (param)=>{
|
|
|
434678
435342
|
let { buttonList } = param;
|
|
434679
435343
|
const showBackground = useIsShowBackground();
|
|
434680
435344
|
const [visible, setVisible] = (0,react.useState)(false);
|
|
434681
|
-
const { readonly } =
|
|
435345
|
+
const { readonly } = context_useChatAppProps();
|
|
434682
435346
|
(0,react.useEffect)(()=>{
|
|
434683
435347
|
document.addEventListener('click', ()=>{
|
|
434684
435348
|
setVisible(false);
|
|
@@ -434728,7 +435392,7 @@ const ChatInputLeftSlot = ()=>{
|
|
|
434728
435392
|
var _chatConfig_ui_base, _chatConfig_ui;
|
|
434729
435393
|
const { chatInputLeftOps } = useChatOpInfo();
|
|
434730
435394
|
const showBackground = useIsShowBackground();
|
|
434731
|
-
const { chatConfig } =
|
|
435395
|
+
const { chatConfig } = context_useChatAppProps();
|
|
434732
435396
|
const isMobile = ((_chatConfig_ui = chatConfig.ui) === null || _chatConfig_ui === void 0 ? void 0 : (_chatConfig_ui_base = _chatConfig_ui.base) === null || _chatConfig_ui_base === void 0 ? void 0 : _chatConfig_ui_base.layout) === client_Layout.MOBILE;
|
|
434733
435397
|
const buttonClass = showBackground ? '!coz-fg-images-white' : '';
|
|
434734
435398
|
const buttonList = useChatChatButtonInfo(chatInputLeftOps);
|
|
@@ -434824,10 +435488,10 @@ const StudioChatArea = (param)=>{
|
|
|
434824
435488
|
let { coreAreaClassName, className, showInputArea = true, inputPlaceholder, inputNativeCallbacks, messageGroupListClassName, renderChatInputTopSlot, renderChatInputRightActions, isShowClearContextDivider, headerNode, messageMaxWidth, isMiniScreen, enableMultimodalUpload = false, uiKitCustomComponents, contentBox, getMessageRenderIndex, inputMode, onboardingPrologue, showOnboardingBotInfo, showOnboardingSuggestions } = param;
|
|
434825
435489
|
var _chatConfig_ui_chatBot, _chatConfig_ui, _chatConfig_ui_chatBot1, _chatConfig_ui1, _chatConfig_ui_footer, _chatConfig_ui2;
|
|
434826
435490
|
const initStatus = useInitStatus();
|
|
434827
|
-
const { layout, onInitStateChange, chatConfig } =
|
|
435491
|
+
const { layout, onInitStateChange, chatConfig } = context_useChatAppProps();
|
|
434828
435492
|
const refContainer = (0,react.useRef)(null);
|
|
434829
|
-
const { readonly } =
|
|
434830
|
-
const currentConversationInfo =
|
|
435493
|
+
const { readonly } = context_useChatAppProps();
|
|
435494
|
+
const currentConversationInfo = context_useChatAppStore((state)=>state.currentConversationInfo);
|
|
434831
435495
|
// 空会话的判断:id 为空字符串
|
|
434832
435496
|
const isEmptyConversation = !currentConversationInfo || currentConversationInfo.id === '';
|
|
434833
435497
|
const InputRightActionsComponent = (0,react.useMemo)(()=>renderChatInputRightActions ? (()=>{
|
|
@@ -435038,13 +435702,13 @@ const ChatHeader = (param)=>{
|
|
|
435038
435702
|
let { iconUrl = coze_logo_namespaceObject, title = 'Coze Bot', extra, theme, isShowConversations, isNeedLogo = true } = param;
|
|
435039
435703
|
const { headerTopLeftOps } = useChatOpInfo();
|
|
435040
435704
|
const buttonList = useChatChatButtonInfo(headerTopLeftOps);
|
|
435041
|
-
const { updateCurrentConversationInfo, currentConversationInfo, updateConversations, cozeApi } =
|
|
435705
|
+
const { updateCurrentConversationInfo, currentConversationInfo, updateConversations, cozeApi } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
435042
435706
|
updateCurrentConversationInfo: s.updateCurrentConversationInfo,
|
|
435043
435707
|
currentConversationInfo: s.currentConversationInfo,
|
|
435044
435708
|
updateConversations: s.updateConversations,
|
|
435045
435709
|
cozeApi: s.cozeApi
|
|
435046
435710
|
})));
|
|
435047
|
-
const { chatConfig: { type: chatType } } =
|
|
435711
|
+
const { chatConfig: { type: chatType } } = context_useChatAppProps();
|
|
435048
435712
|
const [isRenameModalVisible, setIsRenameModalVisible] = (0,react.useState)(false);
|
|
435049
435713
|
const [renameInputValue, setRenameInputValue] = (0,react.useState)('');
|
|
435050
435714
|
const [isRenameLoading, setIsRenameLoading] = (0,react.useState)(false);
|
|
@@ -435290,13 +435954,13 @@ const ChatHeaderMobile = (param)=>{
|
|
|
435290
435954
|
let { iconUrl = coze_logo_namespaceObject, title = 'Coze Bot', extra, theme, isShowConversations, isNeedLogo = true } = param;
|
|
435291
435955
|
const { headerTopLeftOps } = useChatOpInfo();
|
|
435292
435956
|
const buttonList = useChatChatButtonInfo(headerTopLeftOps);
|
|
435293
|
-
const { updateCurrentConversationInfo, currentConversationInfo, updateConversations, cozeApi } =
|
|
435957
|
+
const { updateCurrentConversationInfo, currentConversationInfo, updateConversations, cozeApi } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
435294
435958
|
updateCurrentConversationInfo: s.updateCurrentConversationInfo,
|
|
435295
435959
|
currentConversationInfo: s.currentConversationInfo,
|
|
435296
435960
|
updateConversations: s.updateConversations,
|
|
435297
435961
|
cozeApi: s.cozeApi
|
|
435298
435962
|
})));
|
|
435299
|
-
const { chatConfig: { type: chatType } } =
|
|
435963
|
+
const { chatConfig: { type: chatType } } = context_useChatAppProps();
|
|
435300
435964
|
const [isRenameModalVisible, setIsRenameModalVisible] = (0,react.useState)(false);
|
|
435301
435965
|
const [renameInputValue, setRenameInputValue] = (0,react.useState)('');
|
|
435302
435966
|
const [isRenameLoading, setIsRenameLoading] = (0,react.useState)(false);
|
|
@@ -435524,7 +436188,7 @@ var header_index_module_update = injectStylesIntoStyleTag_default()(header_index
|
|
|
435524
436188
|
|
|
435525
436189
|
|
|
435526
436190
|
const FloatBtn = ()=>{
|
|
435527
|
-
const { updateCurrentConversationInfo, currentConversationInfo } =
|
|
436191
|
+
const { updateCurrentConversationInfo, currentConversationInfo } = context_useChatAppStore(shallow_useShallow((s)=>({
|
|
435528
436192
|
updateCurrentConversationInfo: s.updateCurrentConversationInfo,
|
|
435529
436193
|
currentConversationInfo: s.currentConversationInfo
|
|
435530
436194
|
})));
|