From 6f3e634355fd3e69facda7e80a0a38b19e14de93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Fri, 11 Jul 2025 13:45:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=EF=BC=9A=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.config.ts | 7 ++ src/article/index.tsx | 2 +- src/honor/list.tsx | 2 +- src/pages/ai/index.scss | 108 +++++++++++++++++++++- src/pages/ai/index.tsx | 111 +++++++++++------------ src/photo/index.tsx | 2 +- src/zzjy/detail.config.ts | 4 + src/zzjy/detail.scss | 6 ++ src/zzjy/detail.tsx | 50 ++++++++++ src/zzjy/index.config.ts | 5 + src/zzjy/index.scss | 186 ++++++++++++++++++++++++++++++++++++++ src/zzjy/index.tsx | 91 +++++++++++++++++++ 12 files changed, 510 insertions(+), 64 deletions(-) create mode 100644 src/zzjy/detail.config.ts create mode 100644 src/zzjy/detail.scss create mode 100644 src/zzjy/detail.tsx create mode 100644 src/zzjy/index.config.ts create mode 100644 src/zzjy/index.scss create mode 100644 src/zzjy/index.tsx diff --git a/src/app.config.ts b/src/app.config.ts index 7d45227..dc3297e 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -57,6 +57,13 @@ export default defineAppConfig({ "detail" ] }, + { + "root": "zzjy", + "pages": [ + "index", + "detail" + ] + }, ], window: { backgroundTextStyle: 'dark', diff --git a/src/article/index.tsx b/src/article/index.tsx index 405b85b..fab8fce 100644 --- a/src/article/index.tsx +++ b/src/article/index.tsx @@ -60,7 +60,7 @@ const Index = () => {
Taro.navigateTo({url: `./index?id=${item.navigationId}`})} + onClick={() => Taro.navigateTo({url: `/${item.model}/index?id=${item.navigationId}`})} > {/* 图片容器 */}
diff --git a/src/honor/list.tsx b/src/honor/list.tsx index b973b13..d356a77 100644 --- a/src/honor/list.tsx +++ b/src/honor/list.tsx @@ -102,8 +102,8 @@ const List = () => { }}>

{item.title}

{item.comments || '暂无'}

