diff --git a/src/expert/index.tsx b/src/expert/index.tsx
index e2fdf23..fcb95cc 100644
--- a/src/expert/index.tsx
+++ b/src/expert/index.tsx
@@ -3,7 +3,7 @@ import {pageCmsArticle} from "@/api/cms/cmsArticle";
import {CmsArticle} from "@/api/cms/cmsArticle/model";
import Taro from '@tarojs/taro'
import {useRouter} from '@tarojs/taro'
-import {Image} from '@nutui/nutui-react-taro'
+import {Image,InfiniteLoading} from '@nutui/nutui-react-taro'
import {getCmsNavigation} from "@/api/cms/cmsNavigation";
import {CmsNavigation} from "@/api/cms/cmsNavigation/model";
@@ -39,7 +39,7 @@ const Index = () => {
}, [])
return (
-
+
@@ -91,7 +91,7 @@ const Index = () => {
}
-
+
)
}
export default Index
diff --git a/src/honor/list.tsx b/src/honor/list.tsx
index f0b4227..b973b13 100644
--- a/src/honor/list.tsx
+++ b/src/honor/list.tsx
@@ -3,7 +3,7 @@ import {pageCmsArticle} from "@/api/cms/cmsArticle";
import {CmsArticle} from "@/api/cms/cmsArticle/model";
import Taro from '@tarojs/taro'
import {useRouter} from '@tarojs/taro'
-import {Image} from '@nutui/nutui-react-taro'
+import {Image,InfiniteLoading} from '@nutui/nutui-react-taro'
import {getCmsNavigation} from "@/api/cms/cmsNavigation";
import {CmsNavigation} from "@/api/cms/cmsNavigation/model";
@@ -22,7 +22,7 @@ const List = () => {
// 当前栏目信息
const navs = await getCmsNavigation(categoryId);
// 终极新闻列表
- const articles = await pageCmsArticle({categoryId,limit: 50});
+ const articles = await pageCmsArticle({categoryId, limit: 50});
// 当前栏目信息
if (navs) {
@@ -39,7 +39,7 @@ const List = () => {
}, [])
return (
-
+
@@ -52,7 +52,7 @@ const List = () => {
backgroundSize: '100%',
backgroundRepeat: 'no-repeat',
width: '100%',
- height: '70px',
+ height: '67px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
@@ -60,7 +60,7 @@ const List = () => {
>
{/* 标题 */}
{navigation?.categoryName}
@@ -85,19 +85,16 @@ const List = () => {
>
{
// 图片容器
- item.image && (
-
-

-
- )
+ item.image ? (
+
+
+
+ ) :
+
}
{/* 标题 */}
{
}
-
+
)
}
export default List
diff --git a/src/pages/ai/index.tsx b/src/pages/ai/index.tsx
index eac60f6..2193efe 100644
--- a/src/pages/ai/index.tsx
+++ b/src/pages/ai/index.tsx
@@ -2,7 +2,7 @@ import {useEffect, useState, useRef} from "react";
import {View, Textarea} from '@tarojs/components';
import Taro from '@tarojs/taro';
import {Button} from '@nutui/nutui-react-taro';
-import {User, ArrowUp} from '@nutui/icons-react-taro';
+import {User, ArrowUp, Home} from '@nutui/icons-react-taro';
import {sendAiMessage, stopAiMessage} from '@/api/ai';
import {createWebSocket} from '@/utils/websocket';
import {getAiToken} from '@/utils/aiToken';
@@ -29,6 +29,7 @@ const AiChat = () => {
const [isLoading, setIsLoading] = useState(false);
const [currentTaskId, setCurrentTaskId] = useState('');
const [wsConnected, setWsConnected] = useState(false);
+ const [isInitialized, setIsInitialized] = useState(false);
const messagesEndRef = useRef(null);
const wsRef = useRef(null);
@@ -45,6 +46,18 @@ const AiChat = () => {
return getAiToken();
};
+ // 调试函数:检查输入框状态
+ const debugInputStatus = () => {
+ console.log('输入框状态调试:', {
+ isInitialized,
+ isLoading,
+ wsConnected,
+ inputValue,
+ inputDisabled: !isInitialized || isLoading,
+ sendButtonDisabled: !isInitialized || !inputValue.trim()
+ });
+ };
+
// 滚动到底部
const scrollToBottom = () => {
// 检查并确保AI_TOKEN存在
@@ -57,7 +70,9 @@ const AiChat = () => {
// 初始化WebSocket连接
const initWebSocket = () => {
- wsRef.current = createWebSocket(WSS_API_URL + "/chat/" + Taro.getStorageSync('AI_TOKEN'));
+ const userToken = Taro.getStorageSync('AI_TOKEN') || 'anonymous';
+ console.log(WSS_API_URL + "/chat/" + userToken, 'wsUrl');
+ wsRef.current = createWebSocket(WSS_API_URL + "/chat/" + userToken);
wsRef.current.onMessage((data: any) => {
console.log('收到WebSocket消息:', data);
@@ -145,10 +160,25 @@ const AiChat = () => {
useEffect(() => {
// 初始化时检查并生成AI Token
- checkAiToken();
+ const token = checkAiToken();
+ console.log('AI Token初始化完成:', token);
+
+ // 检查userToken
+ const userToken = Taro.getStorageSync('AI_TOKEN');
+ console.log('当前UserToken:', userToken || 'anonymous');
+
+ // 初始化WebSocket
initWebSocket();
Taro.hideTabBar();
+ // 标记初始化完成
+ setIsInitialized(true);
+
+ // 延迟调试,确保状态更新完成
+ setTimeout(() => {
+ debugInputStatus();
+ }, 100);
+
return () => {
if (wsRef.current) {
wsRef.current.close();
@@ -190,7 +220,7 @@ const AiChat = () => {
type: 'user',
query: content.trim(),
timestamp: Date.now(),
- user: `${Taro.getStorageSync('AI_TOKEN')}`
+ user: `${Taro.getStorageSync('AI_TOKEN') || 'anonymous'}`
};
// 立即添加用户消息
@@ -211,7 +241,7 @@ const AiChat = () => {
try {
await sendAiMessage({
query: content.trim(),
- user: `${Taro.getStorageSync('AI_TOKEN')}`,
+ user: `${Taro.getStorageSync('AI_TOKEN') || 'anonymous'}`,
responseMode: 'streaming',
aiToken: aiToken, // 包含AI Token
});
@@ -257,6 +287,14 @@ const AiChat = () => {
// 处理快捷问题点击
const handleQuickQuestion = (question: string) => {
+ if (!isInitialized) {
+ Taro.showToast({
+ title: '正在初始化,请稍候...',
+ icon: 'none',
+ duration: 2000
+ });
+ return;
+ }
handleSendMessage(question);
};
@@ -339,10 +377,13 @@ const AiChat = () => {