mirror of
https://github.com/ngthanhvu/kr-phim.git
synced 2026-08-10 16:47:46 +00:00
Refactor: Remove Supabase authentication and related code
- Removed Supabase authentication logic from xem/[slug].vue and yeu-thich.vue. - Updated favorite and watch later messages to be device-specific. - Removed unused user state and authentication initialization. - Deleted supabase.ts plugin file and related configurations. - Updated nuxt.config.ts to remove Supabase runtime configuration. - Removed Supabase dependencies from package.json and package-lock.json. - Adjusted Dockerfile for development environment. - Added admin layout and pages for managing settings, movies, and users. - Implemented admin dashboard with statistics and recent activities. - Created movie and user management interfaces with search functionality.
This commit is contained in:
@@ -63,49 +63,9 @@ function writeLocalHistory(items: WatchHistoryItem[]) {
|
||||
}
|
||||
|
||||
export function useWatchHistory() {
|
||||
const { $supabase } = useNuxtApp()
|
||||
const { user } = useSupabaseAuth()
|
||||
|
||||
async function loadWatchHistory(limit = 12) {
|
||||
const localItems = readLocalHistory()
|
||||
|
||||
if (user.value) {
|
||||
if (localItems.length) {
|
||||
await $supabase
|
||||
.from('watch_history')
|
||||
.upsert(localItems.slice(0, 20).map((item) => ({
|
||||
user_id: user.value?.id,
|
||||
source: item.source,
|
||||
slug: item.slug,
|
||||
name: item.name,
|
||||
origin_name: item.originName || null,
|
||||
thumb: item.thumb || null,
|
||||
poster: item.poster || null,
|
||||
episode_name: item.episodeName || null,
|
||||
episode_index: item.episodeIndex || 0,
|
||||
server_index: item.serverIndex || 0,
|
||||
progress_seconds: Math.floor(item.progressSeconds || 0),
|
||||
duration_seconds: Math.floor(item.durationSeconds || 0),
|
||||
updated_at: new Date(item.updatedAt || Date.now()).toISOString(),
|
||||
})), {
|
||||
onConflict: 'user_id,source,slug',
|
||||
})
|
||||
}
|
||||
|
||||
const { data, error } = await $supabase
|
||||
.from('watch_history')
|
||||
.select('source, slug, name, origin_name, thumb, poster, episode_name, episode_index, server_index, progress_seconds, duration_seconds, updated_at')
|
||||
.eq('user_id', user.value.id)
|
||||
.order('updated_at', { ascending: false })
|
||||
.limit(limit)
|
||||
|
||||
if (!error && data) {
|
||||
return data
|
||||
.map(normalizeHistoryItem)
|
||||
.filter(Boolean) as WatchHistoryItem[]
|
||||
}
|
||||
}
|
||||
|
||||
return localItems
|
||||
.sort((a, b) => (b.updatedAt || 0) - (a.updatedAt || 0))
|
||||
.slice(0, limit)
|
||||
@@ -125,28 +85,6 @@ export function useWatchHistory() {
|
||||
].slice(0, 20)
|
||||
|
||||
writeLocalHistory(localItems)
|
||||
|
||||
if (!user.value) return
|
||||
|
||||
await $supabase
|
||||
.from('watch_history')
|
||||
.upsert({
|
||||
user_id: user.value.id,
|
||||
source: normalizedItem.source,
|
||||
slug: normalizedItem.slug,
|
||||
name: normalizedItem.name,
|
||||
origin_name: normalizedItem.originName || null,
|
||||
thumb: normalizedItem.thumb || null,
|
||||
poster: normalizedItem.poster || null,
|
||||
episode_name: normalizedItem.episodeName || null,
|
||||
episode_index: normalizedItem.episodeIndex || 0,
|
||||
server_index: normalizedItem.serverIndex || 0,
|
||||
progress_seconds: Math.floor(normalizedItem.progressSeconds || 0),
|
||||
duration_seconds: Math.floor(normalizedItem.durationSeconds || 0),
|
||||
updated_at: new Date(normalizedItem.updatedAt || Date.now()).toISOString(),
|
||||
}, {
|
||||
onConflict: 'user_id,source,slug',
|
||||
})
|
||||
}
|
||||
|
||||
async function clearWatchHistory() {
|
||||
@@ -154,13 +92,6 @@ export function useWatchHistory() {
|
||||
window.localStorage.removeItem(watchHistoryKey)
|
||||
window.localStorage.removeItem(legacyWatchHistoryKey)
|
||||
}
|
||||
|
||||
if (user.value) {
|
||||
await $supabase
|
||||
.from('watch_history')
|
||||
.delete()
|
||||
.eq('user_id', user.value.id)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user