diff --git a/src/pages/ai/index.scss b/src/pages/ai/index.scss index 39e932f..9a6455c 100644 --- a/src/pages/ai/index.scss +++ b/src/pages/ai/index.scss @@ -149,6 +149,108 @@ html { .message-text { flex: 1; white-space: pre-wrap; + + .message-markdown { + // 通用Markdown样式 + .markdown-paragraph { + margin-bottom: 8px; + } + + .markdown-list-item, + .markdown-ordered-list-item { + margin-bottom: 4px; + } + + .markdown-heading { + margin: 12px 0 6px 0; + + &.markdown-h1 { + font-size: 1.2rem; + border-bottom: 1px solid #ddd; + padding-bottom: 2px; + } + + &.markdown-h2 { + font-size: 1.1rem; + } + + &.markdown-h3 { + font-size: 1rem; + } + } + + // AI消息特定样式 + &.ai-markdown { + .markdown-code-block { + background-color: #f8f9fa; + border: 1px solid #e9ecef; + border-radius: 4px; + padding: 8px; + margin: 8px 0; + font-size: 0.9rem; + } + + .markdown-inline-code { + background-color: #f1f3f4; + padding: 2px 4px; + border-radius: 3px; + font-size: 0.9rem; + color: #d73a49; + } + + .markdown-blockquote { + border-left: 3px solid #3498db; + padding-left: 8px; + margin: 8px 0; + background-color: rgba(52, 152, 219, 0.1); + } + + .markdown-link { + color: #3498db; + text-decoration: underline; + } + } + + // 用户消息特定样式 + &.user-markdown { + .markdown-code-block { + background-color: rgba(255, 255, 255, 0.2); + border: 1px solid rgba(255, 255, 255, 0.3); + border-radius: 4px; + padding: 8px; + margin: 8px 0; + font-size: 0.9rem; + } + + .markdown-inline-code { + background-color: rgba(255, 255, 255, 0.2); + padding: 2px 4px; + border-radius: 3px; + font-size: 0.9rem; + color: #fff; + } + + .markdown-blockquote { + border-left: 3px solid rgba(255, 255, 255, 0.5); + padding-left: 8px; + margin: 8px 0; + background-color: rgba(255, 255, 255, 0.1); + } + + .markdown-link { + color: #fff; + text-decoration: underline; + } + + .markdown-bold { + color: #fff; + } + + .markdown-text { + color: #fff; + } + } + } } .typing-cursor { @@ -194,10 +296,8 @@ html { .message-input { width: 100%; - min-height: 90px; - max-height: 120px; padding: 10px 16px; - border: 1px solid #e0e0e0; + border: 2px solid #424242; border-radius: 20px; font-size: 1rem; // 使用 rem 单位 line-height: 1.8; @@ -249,7 +349,7 @@ html { .stop-button { min-width: 60px; - height: 40px; + height: 60px; border-radius: 20px; background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%); border: none; diff --git a/src/pages/ai/index.tsx b/src/pages/ai/index.tsx index 2193efe..3ee910c 100644 --- a/src/pages/ai/index.tsx +++ b/src/pages/ai/index.tsx @@ -1,11 +1,14 @@ import {useEffect, useState, useRef} from "react"; -import {View, Textarea} from '@tarojs/components'; +import {Textarea} from '@tarojs/components'; import Taro from '@tarojs/taro'; import {Button} from '@nutui/nutui-react-taro'; -import {User, ArrowUp, Home} from '@nutui/icons-react-taro'; -import {sendAiMessage, stopAiMessage} from '@/api/ai'; +import {User, Home} from '@nutui/icons-react-taro'; +import {sendAiMessage} from '@/api/ai'; import {createWebSocket} from '@/utils/websocket'; import {getAiToken} from '@/utils/aiToken'; +import MarkdownRenderer from '@/components/MarkdownRenderer'; +// 显示html富文本 +import {View, RichText} from '@tarojs/components' import './index.scss'; import {WSS_API_URL} from "@/utils/server"; @@ -27,7 +30,7 @@ const AiChat = () => { const [messages, setMessages] = useState([]); const [inputValue, setInputValue] = useState(''); const [isLoading, setIsLoading] = useState(false); - const [currentTaskId, setCurrentTaskId] = useState(''); + // const [currentTaskId, setCurrentTaskId] = useState(''); const [wsConnected, setWsConnected] = useState(false); const [isInitialized, setIsInitialized] = useState(false); const messagesEndRef = useRef(null); @@ -84,7 +87,7 @@ const AiChat = () => { msg.isTyping ? {...msg, isTyping: false} : msg )); setIsLoading(false); - setCurrentTaskId(''); + // setCurrentTaskId(''); } else { // 实时更新AI回复消息 setMessages(prev => { @@ -109,7 +112,7 @@ const AiChat = () => { }); if (data.taskId) { - setCurrentTaskId(data.taskId); + // setCurrentTaskId(data.taskId); } } @@ -270,20 +273,20 @@ const AiChat = () => { }; // 停止AI回复 - const handleStopMessage = async () => { - if (currentTaskId) { - try { - await stopAiMessage({taskId: currentTaskId}); - setIsLoading(false); - setCurrentTaskId(''); - setMessages(prev => prev.map(msg => - msg.isTyping ? {...msg, isTyping: false} : msg - )); - } catch (error) { - console.error('停止消息失败:', error); - } - } - }; + // const handleStopMessage = async () => { + // if (currentTaskId) { + // try { + // await stopAiMessage({taskId: currentTaskId}); + // setIsLoading(false); + // setCurrentTaskId(''); + // setMessages(prev => prev.map(msg => + // msg.isTyping ? {...msg, isTyping: false} : msg + // )); + // } catch (error) { + // console.error('停止消息失败:', error); + // } + // } + // }; // 处理快捷问题点击 const handleQuickQuestion = (question: string) => { @@ -341,7 +344,10 @@ const AiChat = () => { - {message.query || (message.isTyping && message.type === 'ai' ? '正在思考中...' : '')} + {message.isTyping && message.type === 'ai' && message.query && ( | @@ -365,7 +371,10 @@ const AiChat = () => { className="question-item" onClick={() => handleQuickQuestion(question)} > - {question} + ))} @@ -373,45 +382,33 @@ const AiChat = () => { )} - -