@agentscope-ai/chat 1.1.20 → 1.1.22
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/bin/client.js +1 -1
- package/components/AGUI/components/HelpModal/icons.tsx +68 -0
- package/components/AGUI/components/HelpModal/index.tsx +1 -0
- package/components/AGUI/components/HelpModal/modal.tsx +101 -0
- package/components/AGUI/components/chat/Button.tsx +18 -0
- package/components/AGUI/components/chat/Chat.tsx +780 -0
- package/components/AGUI/components/chat/ChatContext.tsx +248 -0
- package/components/AGUI/components/chat/CodeBlock.tsx +406 -0
- package/components/AGUI/components/chat/Header.tsx +22 -0
- package/components/AGUI/components/chat/Icons.tsx +237 -0
- package/components/AGUI/components/chat/ImageUploadQueue.tsx +77 -0
- package/components/AGUI/components/chat/Input.tsx +24 -0
- package/components/AGUI/components/chat/Markdown.tsx +134 -0
- package/components/AGUI/components/chat/Messages.tsx +259 -0
- package/components/AGUI/components/chat/Modal.tsx +133 -0
- package/components/AGUI/components/chat/Popup.tsx +57 -0
- package/components/AGUI/components/chat/PoweredByTag.tsx +29 -0
- package/components/AGUI/components/chat/Sidebar.tsx +74 -0
- package/components/AGUI/components/chat/Suggestion.tsx +132 -0
- package/components/AGUI/components/chat/Suggestions.tsx +20 -0
- package/components/AGUI/components/chat/Textarea.tsx +61 -0
- package/components/AGUI/components/chat/Window.tsx +152 -0
- package/components/AGUI/components/chat/index.tsx +11 -0
- package/components/AGUI/components/chat/messages/AssistantMessage.tsx +69 -0
- package/components/AGUI/components/chat/messages/RenderActionExecutionMessage.tsx +129 -0
- package/components/AGUI/components/chat/messages/RenderAgentStateMessage.tsx +116 -0
- package/components/AGUI/components/chat/messages/RenderImageMessage.tsx +64 -0
- package/components/AGUI/components/chat/messages/RenderResultMessage.tsx +26 -0
- package/components/AGUI/components/chat/messages/RenderTextMessage.tsx +51 -0
- package/components/AGUI/components/chat/messages/UserMessage.tsx +10 -0
- package/components/AGUI/components/chat/props.ts +186 -0
- package/components/AGUI/components/index.ts +1 -0
- package/components/AGUI/context/index.ts +1 -0
- package/components/AGUI/hooks/index.ts +1 -0
- package/components/AGUI/hooks/use-copilot-chat-suggestions.tsx +122 -0
- package/components/AGUI/hooks/use-copy-to-clipboard.tsx +29 -0
- package/components/AGUI/hooks/use-dark-mode.ts +10 -0
- package/components/AGUI/hooks/use-push-to-talk.tsx +166 -0
- package/components/AGUI/index.tsx +4 -0
- package/components/AGUI/lib/utils.test.ts +7 -0
- package/components/AGUI/lib/utils.ts +27 -0
- package/components/AGUI/styles.css +0 -0
- package/components/AGUI/types/css.ts +0 -0
- package/components/AGUI/types/index.ts +1 -0
- package/components/AGUI/types/suggestions.ts +6 -0
- package/components/Accordion/Accordion.tsx +203 -0
- package/components/Accordion/BodyContent.tsx +28 -0
- package/components/Accordion/DeepThinking.tsx +91 -0
- package/components/Accordion/SoftLightTitle.tsx +13 -0
- package/components/Accordion/demo/search.tsx +39 -0
- package/components/Accordion/demo/steps.tsx +135 -0
- package/components/Accordion/demo/thinking.tsx +62 -0
- package/components/Accordion/index.en-US.md +34 -0
- package/components/Accordion/index.tsx +3 -0
- package/components/Accordion/index.zh-CN.md +34 -0
- package/components/Accordion/style.ts +208 -0
- package/components/AgentScopeRuntimeWebUI/demo/index.tsx +4 -0
- package/components/AgentScopeRuntimeWebUI/index.tsx +3 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Builder.tsx +82 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Request/Card.tsx +52 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Actions.tsx +39 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Builder.tsx +205 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Card.tsx +44 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Error.tsx +7 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Message.tsx +23 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Reasoning.tsx +16 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/Response/Tool.tsx +19 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/index.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/AgentScopeRuntime/types.tsx +100 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Input/index.tsx +77 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Input/useAttachments.tsx +53 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/MessageList/index.tsx +30 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Welcome/index.tsx +66 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/Welcome/styles.ts +51 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/index.tsx +5 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatController.tsx +130 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatMessageHandler.tsx +87 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatRequest.tsx +114 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/hooks/useChatSessionHandler.tsx +50 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/index.tsx +18 -0
- package/components/AgentScopeRuntimeWebUI/lib/Chat/styles.tsx +59 -0
- package/components/AgentScopeRuntimeWebUI/lib/ChatAnywhere/ComposedProvider.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/ChatAnywhere/index.tsx +29 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereControl.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereInputContext.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereLayoutContext.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereMessagesContext.tsx +82 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereOptionsContext.tsx +76 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/ChatAnywhereSessionsContext.tsx +111 -0
- package/components/AgentScopeRuntimeWebUI/lib/Context/useChatAnywhereEventEmitter.tsx +30 -0
- package/components/AgentScopeRuntimeWebUI/lib/Header/index.tsx +45 -0
- package/components/AgentScopeRuntimeWebUI/lib/Header/styles.ts +23 -0
- package/components/AgentScopeRuntimeWebUI/lib/Layout/index.tsx +45 -0
- package/components/AgentScopeRuntimeWebUI/lib/Layout/styles.tsx +104 -0
- package/components/AgentScopeRuntimeWebUI/lib/Sessions/index.tsx +114 -0
- package/components/AgentScopeRuntimeWebUI/lib/Sessions/styles.tsx +0 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/FormItem.tsx +37 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/OptionsEditor.tsx +163 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/defaultConfig.ts +43 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/OptionsPanel/index.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/index.tsx +57 -0
- package/components/AgentScopeRuntimeWebUI/lib/demo/sessionApi/index.ts +51 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/IChatAnywhere.ts +358 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/IMessages.tsx +52 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/ISessions.tsx +29 -0
- package/components/AgentScopeRuntimeWebUI/lib/types/index.tsx +3 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.tsx +37 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.tsx +163 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.ts +43 -0
- package/components/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.tsx +27 -0
- package/components/AgentScopeRuntimeWebUI/starter/index.tsx +57 -0
- package/components/AgentScopeRuntimeWebUI/starter/sessionApi/index.ts +51 -0
- package/components/Attachments/DropArea.tsx +97 -0
- package/components/Attachments/FileList/AudioIcon.tsx +20 -0
- package/components/Attachments/FileList/FileListCard.tsx +270 -0
- package/components/Attachments/FileList/Progress.tsx +30 -0
- package/components/Attachments/FileList/VideoIcon.tsx +20 -0
- package/components/Attachments/FileList/index.tsx +201 -0
- package/components/Attachments/PlaceholderUploader.tsx +124 -0
- package/components/Attachments/SilentUploader.tsx +39 -0
- package/components/Attachments/context.tsx +11 -0
- package/components/Attachments/demo/basic.tsx +71 -0
- package/components/Attachments/index.en-US.md.bk +10 -0
- package/components/Attachments/index.tsx +274 -0
- package/components/Attachments/index.zh-CN.md.bk +10 -0
- package/components/Attachments/style/fileCard.ts +163 -0
- package/components/Attachments/style/index.ts +232 -0
- package/components/Attachments/util.ts +56 -0
- package/components/Bubble/Avatar.tsx +39 -0
- package/components/Bubble/Bubble.tsx +131 -0
- package/components/Bubble/BubbleList.tsx +105 -0
- package/components/Bubble/Cards.tsx +61 -0
- package/components/Bubble/Footer.tsx +55 -0
- package/components/Bubble/Interrupted.tsx +82 -0
- package/components/Bubble/ScrollToBottom.tsx +42 -0
- package/components/Bubble/Spin.tsx +13 -0
- package/components/Bubble/demo/assistantWithCode.tsx +60 -0
- package/components/Bubble/demo/assistantWithErrorStatus.tsx +102 -0
- package/components/Bubble/demo/assistantWithImage.tsx +46 -0
- package/components/Bubble/demo/assistantWithProcess.tsx +103 -0
- package/components/Bubble/demo/assistantWithSearch.tsx +69 -0
- package/components/Bubble/demo/assistantWithThinking.tsx +54 -0
- package/components/Bubble/demo/basic.tsx +55 -0
- package/components/Bubble/demo/userWithFile.tsx +27 -0
- package/components/Bubble/demo/userWithImage.tsx +26 -0
- package/components/Bubble/hooks/useDisplayData.ts +0 -0
- package/components/Bubble/hooks/useListData.ts +0 -0
- package/components/Bubble/index.en-US.md +33 -0
- package/components/Bubble/index.tsx +21 -0
- package/components/Bubble/index.zh-CN.md +33 -0
- package/components/Bubble/interface.ts +71 -0
- package/components/Bubble/loading.tsx +15 -0
- package/components/Bubble/style/avatar.ts +43 -0
- package/components/Bubble/style/footer.ts +45 -0
- package/components/Bubble/style/index.ts +192 -0
- package/components/Bubble/style/list.ts +51 -0
- package/components/ChatAnywhere/Chat/Ref.tsx +20 -0
- package/components/ChatAnywhere/Chat/index.tsx +56 -0
- package/components/ChatAnywhere/Chat/style.ts +59 -0
- package/components/ChatAnywhere/Header/index.tsx +37 -0
- package/components/ChatAnywhere/Header/style.ts +27 -0
- package/components/ChatAnywhere/Input/index.tsx +158 -0
- package/components/ChatAnywhere/Input/style.ts +14 -0
- package/components/ChatAnywhere/Layout/index.tsx +70 -0
- package/components/ChatAnywhere/Layout/style.ts +51 -0
- package/components/ChatAnywhere/SessionList/index.tsx +122 -0
- package/components/ChatAnywhere/SessionList/style.ts +53 -0
- package/components/ChatAnywhere/hooks/ChatAnywhereProvider.tsx +219 -0
- package/components/ChatAnywhere/hooks/types.ts +333 -0
- package/components/ChatAnywhere/hooks/useInput.tsx +22 -0
- package/components/ChatAnywhere/hooks/useMessages.tsx +63 -0
- package/components/ChatAnywhere/hooks/useSessionList.tsx +123 -0
- package/components/ChatAnywhere/index.tsx +49 -0
- package/components/Conversations/GroupTitle.tsx +28 -0
- package/components/Conversations/Item.tsx +189 -0
- package/components/Conversations/demo/basic.tsx +107 -0
- package/components/Conversations/demo/timeline.tsx +111 -0
- package/components/Conversations/demo/timestamp.tsx +110 -0
- package/components/Conversations/hooks/useGroupable.ts +81 -0
- package/components/Conversations/index.en-US.md +32 -0
- package/components/Conversations/index.tsx +176 -0
- package/components/Conversations/index.zh-CN.md +31 -0
- package/components/Conversations/interface.ts +69 -0
- package/components/Conversations/style.ts +153 -0
- package/components/DefaultCards/DeepThinking/index.tsx +33 -0
- package/components/DefaultCards/Files/index.tsx +69 -0
- package/components/DefaultCards/Footer/index.tsx +16 -0
- package/components/DefaultCards/Images/index.tsx +53 -0
- package/components/DefaultCards/Interrupted/index.tsx +13 -0
- package/components/DefaultCards/Text/index.tsx +13 -0
- package/components/DefaultCards/index.tsx +6 -0
- package/components/DeviceAction/actionMap.tsx +100 -0
- package/components/DeviceAction/demo/index.tsx +132 -0
- package/components/DeviceAction/index.en-US.md +19 -0
- package/components/DeviceAction/index.tsx +75 -0
- package/components/DeviceAction/index.zh-CN.md +19 -0
- package/components/Disclaimer/demo/index.tsx +4 -0
- package/components/Disclaimer/demo/withLink.tsx +4 -0
- package/components/Disclaimer/index.en-US.md +23 -0
- package/components/Disclaimer/index.tsx +42 -0
- package/components/Disclaimer/index.zh-CN.md +24 -0
- package/components/Disclaimer/style.ts +17 -0
- package/components/ImageGenerator/demo/basic.tsx +23 -0
- package/components/ImageGenerator/demo/custom.tsx +56 -0
- package/components/ImageGenerator/demo/size.tsx +15 -0
- package/components/ImageGenerator/index.en-US.md +23 -0
- package/components/ImageGenerator/index.tsx +124 -0
- package/components/ImageGenerator/index.zh-CN.md +23 -0
- package/components/ImageGenerator/style.ts +99 -0
- package/components/Markdown/Markdown/AnimationNode.tsx +89 -0
- package/components/Markdown/Markdown/Markdown.tsx +61 -0
- package/components/Markdown/Markdown/core/Parser.ts +52 -0
- package/components/Markdown/Markdown/core/Renderer.ts +121 -0
- package/components/Markdown/Markdown/core/index.ts +4 -0
- package/components/Markdown/Markdown/defaultComponents/CodeBlock.tsx +113 -0
- package/components/Markdown/Markdown/defaultComponents/DisabledImage.tsx +3 -0
- package/components/Markdown/Markdown/defaultComponents/Media.tsx +71 -0
- package/components/Markdown/Markdown/hooks/index.ts +4 -0
- package/components/Markdown/Markdown/hooks/useAnimation.tsx +27 -0
- package/components/Markdown/Markdown/hooks/useCitationsData.tsx +36 -0
- package/components/Markdown/Markdown/hooks/useStreaming.ts +503 -0
- package/components/Markdown/Markdown/hooks/useTyping.ts +22 -0
- package/components/Markdown/Markdown/index.tsx +198 -0
- package/components/Markdown/Markdown/interface.ts +217 -0
- package/components/Markdown/Markdown/style.ts +152 -0
- package/components/Markdown/demo/basic.tsx +107 -0
- package/components/Markdown/demo/citations.tsx +47 -0
- package/components/Markdown/demo/cursor.tsx +9 -0
- package/components/Markdown/demo/latex.tsx +77 -0
- package/components/Markdown/demo/typing.tsx +82 -0
- package/components/Markdown/index.en-US.md +27 -0
- package/components/Markdown/index.ts +1 -0
- package/components/Markdown/index.zh-CN.md +28 -0
- package/components/Markdown/plugins/citations/CitationComponent.tsx +72 -0
- package/components/Markdown/plugins/citations/index.tsx +37 -0
- package/components/Markdown/plugins/cursor/Dot.tsx +106 -0
- package/components/Markdown/plugins/cursor/Underline.tsx +38 -0
- package/components/Markdown/plugins/cursor/index.tsx +59 -0
- package/components/Markdown/plugins/latex/index.ts +109 -0
- package/components/Markdown/plugins/type.ts +71 -0
- package/components/Mermaid/demo/basic.tsx +12 -0
- package/components/Mermaid/demo/class.tsx +31 -0
- package/components/Mermaid/demo/flowchart.tsx +13 -0
- package/components/Mermaid/demo/sequence.tsx +18 -0
- package/components/Mermaid/demo/state.tsx +16 -0
- package/components/Mermaid/demo/timeline.tsx +15 -0
- package/components/Mermaid/index.en-US.md +27 -0
- package/components/Mermaid/index.tsx +118 -0
- package/components/Mermaid/index.zh-CN.md +27 -0
- package/components/OperateCard/OperateCard.tsx +93 -0
- package/components/OperateCard/demo/index.tsx +35 -0
- package/components/OperateCard/demo/rag.tsx +19 -0
- package/components/OperateCard/demo/thinking.tsx +17 -0
- package/components/OperateCard/demo/todo.tsx +28 -0
- package/components/OperateCard/demo/toolCall.tsx +14 -0
- package/components/OperateCard/demo/webSearch.tsx +12 -0
- package/components/OperateCard/index.en-US.md +51 -0
- package/components/OperateCard/index.tsx +1 -0
- package/components/OperateCard/index.zh-CN.md +51 -0
- package/components/OperateCard/preset/Rag.tsx +90 -0
- package/components/OperateCard/preset/Thinking.tsx +45 -0
- package/components/OperateCard/preset/TodoList.tsx +73 -0
- package/components/OperateCard/preset/ToolCall.tsx +67 -0
- package/components/OperateCard/preset/WebSearch.tsx +65 -0
- package/components/OperateCard/preset/index.tsx +5 -0
- package/components/OperateCard/style.ts +268 -0
- package/components/Provider/CustomCardsProvider.tsx +17 -0
- package/components/Provider/GlobalProvider.tsx +17 -0
- package/components/Provider/index.tsx +33 -0
- package/components/Provider/types.ts +23 -0
- package/components/ResponsesAPI/index.tsx +0 -0
- package/components/Sender/ModeSelect/index.tsx +160 -0
- package/components/Sender/ModeSelect/styles.ts +0 -0
- package/components/Sender/SenderHeader.tsx +164 -0
- package/components/Sender/StopLoading.tsx +48 -0
- package/components/Sender/components/ActionButton.tsx +106 -0
- package/components/Sender/components/ClearButton.tsx +10 -0
- package/components/Sender/components/LoadingButton.tsx +26 -0
- package/components/Sender/components/SendButton.tsx +22 -0
- package/components/Sender/components/SpeechButton/RecordingIcon.tsx +68 -0
- package/components/Sender/components/SpeechButton/index.tsx +30 -0
- package/components/Sender/demo/asr.tsx +7 -0
- package/components/Sender/demo/basic.tsx +7 -0
- package/components/Sender/demo/loading.tsx +5 -0
- package/components/Sender/demo/moreMode.tsx +45 -0
- package/components/Sender/demo/morePrefixAction.tsx +40 -0
- package/components/Sender/demo/withFile.tsx +54 -0
- package/components/Sender/demo/withImage.tsx +52 -0
- package/components/Sender/index.en-US.md +29 -0
- package/components/Sender/index.tsx +491 -0
- package/components/Sender/index.zh-CN.md +30 -0
- package/components/Sender/style/index.ts +150 -0
- package/components/Sender/useSpeech.ts +133 -0
- package/components/StatusCard/demo/index.tsx +32 -0
- package/components/StatusCard/index.en-US.md +30 -0
- package/components/StatusCard/index.tsx +162 -0
- package/components/StatusCard/index.zh-CN.md +27 -0
- package/components/StatusCard/style.ts +119 -0
- package/components/Stream/index.ts +203 -0
- package/components/Util/hooks/use-proxy-imperative-handle.ts +25 -0
- package/components/Util/sleep.ts +3 -0
- package/components/Util/type.ts +1 -0
- package/components/Util/warning.ts +118 -0
- package/components/Version/index.ts +3 -0
- package/components/Voice/Recorder.tsx +3 -0
- package/components/Voice/demo/index.tsx +0 -0
- package/components/Voice/index.en-US.md +8 -0
- package/components/Voice/index.tsx +0 -0
- package/components/Voice/index.zh-CN.md +9 -0
- package/components/Welcome/demo/EyeFollower.tsx +161 -0
- package/components/Welcome/demo/demo0.tsx +14 -0
- package/components/Welcome/demo/demo1.tsx +16 -0
- package/components/Welcome/demo/demo2.tsx +30 -0
- package/components/Welcome/demo/demo3.tsx +16 -0
- package/components/Welcome/index.en-US.md +28 -0
- package/components/Welcome/index.tsx +72 -0
- package/components/Welcome/index.zh-CN.md +28 -0
- package/components/index.ts +88 -0
- package/components/overview.en-US.md +10 -0
- package/components/overview.zh-CN.md +10 -0
- package/lib/AgentScopeRuntimeWebUI/index.d.ts +1 -0
- package/lib/AgentScopeRuntimeWebUI/index.js +1 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.d.ts +9 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/FormItem.js +33 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.d.ts +7 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/OptionsEditor.js +188 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.d.ts +29 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/defaultConfig.js +35 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.d.ts +6 -0
- package/lib/AgentScopeRuntimeWebUI/starter/OptionsPanel/index.js +49 -0
- package/lib/AgentScopeRuntimeWebUI/starter/index.d.ts +1 -0
- package/lib/AgentScopeRuntimeWebUI/starter/index.js +70 -0
- package/lib/AgentScopeRuntimeWebUI/starter/sessionApi/index.d.ts +14 -0
- package/lib/AgentScopeRuntimeWebUI/starter/sessionApi/index.js +143 -0
- package/package.json +3 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export default () => {
|
|
2
|
+
return {
|
|
3
|
+
theme: {
|
|
4
|
+
colorPrimary: '#615CED',
|
|
5
|
+
darkMode: true,
|
|
6
|
+
prefix: 'agentscope-runtime-webui',
|
|
7
|
+
leftHeader: {
|
|
8
|
+
logo: 'https://img.alicdn.com/imgextra/i2/O1CN01lmoGYn1kjoXATy4PX_!!6000000004720-2-tps-200-200.png',
|
|
9
|
+
title: 'Runtime WebUI',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
sender: {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
attachments: true,
|
|
15
|
+
maxLength: 10000,
|
|
16
|
+
disclaimer:
|
|
17
|
+
'AI can also make mistakes, so please check carefully and use it with caution',
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
welcome: {
|
|
21
|
+
greeting: 'Hello, how can I help you today?',
|
|
22
|
+
description:
|
|
23
|
+
'I am a helpful assistant that can help you with your questions.',
|
|
24
|
+
avatar:
|
|
25
|
+
'https://img.alicdn.com/imgextra/i2/O1CN01lmoGYn1kjoXATy4PX_!!6000000004720-2-tps-200-200.png',
|
|
26
|
+
prompts: [
|
|
27
|
+
{
|
|
28
|
+
value: 'Hello',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
value: 'How are you?',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: 'What can you do?',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
api: {
|
|
39
|
+
baseURL: '',
|
|
40
|
+
token: '',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SparkSettingLine } from "@agentscope-ai/icons";
|
|
2
|
+
import { IconButton, Drawer } from "@agentscope-ai/design";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import OptionsEditor from "./OptionsEditor";
|
|
5
|
+
|
|
6
|
+
interface OptionsPanelProps {
|
|
7
|
+
value?: any;
|
|
8
|
+
onChange?: any;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function OptionsPanel(props: OptionsPanelProps) {
|
|
12
|
+
const [open, setOpen] = useState(false);
|
|
13
|
+
|
|
14
|
+
return <>
|
|
15
|
+
<IconButton onClick={() => setOpen(true)} icon={<SparkSettingLine />} bordered={false} />
|
|
16
|
+
<Drawer
|
|
17
|
+
destroyOnHidden
|
|
18
|
+
open={open}
|
|
19
|
+
onClose={() => setOpen(false)}
|
|
20
|
+
styles={{ body: { padding: 0 }, header: { padding: 8 } }}>
|
|
21
|
+
<OptionsEditor value={props.value} onChange={v => {
|
|
22
|
+
setOpen(false);
|
|
23
|
+
props.onChange(v);
|
|
24
|
+
}} />
|
|
25
|
+
</Drawer>
|
|
26
|
+
</>
|
|
27
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AgentScopeRuntimeWebUI } from '@agentscope-ai/chat';
|
|
2
|
+
import OptionsPanel from './OptionsPanel';
|
|
3
|
+
import { useMemo, useState } from 'react';
|
|
4
|
+
import sessionApi from './sessionApi';
|
|
5
|
+
import defaultConfig from './OptionsPanel/defaultConfig';
|
|
6
|
+
import { useLocalStorageState } from 'ahooks';
|
|
7
|
+
|
|
8
|
+
export default function () {
|
|
9
|
+
|
|
10
|
+
const [optionsConfig, setOptionsConfig] = useLocalStorageState('agent-scope-runtime-webui-options', {
|
|
11
|
+
defaultValue: defaultConfig(),
|
|
12
|
+
listenStorageChange: true,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const options = useMemo(() => {
|
|
16
|
+
const rightHeader = <OptionsPanel value={optionsConfig} onChange={v => {
|
|
17
|
+
setOptionsConfig(prev => ({
|
|
18
|
+
...prev,
|
|
19
|
+
...v,
|
|
20
|
+
}));
|
|
21
|
+
}} />;
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
...optionsConfig,
|
|
25
|
+
session: {
|
|
26
|
+
multiple: true,
|
|
27
|
+
api: sessionApi,
|
|
28
|
+
},
|
|
29
|
+
sender: {
|
|
30
|
+
...optionsConfig.sender,
|
|
31
|
+
attachments: optionsConfig.sender.attachments ? {
|
|
32
|
+
customRequest(options) {
|
|
33
|
+
// 模拟上传进度
|
|
34
|
+
options.onProgress({
|
|
35
|
+
percent: 100,
|
|
36
|
+
});
|
|
37
|
+
// 当前是一个 mock 的上传行为
|
|
38
|
+
// 实际情况需要具体实现一个文件上传服务,将文件转化为 url
|
|
39
|
+
options.onSuccess({
|
|
40
|
+
url: URL.createObjectURL(options.file as Blob)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
} : undefined,
|
|
44
|
+
},
|
|
45
|
+
theme: {
|
|
46
|
+
...optionsConfig.theme,
|
|
47
|
+
rightHeader,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}, [optionsConfig]);
|
|
51
|
+
|
|
52
|
+
return <div style={{ height: '100dvh' }}>
|
|
53
|
+
<AgentScopeRuntimeWebUI
|
|
54
|
+
options={options}
|
|
55
|
+
/>
|
|
56
|
+
</div>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { IAgentScopeRuntimeWebUISessionAPI } from '@agentscope-ai/chat';
|
|
2
|
+
import { IAgentScopeRuntimeWebUISession } from '../../lib/types/ISessions';
|
|
3
|
+
|
|
4
|
+
class SessionApi implements IAgentScopeRuntimeWebUISessionAPI {
|
|
5
|
+
private lsKey: string;
|
|
6
|
+
private sessionList: IAgentScopeRuntimeWebUISession[];
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
this.lsKey = 'agent-scope-runtime-webui-sessions';
|
|
10
|
+
this.sessionList = [];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async getSessionList() {
|
|
14
|
+
this.sessionList = JSON.parse(localStorage.getItem(this.lsKey) || '[]');
|
|
15
|
+
return [...this.sessionList];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async getSession(sessionId) {
|
|
19
|
+
return this.sessionList.find((session) => session.id === sessionId);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async updateSession(session) {
|
|
23
|
+
const index = this.sessionList.findIndex((item) => item.id === session.id);
|
|
24
|
+
if (index > -1) {
|
|
25
|
+
this.sessionList[index] = {
|
|
26
|
+
...this.sessionList[index],
|
|
27
|
+
...session,
|
|
28
|
+
};
|
|
29
|
+
localStorage.setItem(this.lsKey, JSON.stringify(this.sessionList));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return [...this.sessionList];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async createSession(session) {
|
|
36
|
+
session.id = Date.now().toString();
|
|
37
|
+
this.sessionList.unshift(session);
|
|
38
|
+
localStorage.setItem(this.lsKey, JSON.stringify(this.sessionList));
|
|
39
|
+
return [...this.sessionList];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async removeSession(session) {
|
|
43
|
+
this.sessionList = this.sessionList.filter(
|
|
44
|
+
(item) => item.id !== session.id,
|
|
45
|
+
);
|
|
46
|
+
localStorage.setItem(this.lsKey, JSON.stringify(this.sessionList));
|
|
47
|
+
return [...this.sessionList];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default new SessionApi();
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import classnames from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { AttachmentContext } from './context';
|
|
5
|
+
|
|
6
|
+
export interface DropUploaderProps {
|
|
7
|
+
/**
|
|
8
|
+
* @description 自定义CSS类名前缀,用于样式隔离和主题定制
|
|
9
|
+
* @descriptionEn Custom CSS class name prefix for style isolation and theme customization
|
|
10
|
+
*/
|
|
11
|
+
prefixCls: string;
|
|
12
|
+
/**
|
|
13
|
+
* @description 拖拽区域的CSS类名
|
|
14
|
+
* @descriptionEn CSS class name for the drop area
|
|
15
|
+
*/
|
|
16
|
+
className: string;
|
|
17
|
+
/**
|
|
18
|
+
* @description 获取拖拽容器的函数,用于自定义拖拽区域
|
|
19
|
+
* @descriptionEn Function to get drop container for customizing drop area
|
|
20
|
+
*/
|
|
21
|
+
getDropContainer?: null | (() => HTMLElement | null | undefined);
|
|
22
|
+
/**
|
|
23
|
+
* @description 拖拽区域内的子元素,用于显示拖拽提示内容
|
|
24
|
+
* @descriptionEn Child elements within the drop area for displaying drop prompt content
|
|
25
|
+
*/
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default function DropArea(props: DropUploaderProps) {
|
|
30
|
+
const { getDropContainer, className, prefixCls, children } = props;
|
|
31
|
+
const { disabled } = React.useContext(AttachmentContext);
|
|
32
|
+
|
|
33
|
+
const [container, setContainer] = React.useState<HTMLElement | null | undefined>();
|
|
34
|
+
const [showArea, setShowArea] = React.useState<boolean | null>(null);
|
|
35
|
+
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
const nextContainer = getDropContainer?.();
|
|
38
|
+
if (container !== nextContainer) {
|
|
39
|
+
setContainer(nextContainer);
|
|
40
|
+
}
|
|
41
|
+
}, [getDropContainer]);
|
|
42
|
+
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
// Add global drop event
|
|
45
|
+
if (container) {
|
|
46
|
+
const onDragEnter = () => {
|
|
47
|
+
setShowArea(true);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Should prevent default to make drop event work
|
|
51
|
+
const onDragOver = (e: DragEvent) => {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const onDragLeave = (e: DragEvent) => {
|
|
56
|
+
if (!e.relatedTarget) {
|
|
57
|
+
setShowArea(false);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const onDrop = (e: DragEvent) => {
|
|
61
|
+
setShowArea(false);
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
document.addEventListener('dragenter', onDragEnter);
|
|
66
|
+
document.addEventListener('dragover', onDragOver);
|
|
67
|
+
document.addEventListener('dragleave', onDragLeave);
|
|
68
|
+
document.addEventListener('drop', onDrop);
|
|
69
|
+
return () => {
|
|
70
|
+
document.removeEventListener('dragenter', onDragEnter);
|
|
71
|
+
document.removeEventListener('dragover', onDragOver);
|
|
72
|
+
document.removeEventListener('dragleave', onDragLeave);
|
|
73
|
+
document.removeEventListener('drop', onDrop);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}, [!!container]);
|
|
77
|
+
|
|
78
|
+
const showDropdown = getDropContainer && container && !disabled;
|
|
79
|
+
|
|
80
|
+
if (!showDropdown) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const areaCls = `${prefixCls}-drop-area`;
|
|
85
|
+
|
|
86
|
+
return createPortal(
|
|
87
|
+
<div
|
|
88
|
+
className={classnames(areaCls, className, {
|
|
89
|
+
[`${areaCls}-on-body`]: container.tagName === 'BODY',
|
|
90
|
+
})}
|
|
91
|
+
style={{ display: showArea ? 'block' : 'none' }}
|
|
92
|
+
>
|
|
93
|
+
{children}
|
|
94
|
+
</div>,
|
|
95
|
+
container,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default function AudioIcon() {
|
|
2
|
+
return (
|
|
3
|
+
<svg
|
|
4
|
+
width="1em"
|
|
5
|
+
height="1em"
|
|
6
|
+
viewBox="0 0 16 16"
|
|
7
|
+
version="1.1"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
10
|
+
>
|
|
11
|
+
<title>audio</title>
|
|
12
|
+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
13
|
+
<path
|
|
14
|
+
d="M14.1178571,4.0125 C14.225,4.11964286 14.2857143,4.26428571 14.2857143,4.41607143 L14.2857143,15.4285714 C14.2857143,15.7446429 14.0303571,16 13.7142857,16 L2.28571429,16 C1.96964286,16 1.71428571,15.7446429 1.71428571,15.4285714 L1.71428571,0.571428571 C1.71428571,0.255357143 1.96964286,0 2.28571429,0 L9.86964286,0 C10.0214286,0 10.1678571,0.0607142857 10.275,0.167857143 L14.1178571,4.0125 Z M10.7315824,7.11216117 C10.7428131,7.15148751 10.7485063,7.19218979 10.7485063,7.23309113 L10.7485063,8.07742614 C10.7484199,8.27364959 10.6183424,8.44607275 10.4296853,8.50003683 L8.32984514,9.09986306 L8.32984514,11.7071803 C8.32986605,12.5367078 7.67249692,13.217028 6.84345686,13.2454634 L6.79068592,13.2463395 C6.12766108,13.2463395 5.53916361,12.8217001 5.33010655,12.1924966 C5.1210495,11.563293 5.33842118,10.8709227 5.86959669,10.4741173 C6.40077221,10.0773119 7.12636292,10.0652587 7.67042486,10.4442027 L7.67020842,7.74937024 L7.68449368,7.74937024 C7.72405122,7.59919041 7.83988806,7.48101083 7.98924584,7.4384546 L10.1880418,6.81004755 C10.42156,6.74340323 10.6648954,6.87865515 10.7315824,7.11216117 Z M9.60714286,1.31785714 L12.9678571,4.67857143 L9.60714286,4.67857143 L9.60714286,1.31785714 Z"
|
|
15
|
+
fill="currentColor"
|
|
16
|
+
/>
|
|
17
|
+
</g>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import classnames from 'classnames';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { Attachment } from '..';
|
|
4
|
+
import { AttachmentContext } from '../context';
|
|
5
|
+
import { previewImage } from '../util';
|
|
6
|
+
import AudioIcon from './AudioIcon';
|
|
7
|
+
import Progress from './Progress';
|
|
8
|
+
import VideoIcon from './VideoIcon';
|
|
9
|
+
import Style from '../style/fileCard';
|
|
10
|
+
import { useProviderContext } from '@agentscope-ai/chat';
|
|
11
|
+
import { SparkFalseLine } from '@agentscope-ai/icons';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export interface FileListCardProps {
|
|
15
|
+
/**
|
|
16
|
+
* @description 自定义CSS类名前缀,用于样式隔离和主题定制
|
|
17
|
+
* @descriptionEn Custom CSS class name prefix for style isolation and theme customization
|
|
18
|
+
*/
|
|
19
|
+
prefixCls?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @description 文件附件数据对象,包含文件的基本信息
|
|
22
|
+
* @descriptionEn File attachment data object containing basic file information
|
|
23
|
+
*/
|
|
24
|
+
item: Attachment;
|
|
25
|
+
/**
|
|
26
|
+
* @description 文件移除时的回调函数,用于处理文件删除操作
|
|
27
|
+
* @descriptionEn Callback function when file is removed for handling file deletion operations
|
|
28
|
+
*/
|
|
29
|
+
onRemove?: (item: Attachment) => void;
|
|
30
|
+
/**
|
|
31
|
+
* @description 组件的CSS类名
|
|
32
|
+
* @descriptionEn CSS class name for the component
|
|
33
|
+
*/
|
|
34
|
+
className?: string;
|
|
35
|
+
/**
|
|
36
|
+
* @description 组件的内联样式对象
|
|
37
|
+
* @descriptionEn Inline style object for the component
|
|
38
|
+
*/
|
|
39
|
+
style?: React.CSSProperties;
|
|
40
|
+
/**
|
|
41
|
+
* @description 渲染类型,目前仅支持默认渲染模式
|
|
42
|
+
* @descriptionEn Render type, currently only supports default render mode
|
|
43
|
+
*/
|
|
44
|
+
renderType?: 'default',
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const EMPTY = '\u00A0';
|
|
49
|
+
|
|
50
|
+
const DEFAULT_ICON_COLOR = '#8c8c8c';
|
|
51
|
+
|
|
52
|
+
const IMG_EXTS = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'webp', 'svg'];
|
|
53
|
+
|
|
54
|
+
const IconImage = ({ url }) => <img src={url} width={32} height={32} />
|
|
55
|
+
|
|
56
|
+
const PRESET_FILE_ICONS: {
|
|
57
|
+
ext: string[];
|
|
58
|
+
color: string;
|
|
59
|
+
icon: React.ReactElement;
|
|
60
|
+
}[] = [
|
|
61
|
+
{
|
|
62
|
+
icon: <IconImage url="https://gw.alicdn.com/imgextra/i1/O1CN01cVtZXI23tPVhiZoPJ_!!6000000007313-55-tps-40-40.svg" />,
|
|
63
|
+
color: '#22b35e',
|
|
64
|
+
ext: ['xlsx', 'xls'],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
icon: <IconImage url="https://gw.alicdn.com/imgextra/i1/O1CN01uDnnuz1XMNEjgFMul_!!6000000002909-55-tps-40-40.svg" />,
|
|
68
|
+
color: DEFAULT_ICON_COLOR,
|
|
69
|
+
ext: IMG_EXTS,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
icon: <IconImage url="https://gw.alicdn.com/imgextra/i1/O1CN01PaXli01DDPAO68fsI_!!6000000000182-55-tps-40-40.svg" />,
|
|
73
|
+
color: DEFAULT_ICON_COLOR,
|
|
74
|
+
ext: ['md', 'mdx'],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
icon: <IconImage url="https://gw.alicdn.com/imgextra/i3/O1CN01mB5PzD27fuIWK661W_!!6000000007825-55-tps-40-40.svg" />,
|
|
78
|
+
color: '#ff4d4f',
|
|
79
|
+
ext: ['pdf'],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
icon: <IconImage url="https://gw.alicdn.com/imgextra/i3/O1CN01a8j7Jv1nW1QyFme7k_!!6000000005096-55-tps-40-40.svg" />,
|
|
83
|
+
color: '#ff6e31',
|
|
84
|
+
ext: ['ppt', 'pptx'],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
icon: <IconImage url="https://gw.alicdn.com/imgextra/i1/O1CN01XaNi8P1UkhQXoQdUL_!!6000000002556-55-tps-40-40.svg" />,
|
|
88
|
+
color: '#1677ff',
|
|
89
|
+
ext: ['doc', 'docx'],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
icon: <IconImage url="https://gw.alicdn.com/imgextra/i1/O1CN01K7jgEj1sywWTkPSGY_!!6000000005836-55-tps-40-40.svg" />,
|
|
93
|
+
color: '#fab714',
|
|
94
|
+
ext: ['zip', 'rar', '7z', 'tar', 'gz'],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
icon: <IconImage url="https://gw.alicdn.com/imgextra/i2/O1CN01zTTe0q1Xg4GkZgJol_!!6000000002952-55-tps-40-40.svg" />,
|
|
98
|
+
|
|
99
|
+
color: '#ff4d4f',
|
|
100
|
+
ext: ['mp4', 'avi', 'mov', 'wmv', 'flv', 'mkv'],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
icon: <IconImage url="https://gw.alicdn.com/imgextra/i2/O1CN01qOBdXG1UpHO6f3Vvc_!!6000000002566-55-tps-40-40.svg" />,
|
|
104
|
+
|
|
105
|
+
color: '#8c8c8c',
|
|
106
|
+
ext: ['mp3', 'wav', 'flac', 'ape', 'aac', 'ogg'],
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
function matchExt(suffix: string, ext: string[]) {
|
|
111
|
+
return ext.some((e) => suffix.toLowerCase() === `.${e}`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function getSize(size: number) {
|
|
115
|
+
let retSize = size;
|
|
116
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'];
|
|
117
|
+
let unitIndex = 0;
|
|
118
|
+
|
|
119
|
+
while (retSize >= 1024 && unitIndex < units.length - 1) {
|
|
120
|
+
retSize /= 1024;
|
|
121
|
+
unitIndex++;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return `${retSize.toFixed(0)} ${units[unitIndex]}`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function FileListCard(props: FileListCardProps, ref: React.Ref<HTMLDivElement>) {
|
|
128
|
+
const { getPrefixCls } = useProviderContext();
|
|
129
|
+
const { item, onRemove, className, style } = props;
|
|
130
|
+
const context = React.useContext(AttachmentContext);
|
|
131
|
+
const { disabled } = context || {};
|
|
132
|
+
const { name, size, percent, status = 'done', description } = item;
|
|
133
|
+
const prefixCls = getPrefixCls('attachment');
|
|
134
|
+
const cardCls = `${prefixCls}-list-card`;
|
|
135
|
+
|
|
136
|
+
const [namePrefix, nameSuffix] = React.useMemo(() => {
|
|
137
|
+
const nameStr = name || '';
|
|
138
|
+
const match = nameStr.match(/^(.*)\.[^.]+$/);
|
|
139
|
+
return match ? [match[1], nameStr.slice(match[1].length)] : [nameStr, ''];
|
|
140
|
+
}, [name]);
|
|
141
|
+
|
|
142
|
+
const isImg = React.useMemo(() => matchExt(nameSuffix, IMG_EXTS), [nameSuffix]);
|
|
143
|
+
|
|
144
|
+
const desc = React.useMemo(() => {
|
|
145
|
+
if (description) {
|
|
146
|
+
return description;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (status === 'uploading') {
|
|
150
|
+
return `${percent || 0}%`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (status === 'error') {
|
|
154
|
+
return item.response || EMPTY;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return size ? getSize(size) : EMPTY;
|
|
158
|
+
}, [status, percent]);
|
|
159
|
+
|
|
160
|
+
const [icon, iconColor] = React.useMemo(() => {
|
|
161
|
+
for (const { ext, icon, color } of PRESET_FILE_ICONS) {
|
|
162
|
+
if (matchExt(nameSuffix, ext)) {
|
|
163
|
+
return [icon, color];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return [<IconImage url="https://gw.alicdn.com/imgextra/i1/O1CN01K7jgEj1sywWTkPSGY_!!6000000005836-55-tps-40-40.svg" key="defaultIcon" />, DEFAULT_ICON_COLOR];
|
|
168
|
+
}, [nameSuffix]);
|
|
169
|
+
|
|
170
|
+
const [previewImg, setPreviewImg] = React.useState<string>();
|
|
171
|
+
|
|
172
|
+
React.useEffect(() => {
|
|
173
|
+
if (item.originFileObj) {
|
|
174
|
+
let synced = true;
|
|
175
|
+
previewImage(item.originFileObj).then((url) => {
|
|
176
|
+
if (synced) {
|
|
177
|
+
setPreviewImg(url);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return () => {
|
|
182
|
+
synced = false;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
setPreviewImg(undefined);
|
|
186
|
+
}, [item.originFileObj]);
|
|
187
|
+
|
|
188
|
+
let content: React.ReactNode = null;
|
|
189
|
+
const previewUrl = item.thumbUrl || item.url || previewImg;
|
|
190
|
+
const renderType = props.renderType || 'default';
|
|
191
|
+
const isImgPreview = isImg && (item.originFileObj || previewUrl) && renderType === 'default';
|
|
192
|
+
|
|
193
|
+
if (isImgPreview) {
|
|
194
|
+
content = (
|
|
195
|
+
<>
|
|
196
|
+
{
|
|
197
|
+
previewUrl && (
|
|
198
|
+
<img alt="preview" src={previewUrl} />
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
{status !== 'done' && (
|
|
203
|
+
<div className={`${cardCls}-img-mask`}>
|
|
204
|
+
{status === 'uploading' && percent !== undefined && (
|
|
205
|
+
<Progress percent={percent} prefixCls={cardCls} />
|
|
206
|
+
)}
|
|
207
|
+
{status === 'error' && (
|
|
208
|
+
<div className={`${cardCls}-desc`}>
|
|
209
|
+
<div className={`${cardCls}-ellipsis-prefix`}>{desc}</div>
|
|
210
|
+
</div>
|
|
211
|
+
)}
|
|
212
|
+
</div>
|
|
213
|
+
)}
|
|
214
|
+
</>
|
|
215
|
+
);
|
|
216
|
+
} else {
|
|
217
|
+
content = (
|
|
218
|
+
<>
|
|
219
|
+
<div className={`${cardCls}-icon`} style={{ color: iconColor }}>
|
|
220
|
+
{icon}
|
|
221
|
+
</div>
|
|
222
|
+
<div className={`${cardCls}-content`}>
|
|
223
|
+
<div className={`${cardCls}-name`}>
|
|
224
|
+
{namePrefix ?? EMPTY}{nameSuffix}
|
|
225
|
+
</div>
|
|
226
|
+
<div className={`${cardCls}-desc`}>
|
|
227
|
+
<div className={`${cardCls}-ellipsis-prefix`}>{desc}</div>
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
</>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return <>
|
|
235
|
+
<Style />
|
|
236
|
+
<div
|
|
237
|
+
className={classnames(
|
|
238
|
+
cardCls,
|
|
239
|
+
{
|
|
240
|
+
[`${cardCls}-status-${status}`]: status,
|
|
241
|
+
[`${cardCls}-type-preview`]: isImgPreview,
|
|
242
|
+
[`${cardCls}-type-overview`]: !isImgPreview,
|
|
243
|
+
[`${cardCls}-type-${renderType}`]: true,
|
|
244
|
+
[`${cardCls}-hoverable`]: !disabled && onRemove,
|
|
245
|
+
},
|
|
246
|
+
className,
|
|
247
|
+
)}
|
|
248
|
+
style={style}
|
|
249
|
+
ref={ref}
|
|
250
|
+
>
|
|
251
|
+
{content}
|
|
252
|
+
|
|
253
|
+
<button
|
|
254
|
+
style={{
|
|
255
|
+
opacity: !disabled && onRemove ? 1 : 0,
|
|
256
|
+
}}
|
|
257
|
+
className={`${cardCls}-remove`}
|
|
258
|
+
onClick={() => {
|
|
259
|
+
if (!disabled && onRemove) {
|
|
260
|
+
onRemove(item);
|
|
261
|
+
}
|
|
262
|
+
}}
|
|
263
|
+
>
|
|
264
|
+
<SparkFalseLine />
|
|
265
|
+
|
|
266
|
+
</button>
|
|
267
|
+
</div></>
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export default React.forwardRef(FileListCard);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Progress as AntdProgress, theme } from 'antd';
|
|
2
|
+
|
|
3
|
+
export interface ProgressProps {
|
|
4
|
+
/**
|
|
5
|
+
* @description 自定义CSS类名前缀,用于样式隔离和主题定制
|
|
6
|
+
* @descriptionEn Custom CSS class name prefix for style isolation and theme customization
|
|
7
|
+
*/
|
|
8
|
+
prefixCls: string;
|
|
9
|
+
/**
|
|
10
|
+
* @description 进度百分比值,范围0-100,用于显示上传进度
|
|
11
|
+
* @descriptionEn Progress percentage value, range 0-100, for displaying upload progress
|
|
12
|
+
*/
|
|
13
|
+
percent: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default function Progress(props: ProgressProps) {
|
|
17
|
+
const { percent } = props;
|
|
18
|
+
const { token } = theme.useToken();
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<AntdProgress
|
|
22
|
+
type="circle"
|
|
23
|
+
percent={percent}
|
|
24
|
+
size={40}
|
|
25
|
+
strokeColor="#FFF"
|
|
26
|
+
trailColor="rgba(255, 255, 255, 0.3)"
|
|
27
|
+
format={(ptg) => <span style={{ color: '#FFF' }}>{(ptg || 0).toFixed(0)}%</span>}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default function VideoIcon() {
|
|
2
|
+
return (
|
|
3
|
+
<svg
|
|
4
|
+
width="1em"
|
|
5
|
+
height="1em"
|
|
6
|
+
viewBox="0 0 16 16"
|
|
7
|
+
version="1.1"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
10
|
+
>
|
|
11
|
+
<title>video</title>
|
|
12
|
+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
13
|
+
<path
|
|
14
|
+
d="M14.1178571,4.0125 C14.225,4.11964286 14.2857143,4.26428571 14.2857143,4.41607143 L14.2857143,15.4285714 C14.2857143,15.7446429 14.0303571,16 13.7142857,16 L2.28571429,16 C1.96964286,16 1.71428571,15.7446429 1.71428571,15.4285714 L1.71428571,0.571428571 C1.71428571,0.255357143 1.96964286,0 2.28571429,0 L9.86964286,0 C10.0214286,0 10.1678571,0.0607142857 10.275,0.167857143 L14.1178571,4.0125 Z M12.9678571,4.67857143 L9.60714286,1.31785714 L9.60714286,4.67857143 L12.9678571,4.67857143 Z M10.5379461,10.3101106 L6.68957555,13.0059749 C6.59910784,13.0693494 6.47439406,13.0473861 6.41101953,12.9569184 C6.3874624,12.9232903 6.37482581,12.8832269 6.37482581,12.8421686 L6.37482581,7.45043999 C6.37482581,7.33998304 6.46436886,7.25043999 6.57482581,7.25043999 C6.61588409,7.25043999 6.65594753,7.26307658 6.68957555,7.28663371 L10.5379461,9.98249803 C10.6284138,10.0458726 10.6503772,10.1705863 10.5870027,10.2610541 C10.5736331,10.2801392 10.5570312,10.2967411 10.5379461,10.3101106 Z"
|
|
15
|
+
fill="currentColor"
|
|
16
|
+
/>
|
|
17
|
+
</g>
|
|
18
|
+
</svg>
|
|
19
|
+
);
|
|
20
|
+
}
|