This commit is contained in:
2026-03-11 00:42:46 +08:00
parent a125b5922f
commit a12cb5e75a
23 changed files with 1593 additions and 101 deletions

View File

@@ -26,6 +26,12 @@
</button>
</transition>
</div>
<!-- 我创建的 -->
<button class="favorites-btn" @click="showFavoritesModal = true">
<StarFilled class="favorites-btn-icon" />
<span class="favorites-btn-text">我创建的</span>
</button>
</div>
<!-- 精简分类筛选 -->
@@ -183,6 +189,12 @@
:agent-id="historyAgentId"
@close="closeHistoryPanel"
/>
<MyFavoritesModal
v-model:visible="showFavoritesModal"
@chat="handleChat"
@remove="handleFavoriteRemoved"
/>
</FullWidthLayout>
</template>
@@ -202,6 +214,7 @@ import { message } from 'ant-design-vue'
import FullWidthLayout from '@/layouts/components/FullWidthLayout.vue'
import ChatDrawer from '@/components/agents/ChatDrawer.vue'
import HistoryPanel from '@/components/agents/HistoryPanel.vue'
import MyFavoritesModal from '@/components/agents/MyFavoritesModal.vue'
import { getAgentList, addFavorite, removeFavorite } from '@/api/agent'
// 状态管理
@@ -216,6 +229,7 @@ const showCategoryPanel = ref(false)
const panelTop = ref(0)
const historyPanelVisible = ref(false)
const historyAgentId = ref(null)
const showFavoritesModal = ref(false)
// 面板样式
const panelStyle = computed(() => ({
@@ -385,6 +399,15 @@ const handleFavorite = async (agent) => {
}
}
// 收藏被移除的回调
const handleFavoriteRemoved = (agent) => {
// 同步更新列表中的收藏状态
const target = agentList.value.find(a => a.id === agent.id)
if (target) {
target.isFavorite = false
}
}
// 初始化
onMounted(() => {
fetchAgentList()
@@ -459,14 +482,18 @@ onMounted(() => {
// 搜索区域 - 核心焦点
// ============================================
.search-hero {
max-width: 480px;
max-width: 560px;
margin: 0 auto 28px;
display: flex;
align-items: center;
gap: 12px;
}
.search-input-group {
position: relative;
display: flex;
align-items: center;
flex: 1;
}
.search-icon {
@@ -532,6 +559,46 @@ onMounted(() => {
}
}
// ============================================
// 收藏按钮
// ============================================
.favorites-btn {
flex-shrink: 0;
display: inline-flex;
align-items: center;
gap: 6px;
padding: 0 16px;
height: 52px;
border: 1px solid var(--color-gray-300);
border-radius: var(--radius-lg);
background: var(--color-bg-card);
cursor: pointer;
transition: all var(--duration-fast);
box-shadow: var(--shadow-sm);
&:hover {
border-color: #f59e0b;
background: #fffbeb;
box-shadow: var(--shadow-md);
}
&:active {
transform: scale(0.98);
}
}
.favorites-btn-icon {
font-size: 18px;
color: #f59e0b;
}
.favorites-btn-text {
font-size: 14px;
font-weight: 500;
color: var(--color-gray-700);
white-space: nowrap;
}
// ============================================
// 分类筛选 - 精简胶囊
// ============================================

View File

@@ -429,8 +429,6 @@ async function handleSmsLogin() {
</script>
<style scoped lang="less">
/* ========== 导入字体 ========== */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=DM+Sans:wght@400;500;600&display=swap');
/* ========== CSS变量 ========== */
@primary-gold: #D4A853;

View File

@@ -2,8 +2,7 @@
import { ref, watch } from 'vue'
import { message } from 'ant-design-vue'
import ChatMessageRendererV2 from '@/components/ChatMessageRendererV2.vue'
import { ChatMessageApi } from '@/api/chat'
import { streamChat } from '@/utils/streamChat'
import { benchmarkAnalyzeStream } from '@/api/dify'
const props = withDefaults(defineProps<{
visible: boolean
@@ -52,35 +51,29 @@ async function generateBatchPrompt() {
if (!props.mergedText || hasGenerated.value) return
hasGenerated.value = true
const ctrl = new AbortController()
try {
batchPromptGenerating.value = true
const conversationId = await createConversation()
const aiContent = await streamChat({
conversationId,
await benchmarkAnalyzeStream({
content: props.mergedText,
onUpdate: (fullText: string) => {
videoCount: props.textCount,
ctrl,
onMessage: (fullText: string) => {
batchPrompt.value = fullText
},
enableTypewriter: true,
typewriterSpeed: 10,
typewriterBatchSize: 2,
onComplete: () => {},
onError: (error: Error) => {
console.error('流式聊天错误:', error)
console.error('对标分析错误:', error)
message.error('AI生成失败请稍后重试')
},
enableContext: false,
enableWebSearch: false,
timeout: 180000,
attachmentUrls: []
onComplete: (fullText: string) => {
if (fullText && fullText !== batchPrompt.value) {
batchPrompt.value = fullText
}
message.success(`批量分析完成:已基于 ${props.textCount} 个视频的文案生成综合提示词`)
}
})
if (aiContent && aiContent !== batchPrompt.value) {
batchPrompt.value = aiContent
}
message.success(`批量分析完成:已基于 ${props.textCount} 个视频的文案生成综合提示词`)
} catch (error) {
console.error('AI生成失败:', error)
message.error('AI生成失败请稍后重试')
@@ -90,21 +83,6 @@ async function generateBatchPrompt() {
}
}
async function createConversation() {
const createPayload = { roleId: 20 }
const conversationResp = await ChatMessageApi.createChatConversationMy(createPayload)
const conversationId = conversationResp?.data
? (typeof conversationResp.data === 'object' ? conversationResp.data.id : conversationResp.data)
: null
if (!conversationId) {
throw new Error('创建对话失败:未获取到 conversationId')
}
return conversationId
}
function handleClose() {
emit('update:visible', false)
}

View File

@@ -195,7 +195,6 @@
<!-- 音色选择 -->
<div class="input-section">
<label class="input-label">选择音色</label>
<VoiceSelector
:synth-text="store.text"
:speech-rate="store.speechRate"

View File

@@ -4,11 +4,11 @@ import { message } from 'ant-design-vue'
import TikhubService, { InterfaceType, MethodType, ParamType } from '@/api/tikhub'
import { rewriteStream } from '@/api/forecast'
import { getAgentList } from '@/api/agent'
import { useUserStore } from '@/stores/user'
import { usePointsConfigStore } from '@/stores/pointsConfig'
import { getVoiceText } from '@/hooks/web/useVoiceText'
import { copyToClipboard } from '@/utils/clipboard'
import StyleSelector from '@/components/StyleSelector.vue'
defineOptions({ name: 'ForecastView' })
@@ -47,22 +47,12 @@ const topicDetails = reactive({
// 智能体列表
const agentList = ref([])
const loadingAgents = ref(false)
const agentSearchKeyword = ref('')
// 当前选中的智能体
const selectedAgent = ref(null)
// 过滤后的智能体列表
const filteredAgentList = computed(() => {
if (!agentSearchKeyword.value.trim()) {
return agentList.value
}
const keyword = agentSearchKeyword.value.trim().toLowerCase()
return agentList.value.filter(agent =>
agent.name.toLowerCase().includes(keyword) ||
(agent.description && agent.description.toLowerCase().includes(keyword))
)
})
// 当前选中的风格类型
const selectedStyleType = ref('agent')
// 工具函数
function formatNumber(num) {
@@ -99,7 +89,7 @@ async function copyContent() {
}
}
// 加载智能体列表
// 加载智能体列表(保留用于其他逻辑)
async function loadAgentList() {
loadingAgents.value = true
try {
@@ -112,13 +102,9 @@ async function loadAgentList() {
description: item.description,
systemPrompt: item.systemPrompt,
avatar: item.icon,
categoryName: item.categoryName || '其他'
categoryName: item.categoryName || '其他',
isFavorite: item.isFavorite || false
}))
// 默认选中第一个
if (agentList.value.length > 0 && !topicDetails.selectedAgentId) {
topicDetails.selectedAgentId = agentList.value[0].id
selectedAgent.value = agentList.value[0]
}
}
} catch (error) {
console.error('加载智能体列表失败:', error)
@@ -127,12 +113,28 @@ async function loadAgentList() {
}
}
// 处理智能体选择
function handleAgentChange(agentId) {
const agent = agentList.value.find(a => a.id === agentId)
if (agent) {
selectedAgent.value = agent
topicDetails.selectedAgentId = agentId
// 处理风格选择变化
function handleStyleChange(data) {
if (!data) {
selectedAgent.value = null
selectedStyleType.value = null
return
}
const { id, type, item } = data
selectedStyleType.value = type
topicDetails.selectedAgentId = id
if (type === 'agent') {
// 选择的是智能体
selectedAgent.value = item
} else if (type === 'prompt') {
// 选择的是用户风格
selectedAgent.value = {
id: item.id,
name: item.name,
systemPrompt: item.content
}
}
}
@@ -206,8 +208,8 @@ async function handleGenerate() {
}
}, 180000)
rewriteStream({
agentId: selectedAgent.value.id,
// 构建请求参数
const requestOptions = {
userText: topicDetails.copywriting.trim(),
level: topicDetails.level,
modelType: topicDetails.modelType,
@@ -245,7 +247,18 @@ async function handleGenerate() {
resolve()
}
}
})
}
// 根据风格类型设置参数
if (selectedStyleType.value === 'prompt') {
// 使用用户风格
requestOptions.customSystemPrompt = selectedAgent.value.systemPrompt
} else {
// 使用智能体
requestOptions.agentId = selectedAgent.value.id
}
rewriteStream(requestOptions)
})
generatedContent.value = fullText.trim()
@@ -369,6 +382,7 @@ async function handleSearch() {
// 初始化
onMounted(() => {
// 加载智能体列表用于后续逻辑
loadAgentList()
pointsConfigStore.loadConfig()
})
@@ -537,25 +551,12 @@ onMounted(() => {
<!-- 风格选择 -->
<div class="form-block">
<label>文案风格</label>
<a-select
v-model:value="topicDetails.selectedAgentId"
<StyleSelector
v-model="topicDetails.selectedAgentId"
placeholder="选择风格"
style="width: 100%"
:loading="loadingAgents"
show-search
:filter-option="false"
@change="handleAgentChange"
@search="agentSearchKeyword = $event"
>
<a-select-option
v-for="agent in filteredAgentList"
:key="agent.id"
:value="agent.id"
>
<span>{{ agent.name }}</span>
<span class="agent-category">{{ agent.categoryName }}</span>
</a-select-option>
</a-select>
storage-key="forecast_style"
@change="handleStyleChange"
/>
</div>
<!-- 模式 & 幅度 -->