From ad54ff03988bc862ce0747e94793daa1c5f24f4d Mon Sep 17 00:00:00 2001 From: Qyir <13521889462@163.com> Date: Fri, 7 Nov 2025 17:36:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=8E=E7=9A=84=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=90=8E=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/routers/rank_api_routes.py | 3 +- frontend/src/AdminPanel.vue | 254 ++--------------------------- frontend/src/App.vue | 6 +- 3 files changed, 19 insertions(+), 244 deletions(-) diff --git a/backend/routers/rank_api_routes.py b/backend/routers/rank_api_routes.py index 06c8437..18f3700 100644 --- a/backend/routers/rank_api_routes.py +++ b/backend/routers/rank_api_routes.py @@ -197,7 +197,7 @@ def format_interaction_count(count): def format_mix_item(doc, target_date=None): """格式化合集数据项 - 完全按照数据库原始字段返回""" - mix_name = doc.get("mix_name", "") + mix_name = doc.get("mix_name", "") or doc.get("title", "") # 计算总点赞数 episode_details = doc.get("episode_details", []) @@ -217,6 +217,7 @@ def format_mix_item(doc, target_date=None): "_id": str(doc.get("_id", "")), "batch_time": format_time(doc.get("batch_time")), "mix_name": mix_name, + "title": mix_name, "video_url": doc.get("video_url", ""), "playcount": doc.get("playcount", ""), "play_vv": doc.get("play_vv", 0), diff --git a/frontend/src/AdminPanel.vue b/frontend/src/AdminPanel.vue index 299e774..2ab9b45 100644 --- a/frontend/src/AdminPanel.vue +++ b/frontend/src/AdminPanel.vue @@ -8,9 +8,7 @@ const router = useRouter() // 响应式数据 const rankingData = ref([]) const loading = ref(false) -const selectedDate = ref('') const showEditModal = ref(false) -const showAddModal = ref(false) // 编辑表单数据 const editForm = reactive({ @@ -34,32 +32,20 @@ const editForm = reactive({ isDrama: false }) -// 新增表单数据 -const addForm = reactive({ - title: '', - mix_name: '', - series_author: '', - Manufacturing_Field: '', - Copyright_field: '', - play_vv: 0, - total_likes_formatted: '', - cover_image_url: '', - cover_backup_urls: [], - timeline_data: { - play_vv_change: 0, - play_vv_change_rate: 0 - } -}) - -// 初始化日期为今天 -const initDate = () => { - const today = new Date() - selectedDate.value = today.toISOString().split('T')[0] -} - // API基础URL const API_BASE_URL = 'http://localhost:5001/api' +// 格式化播放量 +const formatPlayCount = (count) => { + if (!count) return '0' + if (count >= 100000000) { + return (count / 100000000).toFixed(1) + '亿' + } else if (count >= 10000) { + return (count / 10000).toFixed(1) + '万' + } + return count.toString() +} + // 获取排行榜数据 const fetchRankingData = async () => { loading.value = true @@ -68,9 +54,7 @@ const fetchRankingData = async () => { params: { page: 1, limit: 100, - sort: 'growth', - start_date: selectedDate.value, - end_date: selectedDate.value + sort: 'growth' } }) @@ -119,17 +103,6 @@ const fetchRankingData = async () => { } } -// 格式化播放量 -const formatPlayCount = (count) => { - if (!count) return '0' - if (count >= 100000000) { - return (count / 100000000).toFixed(1) + '亿' - } else if (count >= 10000) { - return (count / 10000).toFixed(1) + '万' - } - return count.toString() -} - // 编辑项目 const editItem = async (item) => { editForm.id = item.id || item._id @@ -161,7 +134,7 @@ const loadClassificationStatus = async (mixName) => { }) if (response.data.success) { - const classifications = response.data.data + const classifications = response.data.data.classification_status || response.data.data editForm.isNovel = classifications.novel || false editForm.isAnime = classifications.anime || false editForm.isDrama = classifications.drama || false @@ -273,8 +246,7 @@ const saveEdit = async () => { total_likes_formatted: editForm.total_likes_formatted, cover_image_url: editForm.cover_image_url, cover_backup_urls: editForm.cover_backup_urls, - timeline_data: editForm.timeline_data, - target_date: selectedDate.value + timeline_data: editForm.timeline_data } // 调用后端API更新数据 @@ -312,113 +284,11 @@ const saveEdit = async () => { } } -// 添加新项目 -const addNewItem = async () => { - try { - const newItemData = { - title: addForm.title, - mix_name: addForm.mix_name, - series_author: addForm.series_author, - Manufacturing_Field: addForm.Manufacturing_Field, - Copyright_field: addForm.Copyright_field, - play_vv: addForm.play_vv, - total_likes_formatted: addForm.total_likes_formatted, - cover_image_url: addForm.cover_image_url, - cover_backup_urls: addForm.cover_backup_urls, - timeline_data: addForm.timeline_data - } - - // 尝试调用后端API添加数据 - try { - const response = await axios.post(`${API_BASE_URL}/rank/videos`, newItemData) - - // 重置表单 - Object.keys(addForm).forEach(key => { - if (key === 'play_vv') { - addForm[key] = 0 - } else if (key === 'cover_backup_urls') { - addForm[key] = [] - } else if (key === 'timeline_data') { - addForm[key] = { - play_vv_change: 0, - play_vv_change_rate: 0 - } - } else { - addForm[key] = '' - } - }) - - showAddModal.value = false - - // 重新获取最新数据,确保前端显示的是数据库中的最新数据 - await fetchRankingData() - - alert('添加成功!') - } catch (apiError) { - console.warn('API添加失败,使用本地添加:', apiError) - const newItem = { - id: Date.now(), - ...newItemData - } - - // 添加到本地数据 - rankingData.value.unshift(newItem) - - // 重置表单 - Object.keys(addForm).forEach(key => { - if (key === 'play_vv') { - addForm[key] = 0 - } else if (key === 'cover_backup_urls') { - addForm[key] = [] - } else if (key === 'timeline_data') { - addForm[key] = { - play_vv_change: 0, - play_vv_change_rate: 0 - } - } else { - addForm[key] = '' - } - }) - - showAddModal.value = false - alert('添加失败,但本地数据已更新。请检查网络连接。') - } - } catch (error) { - console.error('添加失败:', error) - alert('添加失败!') - } -} - // 取消编辑 const cancelEdit = () => { showEditModal.value = false } -// 取消添加 -const cancelAdd = () => { - showAddModal.value = false - // 重置表单 - Object.keys(addForm).forEach(key => { - if (key === 'play_vv') { - addForm[key] = 0 - } else if (key === 'cover_backup_urls') { - addForm[key] = [] - } else if (key === 'timeline_data') { - addForm[key] = { - play_vv_change: 0, - play_vv_change_rate: 0 - } - } else { - addForm[key] = '' - } - }) -} - -// 日期改变处理 -const onDateChange = () => { - fetchRankingData() -} - // 返回前端页面 const goBack = () => { router.push('/') @@ -426,7 +296,6 @@ const goBack = () => { // 页面加载时初始化 onMounted(() => { - initDate() fetchRankingData() }) @@ -442,28 +311,12 @@ onMounted(() => {

