fix: 前端优化

This commit is contained in:
2026-02-25 21:57:05 +08:00
parent 79a5c1f3ed
commit c8518a381f
6 changed files with 233 additions and 197 deletions

View File

@@ -116,45 +116,33 @@ async function handleExportToExcel() {
const selectedRows = data.value.filter(item => selectedRowKeys.value.includes(item.id))
const rowsNeedTranscription = selectedRows.filter(row => !row.transcriptions)
if (rowsNeedTranscription.length) {
globalLoading.value = true
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) {
const index = data.value.findIndex(item => item.id === row.id)
if (index !== -1) {
data.value[index].transcriptions = transcription.value
}
}
}
globalLoadingText.value = '正在导出...'
} catch (error) {
console.error('获取语音转写失败:', error)
message.warning('部分数据语音转写失败,将导出已有数据')
}
} else {
globalLoading.value = true
globalLoadingText.value = '正在导出数据...'
}
globalLoading.value = true
globalLoadingText.value = rowsNeedTranscription.length ? '正在分析中...' : '正在导出数据...'
try {
if (rowsNeedTranscription.length) {
try {
const transcriptions = await getVoiceText(rowsNeedTranscription)
rowsNeedTranscription.forEach(row => {
const transcription = transcriptions.find(item => item.audio_url === row.audio_url)
const index = data.value.findIndex(item => item.id === row.id)
if (transcription && index !== -1) {
data.value[index].transcriptions = transcription.value
}
})
globalLoadingText.value = '正在导出...'
} catch (error) {
console.error('获取语音转写失败:', error)
message.warning('部分数据语音转写失败,将导出已有数据')
}
}
const finalSelectedRows = data.value.filter(item => selectedRowKeys.value.includes(item.id))
const result = exportBenchmarkDataToExcel(finalSelectedRows, {
platform: form.value.platform,
formatTime
})
if (result.success) {
message.success(result.message)
} else {
message.error(result.message)
}
message[result.success ? 'success' : 'error'](result.message)
} finally {
globalLoading.value = false
globalLoadingText.value = ''
@@ -232,25 +220,23 @@ async function handleLoadMore() {
}
}
async function handleCopyBatchPrompt(prompt) {
function validatePrompt(prompt, warningMsg = '没有提示词') {
if (!prompt?.trim()) {
message.warning('没有提示词可复制')
return
message.warning(warningMsg)
return false
}
return true
}
async function handleCopyBatchPrompt(prompt) {
if (!validatePrompt(prompt, '没有提示词可复制')) return
const success = await copyToClipboard(prompt)
if (success) {
message.success('提示词已复制到剪贴板')
} else {
message.error('复制失败')
}
message[success ? 'success' : 'error'](success ? '提示词已复制到剪贴板' : '复制失败')
}
function handleUseBatchPrompt(prompt) {
if (!prompt?.trim()) {
message.warning('暂无批量生成的提示词')
return
}
if (!validatePrompt(prompt, '暂无批量生成的提示词')) return
promptStore.setPrompt(prompt, { batch: true })
router.push('/content-style/copywriting')
@@ -258,10 +244,8 @@ function handleUseBatchPrompt(prompt) {
function handleOpenSavePromptModal(batchPrompt = null) {
const promptToSave = batchPrompt || batchPromptMergedText.value
if (!promptToSave?.trim()) {
message.warning('没有提示词可保存')
return
}
if (!validatePrompt(promptToSave, '没有提示词可保存')) return
savePromptContent.value = promptToSave
savePromptModalVisible.value = true
}
@@ -338,13 +322,18 @@ defineOptions({ name: 'ContentStyleBenchmark' })
<style scoped>
/* 页面垂直堆叠间距 */
.stack {
overflow-x: hidden;
}
.stack>*+* {
margin-top: 16px;
}
/* 稳定滚动条,避免内容高度变化导致页面左右抖动 */
/* 稳定滚动条,只在垂直方向预留空间 */
.page {
scrollbar-gutter: stable both-edges;
overflow-x: hidden;
max-width: 100%;
}
/* 卡片样式(不依赖 tailwind */
@@ -382,6 +371,7 @@ defineOptions({ name: 'ContentStyleBenchmark' })
:deep(.batch-analyze-spin-wrapper) {
width: 100%;
min-height: calc(100vh - 120px);
overflow-x: hidden;
}
:deep(.batch-analyze-spin-wrapper .ant-spin-spinning) {