新增自定义ai问片默认消息
This commit is contained in:
@@ -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') ? '保存中...' : '保存个性化配置'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -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 = ({
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
{/* AI默认消息配置 */}
|
||||
<details className='p-4 border border-gray-200 dark:border-gray-700 rounded-lg'>
|
||||
<summary className='text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer'>
|
||||
默认消息配置 (可选)
|
||||
</summary>
|
||||
<div className='mt-4 space-y-4'>
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
|
||||
无视频时的默认消息
|
||||
</label>
|
||||
<textarea
|
||||
value={defaultMessageNoVideo}
|
||||
onChange={(e) => 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'
|
||||
/>
|
||||
<p className='mt-2 text-sm text-gray-600 dark:text-gray-400'>
|
||||
当用户在首页或没有视频上下文时打开AI问片,将显示此默认消息
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
|
||||
有视频时的默认消息
|
||||
</label>
|
||||
<textarea
|
||||
value={defaultMessageWithVideo}
|
||||
onChange={(e) => 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'
|
||||
/>
|
||||
<p className='mt-2 text-sm text-gray-600 dark:text-gray-400'>
|
||||
当用户在视频卡片或播放页打开AI问片时,将显示此默认消息。支持使用 <code className='px-1.5 py-0.5 bg-gray-100 dark:bg-gray-700 rounded text-xs font-mono'>{'{title}'}</code> 替换符来显示片名
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
{/* 保存按钮 */}
|
||||
@@ -9690,9 +9738,9 @@ function AdminPageClient() {
|
||||
<RegistrationConfigComponent config={config} refreshConfig={fetchConfig} />
|
||||
</CollapsibleTab>
|
||||
|
||||
{/* 主题配置标签 */}
|
||||
{/* 个性化配置标签 */}
|
||||
<CollapsibleTab
|
||||
title='主题配置'
|
||||
title='个性化配置'
|
||||
icon={
|
||||
<Palette
|
||||
size={20}
|
||||
|
||||
@@ -61,6 +61,8 @@ export async function POST(request: NextRequest) {
|
||||
Temperature,
|
||||
MaxTokens,
|
||||
SystemPrompt,
|
||||
DefaultMessageNoVideo,
|
||||
DefaultMessageWithVideo,
|
||||
} = body as {
|
||||
Enabled: boolean;
|
||||
Provider: 'openai' | 'claude' | 'custom';
|
||||
@@ -94,6 +96,8 @@ export async function POST(request: NextRequest) {
|
||||
Temperature?: number;
|
||||
MaxTokens?: number;
|
||||
SystemPrompt?: string;
|
||||
DefaultMessageNoVideo?: string;
|
||||
DefaultMessageWithVideo?: string;
|
||||
};
|
||||
|
||||
// 参数校验
|
||||
@@ -178,6 +182,8 @@ export async function POST(request: NextRequest) {
|
||||
Temperature,
|
||||
MaxTokens,
|
||||
SystemPrompt,
|
||||
DefaultMessageNoVideo,
|
||||
DefaultMessageWithVideo,
|
||||
};
|
||||
|
||||
// 写入数据库
|
||||
|
||||
@@ -54,6 +54,8 @@ export async function GET(request: NextRequest) {
|
||||
AIEnableHomepageEntry: config.AIConfig?.EnableHomepageEntry || false,
|
||||
AIEnableVideoCardEntry: config.AIConfig?.EnableVideoCardEntry || false,
|
||||
AIEnablePlayPageEntry: config.AIConfig?.EnablePlayPageEntry || false,
|
||||
AIDefaultMessageNoVideo: config.AIConfig?.DefaultMessageNoVideo || '',
|
||||
AIDefaultMessageWithVideo: config.AIConfig?.DefaultMessageWithVideo || '',
|
||||
};
|
||||
return NextResponse.json(result);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,8 @@ export default async function RootLayout({
|
||||
let aiEnableHomepageEntry = false;
|
||||
let aiEnableVideoCardEntry = false;
|
||||
let aiEnablePlayPageEntry = false;
|
||||
let aiDefaultMessageNoVideo = '';
|
||||
let aiDefaultMessageWithVideo = '';
|
||||
let customCategories = [] as {
|
||||
name: string;
|
||||
type: 'movie' | 'tv';
|
||||
@@ -119,6 +121,8 @@ export default async function RootLayout({
|
||||
aiEnableHomepageEntry = config.AIConfig?.EnableHomepageEntry || false;
|
||||
aiEnableVideoCardEntry = config.AIConfig?.EnableVideoCardEntry || false;
|
||||
aiEnablePlayPageEntry = config.AIConfig?.EnablePlayPageEntry || false;
|
||||
aiDefaultMessageNoVideo = config.AIConfig?.DefaultMessageNoVideo || '';
|
||||
aiDefaultMessageWithVideo = config.AIConfig?.DefaultMessageWithVideo || '';
|
||||
// 检查是否启用了 OpenList 功能
|
||||
openListEnabled = !!(
|
||||
config.OpenListConfig?.Enabled &&
|
||||
@@ -165,6 +169,8 @@ export default async function RootLayout({
|
||||
AI_ENABLE_HOMEPAGE_ENTRY: aiEnableHomepageEntry,
|
||||
AI_ENABLE_VIDEOCARD_ENTRY: aiEnableVideoCardEntry,
|
||||
AI_ENABLE_PLAYPAGE_ENTRY: aiEnablePlayPageEntry,
|
||||
AI_DEFAULT_MESSAGE_NO_VIDEO: aiDefaultMessageNoVideo,
|
||||
AI_DEFAULT_MESSAGE_WITH_VIDEO: aiDefaultMessageWithVideo,
|
||||
ENABLE_SOURCE_SEARCH: process.env.NEXT_PUBLIC_ENABLE_SOURCE_SEARCH !== 'false',
|
||||
};
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ function HomeClient() {
|
||||
const [showHttpWarning, setShowHttpWarning] = useState(true);
|
||||
const [showAIChat, setShowAIChat] = useState(false);
|
||||
const [aiEnabled, setAiEnabled] = useState(false);
|
||||
const [aiDefaultMessageNoVideo, setAiDefaultMessageNoVideo] = useState('你好!我是MoonTVPlus的AI影视助手。想看什么电影或剧集?需要推荐吗?');
|
||||
const [sourceSearchEnabled, setSourceSearchEnabled] = useState(true);
|
||||
|
||||
// 加载首页模块配置
|
||||
@@ -102,6 +103,12 @@ function HomeClient() {
|
||||
(window as any).RUNTIME_CONFIG?.AI_ENABLED &&
|
||||
(window as any).RUNTIME_CONFIG?.AI_ENABLE_HOMEPAGE_ENTRY;
|
||||
setAiEnabled(enabled);
|
||||
|
||||
// 加载AI默认消息配置
|
||||
const defaultMsg = (window as any).RUNTIME_CONFIG?.AI_DEFAULT_MESSAGE_NO_VIDEO;
|
||||
if (defaultMsg) {
|
||||
setAiDefaultMessageNoVideo(defaultMsg);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -591,7 +598,7 @@ function HomeClient() {
|
||||
<AIChatPanel
|
||||
isOpen={showAIChat}
|
||||
onClose={() => setShowAIChat(false)}
|
||||
welcomeMessage='你好!我是MoonTVPlus的AI影视助手。想看什么电影或剧集?需要推荐吗?'
|
||||
welcomeMessage={aiDefaultMessageNoVideo}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
@@ -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}》的更多信息吗?我可以帮你查询剧情、演员、评价等。`}
|
||||
/>
|
||||
)}
|
||||
</PageLayout>
|
||||
|
||||
@@ -263,16 +263,16 @@ export default function AIChatPanel({
|
||||
<div className='relative mx-4 my-auto flex h-[85vh] sm:h-[80vh] max-h-[90vh] sm:max-h-[600px] w-full max-w-3xl flex-col rounded-2xl bg-white shadow-2xl dark:bg-gray-900'>
|
||||
{/* 头部 */}
|
||||
<div className='flex items-center justify-between border-b border-gray-200 p-4 dark:border-gray-700'>
|
||||
<div className='flex items-center gap-3'>
|
||||
<div className='flex h-10 w-10 items-center justify-center rounded-full bg-purple-500'>
|
||||
<div className='flex items-center gap-3 min-w-0 flex-1'>
|
||||
<div className='flex h-10 w-10 items-center justify-center rounded-full bg-purple-500 flex-shrink-0'>
|
||||
<Sparkles size={20} className='text-white' />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className='text-lg font-semibold text-gray-900 dark:text-white'>
|
||||
<div className='min-w-0 flex-1'>
|
||||
<h2 className='text-lg font-semibold text-gray-900 dark:text-white'>
|
||||
AI影视助手
|
||||
</h2>
|
||||
{context?.title && (
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400'>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400 truncate'>
|
||||
正在讨论: {context.title}
|
||||
{context.year && ` (${context.year})`}
|
||||
</p>
|
||||
@@ -281,9 +281,9 @@ export default function AIChatPanel({
|
||||
</div>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className='rounded-lg p-2 text-gray-500 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800'
|
||||
className='rounded-lg p-2 text-gray-500 transition-colors hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800 flex-shrink-0'
|
||||
>
|
||||
<X size={20} />
|
||||
<X size={20} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ const VideoCard = forwardRef<VideoCardHandle, VideoCardProps>(function VideoCard
|
||||
const [searchFavorited, setSearchFavorited] = useState<boolean | null>(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<VideoCardHandle, VideoCardProps>(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<VideoCardHandle, VideoCardProps>(function VideoCard
|
||||
type: actualSearchType as 'movie' | 'tv',
|
||||
currentEpisode,
|
||||
}}
|
||||
welcomeMessage={`想了解《${actualTitle}》的更多信息吗?我可以帮你查询剧情、演员、评价等。`}
|
||||
welcomeMessage={aiDefaultMessageWithVideo ? aiDefaultMessageWithVideo.replace('{title}', actualTitle || '') : `想了解《${actualTitle}》的更多信息吗?我可以帮你查询剧情、演员、评价等。`}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
@@ -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?: {
|
||||
// 新格式:多源配置(推荐)
|
||||
|
||||
Reference in New Issue
Block a user