diff --git a/Moncter/app/controller/IndexController.php b/Moncter/app/controller/IndexController.php index b9b0da79..7d904faa 100644 --- a/Moncter/app/controller/IndexController.php +++ b/Moncter/app/controller/IndexController.php @@ -8,25 +8,7 @@ class IndexController { public function index(Request $request) { - return << - * { - padding: 0; - margin: 0; - } - iframe { - border: none; - overflow: scroll; - } - - -EOF; + return "我是数据中心,有何贵干?"; } public function view(Request $request) diff --git a/Moncter/app/controller/UserController.php b/Moncter/app/controller/UserController.php new file mode 100644 index 00000000..b23f213c --- /dev/null +++ b/Moncter/app/controller/UserController.php @@ -0,0 +1,16 @@ +get('name', $default_name); + // 向浏览器返回字符串 + return response('hello ' . $name); + } +} \ No newline at end of file diff --git a/Touchkebao/src/components/Upload/AudioRecorder/index.tsx b/Touchkebao/src/components/Upload/AudioRecorder/index.tsx index 1bcc705e..8e9a1dc0 100644 --- a/Touchkebao/src/components/Upload/AudioRecorder/index.tsx +++ b/Touchkebao/src/components/Upload/AudioRecorder/index.tsx @@ -10,7 +10,11 @@ import { import { uploadFile } from "@/api/common"; interface AudioRecorderProps { - onAudioUploaded: (audioData: { url: string; durationMs: number }) => void; + onAudioUploaded: (audioData: { + url: string; + name: string; + durationMs?: number; + }) => void; className?: string; disabled?: boolean; maxDuration?: number; // 最大录音时长(秒) @@ -206,6 +210,7 @@ const AudioRecorder: React.FC = ({ // 调用回调函数,传递音频URL和时长(毫秒) onAudioUploaded({ url: filePath, + name: audioFile.name, durationMs: recordingTime * 1000, // 将秒转换为毫秒 }); diff --git a/Touchkebao/src/components/Upload/SimpleFileUpload/index.tsx b/Touchkebao/src/components/Upload/SimpleFileUpload/index.tsx index 014c3dd1..b751bddb 100644 --- a/Touchkebao/src/components/Upload/SimpleFileUpload/index.tsx +++ b/Touchkebao/src/components/Upload/SimpleFileUpload/index.tsx @@ -3,7 +3,7 @@ import React, { useRef } from "react"; import { message } from "antd"; interface SimpleFileUploadProps { - onFileUploaded?: (filePath: string) => void; + onFileUploaded?: (filePath: { name: string; url: string }) => void; maxSize?: number; // 最大文件大小(MB) type?: number; // 1: 图片, 2: 视频, 3: 音频, 4: 文件 slot?: React.ReactNode; @@ -51,7 +51,10 @@ const SimpleFileUpload: React.FC = ({ try { const fileUrl = await uploadFile(file); - onFileUploaded?.(fileUrl); + onFileUploaded?.({ + name: file.name, + url: fileUrl, + }); message.success("文件上传成功"); } catch (error: any) { console.error("文件上传失败:", error); diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx index 33307856..8ae096e8 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx @@ -34,7 +34,6 @@ const { sendCommand } = useWebSocketStore.getState(); const MessageEnter: React.FC = ({ contract }) => { const [inputValue, setInputValue] = useState(""); - const [showMaterialModal, setShowMaterialModal] = useState(false); const EnterModule = useWeChatStore(state => state.EnterModule); const updateShowCheckbox = useWeChatStore(state => state.updateShowCheckbox); const updateEnterModule = useWeChatStore(state => state.updateEnterModule); @@ -254,20 +253,43 @@ const MessageEnter: React.FC = ({ contract }) => { FILE: 5, }; const handleFileUploaded = ( - filePath: string | { url: string; durationMs: number }, + filePath: { url: string; name: string; durationMs?: number }, fileType: number, ) => { + console.log("handleFileUploaded: ", fileType, filePath); + // msgType(1:文本 3:图片 43:视频 47:动图表情包(gif、其他表情包) 49:小程序/其他:图文、文件) let msgType = 1; + let content: any = ""; if ([FileType.TEXT].includes(fileType)) { - msgType = getMsgTypeByFileFormat(filePath as string); + msgType = getMsgTypeByFileFormat(filePath.url); } else if ([FileType.IMAGE].includes(fileType)) { msgType = 3; + content = filePath.url; } else if ([FileType.AUDIO].includes(fileType)) { msgType = 34; + content = JSON.stringify({ + url: filePath.url, + durationMs: filePath.durationMs, + }); } else if ([FileType.FILE].includes(fileType)) { - msgType = 49; + msgType = getMsgTypeByFileFormat(filePath.url); + if (msgType === 3) { + content = filePath.url; + } + if (msgType === 43) { + content = filePath.url; + } + + if (msgType === 49) { + content = JSON.stringify({ + type: "file", + title: filePath.name, + url: filePath.url, + }); + } } + const messageId = +Date.now(); const params = { wechatAccountId: contract.wechatAccountId, @@ -275,10 +297,37 @@ const MessageEnter: React.FC = ({ contract }) => { wechatFriendId: contract?.chatroomId ? 0 : contract.id, msgSubType: 0, msgType, - content: [FileType.AUDIO].includes(fileType) - ? JSON.stringify(filePath) - : filePath, + content: content, + seq: messageId, }; + + // 构造本地消息对象 + const localMessage: ChatRecord = { + id: messageId, // 使用时间戳作为临时ID + wechatAccountId: contract.wechatAccountId, + wechatFriendId: contract?.chatroomId ? 0 : contract.id, + wechatChatroomId: contract?.chatroomId ? contract.id : 0, + tenantId: 0, + accountId: 0, + synergyAccountId: 0, + content: params.content, + msgType: msgType, + msgSubType: 0, + msgSvrId: "", + isSend: true, // 标记为发送中 + createTime: new Date().toISOString(), + isDeleted: false, + deleteTime: "", + sendStatus: 1, + wechatTime: Date.now(), + origin: 0, + msgId: 0, + recalled: false, + seq: messageId, + }; + // 先插入本地数据 + addMessage(localMessage); + sendCommand("CmdSendMessage", params); }; @@ -349,10 +398,10 @@ const MessageEnter: React.FC = ({ contract }) => {
- handleFileUploaded(filePath, FileType.FILE) + onFileUploaded={fileInfo => + handleFileUploaded(fileInfo, FileType.FILE) } - maxSize={1} + maxSize={10} type={4} slot={ , - , - ]} - width={800} - > -
- {/* 左侧素材分类 */} -
-
-

