feat: 优化

This commit is contained in:
2026-01-27 00:39:12 +08:00
parent b76367afed
commit bf12e70339
10 changed files with 896 additions and 47 deletions

View File

@@ -25,6 +25,7 @@ const {
saveTableDataToSession,
loadTableDataFromSession,
processApiResponse,
appendData,
clearData,
} = useBenchmarkData()
@@ -51,6 +52,10 @@ const batchPromptTextCount = ref(0)
const savePromptModalVisible = ref(false)
const savePromptContent = ref('')
const maxCursor = ref(0)
const hasMore = ref(false)
const loadingMore = ref(false)
async function handleAnalyzeUser() {
const sec_user_id = resolveId(form.value.url, {
queryKeys: ['user'],
@@ -61,6 +66,10 @@ async function handleAnalyzeUser() {
}
loading.value = true
maxCursor.value = 0
hasMore.value = false
await clearData()
const req = await TikhubService.postTikHup({
type: InterfaceType.DOUYIN_WEB_USER_POST_VIDEOS,
methodType: MethodType.GET,
@@ -75,7 +84,9 @@ async function handleAnalyzeUser() {
try {
const resp = await req
processApiResponse(resp, form.value.platform)
const result = processApiResponse(resp, form.value.platform)
maxCursor.value = result.maxCursor
hasMore.value = result.hasMore
await saveTableDataToSession()
message.success('分析完成')
} catch (err) {
@@ -164,9 +175,64 @@ async function handleBatchAnalyze() {
async function handleResetForm() {
form.value = { platform: '抖音', url: '', count: 20, sort_type: 0 }
maxCursor.value = 0
hasMore.value = false
await clearData()
}
async function handleLoadMore() {
const sec_user_id = resolveId(form.value.url, {
queryKeys: ['user'],
pathPatterns: ['/user/:id'],
})
if (!sec_user_id) {
return
}
loadingMore.value = true
const req = await TikhubService.postTikHup({
type: InterfaceType.DOUYIN_WEB_USER_POST_VIDEOS,
methodType: MethodType.GET,
urlParams: {
sec_user_id,
max_cursor: maxCursor.value,
type: 'tik-app',
sort_type: form.value.sort_type,
count: form.value.count || 20,
},
})
try {
const resp = await req
if (form.value.platform === '抖音') {
const { mapFromDouyin } = await import('./utils/benchmarkUtils')
const awemeList = resp?.data?.aweme_list || []
const newItems = mapFromDouyin(awemeList)
appendData(newItems)
maxCursor.value = resp?.data?.max_cursor || 0
hasMore.value = resp?.data?.has_more || !(awemeList.length < (resp?.data?.count || 20))
} else {
const { mapFromXhs } = await import('./utils/benchmarkUtils')
const notes = resp?.data?.notes || resp?.data?.data || []
const newItems = mapFromXhs(notes)
appendData(newItems)
maxCursor.value = resp?.data?.max_cursor || 0
hasMore.value = resp?.data?.has_more || false
}
await saveTableDataToSession()
message.success(`已加载 ${data.value.length} 条数据`)
} catch (err) {
console.error(err)
message.error('加载失败,请稍后重试')
} finally {
loadingMore.value = false
}
}
function handleCopyBatchPrompt(prompt) {
if (!prompt?.trim()) {
message.warning('没有提示词可复制')
@@ -224,11 +290,14 @@ defineOptions({ name: 'ContentStyleBenchmark' })
:data="data"
v-model:selectedRowKeys="selectedRowKeys"
:loading="loading"
:loading-more="loadingMore"
:has-more="hasMore"
@export="handleExportToExcel"
@batch-analyze="handleBatchAnalyze"
@load-more="handleLoadMore"
/>
<section v-if="!data.length && !loading" class="card results-card empty-state">
<section v-if="!data.length" 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">