diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index 67afa21..4080fae 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -5875,7 +5875,7 @@ const ConfigFileComponent = ({ ); }; -// 主题配置组件 +// 个性化配置组件 const ThemeConfigComponent = ({ config, refreshConfig, @@ -5986,7 +5986,7 @@ const ThemeConfigComponent = ({ showAlert({ type: 'success', title: '保存成功', - message: '主题配置已更新', + message: '个性化配置已更新', timer: 2000, }); @@ -6345,7 +6345,7 @@ const ThemeConfigComponent = ({ : buttonStyles.success } > - {isLoading('saveThemeConfig') ? '保存中...' : '保存主题配置'} + {isLoading('saveThemeConfig') ? '保存中...' : '保存个性化配置'} @@ -8377,6 +8377,10 @@ const AIConfigComponent = ({ const [maxTokens, setMaxTokens] = useState(1000); const [systemPrompt, setSystemPrompt] = useState(''); + // AI默认消息配置 + const [defaultMessageNoVideo, setDefaultMessageNoVideo] = useState(''); + const [defaultMessageWithVideo, setDefaultMessageWithVideo] = useState(''); + // 从配置加载数据 useEffect(() => { if (config?.AIConfig) { @@ -8397,6 +8401,8 @@ const AIConfigComponent = ({ setTemperature(config.AIConfig.Temperature ?? 0.7); setMaxTokens(config.AIConfig.MaxTokens ?? 1000); setSystemPrompt(config.AIConfig.SystemPrompt || ''); + setDefaultMessageNoVideo(config.AIConfig.DefaultMessageNoVideo || ''); + setDefaultMessageWithVideo(config.AIConfig.DefaultMessageWithVideo || ''); } }, [config]); @@ -8427,6 +8433,8 @@ const AIConfigComponent = ({ Temperature: temperature, MaxTokens: maxTokens, SystemPrompt: systemPrompt, + DefaultMessageNoVideo: defaultMessageNoVideo, + DefaultMessageWithVideo: defaultMessageWithVideo, }), }); @@ -8788,6 +8796,46 @@ const AIConfigComponent = ({ /> + + + {/* AI默认消息配置 */} + + + 默认消息配置 (可选) + + + + + 无视频时的默认消息 + + setDefaultMessageNoVideo(e.target.value)} + rows={3} + placeholder='例如:你好!我是MoonTVPlus的AI影视助手。想看什么电影或剧集?需要推荐吗?' + className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100' + /> + + 当用户在首页或没有视频上下文时打开AI问片,将显示此默认消息 + + + + + + 有视频时的默认消息 + + setDefaultMessageWithVideo(e.target.value)} + rows={3} + placeholder='例如:你好!我看到你正在浏览《{title}》,有什么想了解的吗?' + className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100' + /> + + 当用户在视频卡片或播放页打开AI问片时,将显示此默认消息。支持使用 {'{title}'} 替换符来显示片名 + + + {/* 保存按钮 */} @@ -9690,9 +9738,9 @@ function AdminPageClient() { - {/* 主题配置标签 */} + {/* 个性化配置标签 */} setShowAIChat(false)} - welcomeMessage='你好!我是MoonTVPlus的AI影视助手。想看什么电影或剧集?需要推荐吗?' + welcomeMessage={aiDefaultMessageNoVideo} /> )} diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index b9b785b..c6bdcb5 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -120,6 +120,7 @@ function PlayPageClient() { // AI问片状态 const [showAIChat, setShowAIChat] = useState(false); const [aiEnabled, setAiEnabled] = useState(false); + const [aiDefaultMessageWithVideo, setAiDefaultMessageWithVideo] = useState(''); // 检查AI功能是否启用 useEffect(() => { @@ -128,6 +129,12 @@ function PlayPageClient() { (window as any).RUNTIME_CONFIG?.AI_ENABLED && (window as any).RUNTIME_CONFIG?.AI_ENABLE_PLAYPAGE_ENTRY; setAiEnabled(enabled); + + // 加载AI默认消息配置 + const defaultMsg = (window as any).RUNTIME_CONFIG?.AI_DEFAULT_MESSAGE_WITH_VIDEO; + if (defaultMsg) { + setAiDefaultMessageWithVideo(defaultMsg); + } } }, []); @@ -7039,7 +7046,7 @@ function PlayPageClient() { douban_id: videoDoubanId !== 0 ? videoDoubanId : undefined, currentEpisode: currentEpisodeIndex + 1, }} - welcomeMessage={`想了解《${detail.title}》的更多信息吗?我可以帮你查询剧情、演员、评价等。`} + welcomeMessage={aiDefaultMessageWithVideo ? aiDefaultMessageWithVideo.replace('{title}', detail.title || '') : `想了解《${detail.title}》的更多信息吗?我可以帮你查询剧情、演员、评价等。`} /> )} diff --git a/src/components/AIChatPanel.tsx b/src/components/AIChatPanel.tsx index 8b20d7d..e0a1c43 100644 --- a/src/components/AIChatPanel.tsx +++ b/src/components/AIChatPanel.tsx @@ -263,16 +263,16 @@ export default function AIChatPanel({ {/* 头部 */} - - + + - - + + AI影视助手 {context?.title && ( - + 正在讨论: {context.title} {context.year && ` (${context.year})`} @@ -281,9 +281,9 @@ export default function AIChatPanel({ - + diff --git a/src/components/VideoCard.tsx b/src/components/VideoCard.tsx index acb32f9..e1da28a 100644 --- a/src/components/VideoCard.tsx +++ b/src/components/VideoCard.tsx @@ -110,6 +110,7 @@ const VideoCard = forwardRef(function VideoCard const [searchFavorited, setSearchFavorited] = useState(null); // 搜索结果的收藏状态 const [showAIChat, setShowAIChat] = useState(false); const [aiEnabled, setAiEnabled] = useState(false); + const [aiDefaultMessageWithVideo, setAiDefaultMessageWithVideo] = useState(''); const [showDetailPanel, setShowDetailPanel] = useState(false); // 检查AI功能是否启用 @@ -119,6 +120,12 @@ const VideoCard = forwardRef(function VideoCard (window as any).RUNTIME_CONFIG?.AI_ENABLED && (window as any).RUNTIME_CONFIG?.AI_ENABLE_VIDEOCARD_ENTRY; setAiEnabled(enabled); + + // 加载AI默认消息配置 + const defaultMsg = (window as any).RUNTIME_CONFIG?.AI_DEFAULT_MESSAGE_WITH_VIDEO; + if (defaultMsg) { + setAiDefaultMessageWithVideo(defaultMsg); + } } }, []); @@ -1468,7 +1475,7 @@ const VideoCard = forwardRef(function VideoCard type: actualSearchType as 'movie' | 'tv', currentEpisode, }} - welcomeMessage={`想了解《${actualTitle}》的更多信息吗?我可以帮你查询剧情、演员、评价等。`} + welcomeMessage={aiDefaultMessageWithVideo ? aiDefaultMessageWithVideo.replace('{title}', actualTitle || '') : `想了解《${actualTitle}》的更多信息吗?我可以帮你查询剧情、演员、评价等。`} /> )} diff --git a/src/lib/admin.types.ts b/src/lib/admin.types.ts index 6928bbf..e901fd7 100644 --- a/src/lib/admin.types.ts +++ b/src/lib/admin.types.ts @@ -154,6 +154,9 @@ export interface AdminConfig { Temperature?: number; // AI温度参数(0-2),默认0.7 MaxTokens?: number; // 最大回复token数,默认1000 SystemPrompt?: string; // 自定义系统提示词 + // AI问片默认消息配置 + DefaultMessageNoVideo?: string; // 无视频时的默认消息 + DefaultMessageWithVideo?: string; // 有视频时的默认消息(支持 {title} 替换符) }; EmbyConfig?: { // 新格式:多源配置(推荐)
+ 当用户在首页或没有视频上下文时打开AI问片,将显示此默认消息 +
+ 当用户在视频卡片或播放页打开AI问片时,将显示此默认消息。支持使用 {'{title}'} 替换符来显示片名 +
{'{title}'}
+
正在讨论: {context.title} {context.year && ` (${context.year})`}