公共素材

-
-
-
- 暗黑4 -
-
- 针对老客户的... -
-
- D2辅助 -
-
- ROS反馈演示... -
-
- 一键宏产品素... -
-
-
-

部门素材

-
-
- - {/* 右侧内容区域 */} -
-
- -
-
- 请选择左侧素材分类 -
-
-
- + 、 ); }; diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageRecord/components/VideoMessage/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageRecord/components/VideoMessage/index.tsx index 1edbcd30..a2c5252b 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageRecord/components/VideoMessage/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageRecord/components/VideoMessage/index.tsx @@ -57,24 +57,22 @@ const VideoMessage: React.FC = ({ // 如果content是直接的视频链接(已预览过或下载好的视频) if (isDirectVideoLink(content)) { return ( -
-
- + ); @@ -109,24 +107,22 @@ const VideoMessage: React.FC = ({ // 如果已有视频URL,显示视频播放器 if (videoData.videoUrl) { return ( -
-
- + ); @@ -134,38 +130,36 @@ const VideoMessage: React.FC = ({ // 显示预览图,根据加载状态显示不同的图标 return ( -
-
-
handlePlayClick(e, msg)} - > - 视频预览 { - const target = e.target as HTMLImageElement; - const parent = target.parentElement?.parentElement; - if (parent) { - parent.innerHTML = `
[视频预览加载失败]
`; - } - }} - /> -
- {videoData.isLoading ? ( -
- ) : ( - - )} -
+
+
handlePlayClick(e, msg)} + > + 视频预览 { + const target = e.target as HTMLImageElement; + const parent = target.parentElement?.parentElement; + if (parent) { + parent.innerHTML = `
[视频预览加载失败]
`; + } + }} + /> +
+ {videoData.isLoading ? ( +
+ ) : ( + + )}
diff --git a/Touchkebao/src/store/module/websocket/msgManage.ts b/Touchkebao/src/store/module/websocket/msgManage.ts index bbb1e4e1..82058dc9 100644 --- a/Touchkebao/src/store/module/websocket/msgManage.ts +++ b/Touchkebao/src/store/module/websocket/msgManage.ts @@ -53,7 +53,7 @@ const messageHandlers: Record = { } }, CmdSendMessageResult: message => { - updateMessage(message.friendMessageId, { + updateMessage(message.friendMessageId || message.chatroomMessageId, { sendStatus: 0, }); },