AI棒榜 - 后台管理

-
- -
- - - 共 {{ rankingData.length }} 条数据 -
-
@@ -624,58 +477,6 @@ onMounted(() => {
- - - @@ -807,29 +608,6 @@ export default { background: #c82333; } -/* 日期选择区域 */ -.date-section { - padding: 16px; - background: white; - border-bottom: 1px solid #e0e0e0; - display: flex; - align-items: center; - gap: 12px; - font-size: 14px; -} - -.date-input { - padding: 6px 10px; - border: 1px solid #ddd; - border-radius: 4px; - font-size: 14px; -} - -.data-count { - color: #666; - margin-left: auto; -} - /* 管理内容区域 */ .admin-content { padding: 16px; @@ -1158,10 +936,6 @@ export default { padding: 16px 12px; } - .date-section { - padding: 12px; - } - .admin-content { padding: 12px; } diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 1bd8464..9e073b2 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -370,9 +370,9 @@ onMounted(() => { 版权
-

剧场名:{{ item.series_author || '爱微剧场' }}

-

承制:{{ item.Manufacturing_Field || '妙想制片厂' }}

-

版权:{{ item.Copyright_field || '可梦' }}

+

剧场名:{{ item.series_author || '' }}

+

承制:{{ item.Manufacturing_Field || '' }}

+

版权:{{ item.Copyright_field || '' }}