feat: 优化
This commit is contained in:
@@ -15,21 +15,19 @@ import BenchmarkTable from './components/BenchmarkTable.vue'
|
||||
import BatchAnalyzeModal from './components/BatchAnalyzeModal.vue'
|
||||
import SavePromptModal from './components/SavePromptModal.vue'
|
||||
|
||||
// ==================== 初始化 ====================
|
||||
const router = useRouter()
|
||||
const promptStore = usePromptStore()
|
||||
|
||||
// ==================== 数据管理 ====================
|
||||
const {
|
||||
data,
|
||||
selectedRowKeys,
|
||||
expandedRowKeys,
|
||||
saveTableDataToSession,
|
||||
loadTableDataFromSession,
|
||||
processApiResponse,
|
||||
clearData,
|
||||
} = useBenchmarkData()
|
||||
|
||||
// ==================== 分析功能 ====================
|
||||
const {
|
||||
loading,
|
||||
batchAnalyzeLoading,
|
||||
@@ -37,9 +35,8 @@ const {
|
||||
globalLoadingText,
|
||||
batchAnalyze,
|
||||
getVoiceText,
|
||||
} = useBenchmarkAnalysis(data, saveTableDataToSession)
|
||||
} = useBenchmarkAnalysis(data, expandedRowKeys, saveTableDataToSession)
|
||||
|
||||
// ==================== 表单状态 ====================
|
||||
const form = ref({
|
||||
platform: '抖音',
|
||||
url: '',
|
||||
@@ -47,7 +44,6 @@ const form = ref({
|
||||
sort_type: 0,
|
||||
})
|
||||
|
||||
// ==================== 弹窗状态 ====================
|
||||
const modalVisible = ref(false)
|
||||
const batchPromptMergedText = ref('')
|
||||
const batchPromptTextCount = ref(0)
|
||||
@@ -55,10 +51,6 @@ const batchPromptTextCount = ref(0)
|
||||
const savePromptModalVisible = ref(false)
|
||||
const savePromptContent = ref('')
|
||||
|
||||
// ==================== API 调用函数 ====================
|
||||
/**
|
||||
* 分析用户主页,获取视频列表
|
||||
*/
|
||||
async function handleAnalyzeUser() {
|
||||
const sec_user_id = resolveId(form.value.url, {
|
||||
queryKeys: ['user'],
|
||||
@@ -94,16 +86,13 @@ async function handleAnalyzeUser() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出数据到 Excel
|
||||
*/
|
||||
async function handleExportToExcel() {
|
||||
if (!data.value || data.value.length === 0) {
|
||||
if (!data.value?.length) {
|
||||
message.warning('暂无数据可导出')
|
||||
return
|
||||
}
|
||||
|
||||
if (selectedRowKeys.value.length === 0) {
|
||||
if (!selectedRowKeys.value.length) {
|
||||
message.warning('请先选择要导出的行')
|
||||
return
|
||||
}
|
||||
@@ -116,15 +105,13 @@ async function handleExportToExcel() {
|
||||
const selectedRows = data.value.filter(item => selectedRowKeys.value.includes(item.id))
|
||||
const rowsNeedTranscription = selectedRows.filter(row => !row.transcriptions)
|
||||
|
||||
// 导出时只获取语音转写,不进行 AI 对话分析
|
||||
if (rowsNeedTranscription.length > 0) {
|
||||
if (rowsNeedTranscription.length) {
|
||||
globalLoading.value = true
|
||||
globalLoadingText.value = `正在分析中...`
|
||||
globalLoadingText.value = '正在分析中...'
|
||||
|
||||
try {
|
||||
const transcriptions = await getVoiceText(rowsNeedTranscription)
|
||||
|
||||
// 更新转写数据
|
||||
for (const row of rowsNeedTranscription) {
|
||||
const transcription = transcriptions.find(item => item.audio_url === row.audio_url)
|
||||
if (transcription) {
|
||||
@@ -163,9 +150,6 @@ async function handleExportToExcel() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量分析处理
|
||||
*/
|
||||
async function handleBatchAnalyze() {
|
||||
try {
|
||||
await batchAnalyze(selectedRowKeys, async (mergedText, textCount) => {
|
||||
@@ -174,22 +158,17 @@ async function handleBatchAnalyze() {
|
||||
modalVisible.value = true
|
||||
})
|
||||
} finally {
|
||||
// 批量分析完成后清空选中项(无论成功还是失败)
|
||||
selectedRowKeys.value = []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置表单
|
||||
*/
|
||||
async function handleResetForm() {
|
||||
form.value = { platform: '抖音', url: '', count: 20, sort_type: 0 }
|
||||
await clearData()
|
||||
}
|
||||
|
||||
// ==================== 批量提示词操作函数 ====================
|
||||
function handleCopyBatchPrompt(prompt) {
|
||||
if (!prompt || !prompt.trim()) {
|
||||
if (!prompt?.trim()) {
|
||||
message.warning('没有提示词可复制')
|
||||
return
|
||||
}
|
||||
@@ -202,7 +181,7 @@ function handleCopyBatchPrompt(prompt) {
|
||||
}
|
||||
|
||||
function handleUseBatchPrompt(prompt) {
|
||||
if (!prompt || !prompt.trim()) {
|
||||
if (!prompt?.trim()) {
|
||||
message.warning('暂无批量生成的提示词')
|
||||
return
|
||||
}
|
||||
@@ -211,11 +190,9 @@ function handleUseBatchPrompt(prompt) {
|
||||
router.push('/content-style/copywriting')
|
||||
}
|
||||
|
||||
// ==================== 保存提示词到服务器 ====================
|
||||
function handleOpenSavePromptModal(batchPrompt = null) {
|
||||
// 批量提示词:使用传入的 batchPrompt(AI 生成的内容),而不是原始的 mergedText
|
||||
const promptToSave = batchPrompt || batchPromptMergedText.value
|
||||
if (!promptToSave || !promptToSave.trim()) {
|
||||
if (!promptToSave?.trim()) {
|
||||
message.warning('没有提示词可保存')
|
||||
return
|
||||
}
|
||||
@@ -223,7 +200,6 @@ function handleOpenSavePromptModal(batchPrompt = null) {
|
||||
savePromptModalVisible.value = true
|
||||
}
|
||||
|
||||
// ==================== 生命周期 ====================
|
||||
onMounted(async () => {
|
||||
await loadTableDataFromSession()
|
||||
})
|
||||
@@ -252,8 +228,7 @@ defineOptions({ name: 'ContentStyleBenchmark' })
|
||||
@batch-analyze="handleBatchAnalyze"
|
||||
/>
|
||||
|
||||
<!-- 空态显示 -->
|
||||
<section class="card results-card empty-state" v-if="data.length === 0 && !loading">
|
||||
<section v-if="!data.length && !loading" class="card results-card empty-state">
|
||||
<a-empty description="暂无数据,请点击开始分析">
|
||||
<template #image>
|
||||
<svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
|
||||
Reference in New Issue
Block a user