From dda92c2cc6359a92348a642ce7062586ef063fef Mon Sep 17 00:00:00 2001 From: ngthanhvu Date: Thu, 6 Aug 2026 05:35:52 -0400 Subject: [PATCH] refactor: remove sync functionality and clean up unused code in index.vue --- app/pages/admin/index.vue | 134 +++++++------------------------------- 1 file changed, 22 insertions(+), 112 deletions(-) diff --git a/app/pages/admin/index.vue b/app/pages/admin/index.vue index 3683a84..181e5cd 100644 --- a/app/pages/admin/index.vue +++ b/app/pages/admin/index.vue @@ -2,44 +2,14 @@ definePageMeta({ layout: 'admin', }) - useHead({ title: 'Dashboard - CineK Admin', }) - const { data: stats, refresh } = await useFetch('/api/admin/stats') -const syncing = ref(false) -const syncOpen = ref(false) -const syncSources = ref({ ophim: true, nguonc: true, kkphim: true }) - -async function handleSync() { - const sources = Object.entries(syncSources.value) - .filter(([, enabled]) => enabled) - .map(([name]) => name) - - if (!sources.length) return - - syncing.value = true - try { - await $fetch('/api/admin/sync', { - method: 'POST', - body: { sources }, - }) - syncOpen.value = false - await refresh() - } catch (err) { - console.error('Sync failed:', err) - } finally { - syncing.value = false - } -} - function percentOf(value: number, total: number) { if (!total) return 0 return Math.round((value / total) * 100) } - -// Donut chart helpers function donutSegment(value: number, total: number, startAngle: number, radius = 38) { if (!total || !value) return '' const angle = (value / total) * 360 @@ -52,7 +22,6 @@ function donutSegment(value: number, total: number, startAngle: number, radius = const largeArc = angle > 180 ? 1 : 0 return `M 50 50 L ${x1} ${y1} A ${radius} ${radius} 0 ${largeArc} 1 ${x2} ${y2} Z` } - // Stacked source bar segments const sourceSegments = computed(() => { const total = stats.value?.total || 0 @@ -66,25 +35,15 @@ const sourceSegments = computed(() => { { key: 'kkphim', label: 'KKPhim', value: kkphim, pct: (kkphim / total) * 100, color: '#60a5fa' }, ].filter(s => s.value > 0) }) - -// Bar chart max value const maxViews = computed(() => { const movies = stats.value?.topMovies || [] return Math.max(...movies.map(m => m.views || 0), 1) }) - function barWidth(views: number) { if (!maxViews.value) return 0 return Math.max((views / maxViews.value) * 100, 3) } - -const syncSourceOptions = [ - { key: 'ophim', label: 'OPhim', domain: 'ophim1.com' }, - { key: 'nguonc', label: 'NguonC', domain: 'phim.nguonc.com' }, - { key: 'kkphim', label: 'KKPhim', domain: 'phimapi.com' }, -] as const - @@ -253,7 +202,6 @@ const syncSourceOptions = [ -
@@ -267,7 +215,8 @@ const syncSourceOptions = [ @@ -296,7 +245,6 @@ const syncSourceOptions = [
-
@@ -313,7 +261,8 @@ const syncSourceOptions = [ {{ movie.name }}
- {{ movie.views?.toLocaleString() }} + {{ movie.views?.toLocaleString() + }}
-
@@ -336,64 +284,26 @@ const syncSourceOptions = [
Đang hiển thị - {{ stats?.active?.toLocaleString() || 0 }} · {{ percentOf(stats?.active || 0, stats?.total || 0) }}% + {{ stats?.active?.toLocaleString() || 0 }} · {{ + percentOf(stats?.active || 0, stats?.total || 0) }}%
-
+
Chưa hiển thị - {{ stats?.inactive?.toLocaleString() || 0 }} · {{ percentOf(stats?.inactive || 0, stats?.total || 0) }}% + {{ stats?.inactive?.toLocaleString() || 0 }} · {{ + percentOf(stats?.inactive || 0, stats?.total || 0) }}%
-
+
- - - - -
-
-
- - -
-

Đồng bộ phim

-

Chọn nguồn để đồng bộ phim vào hệ thống

-
- -
- -
- -
- - -
-
-
- -