Skip to content

Commit

Permalink
perf(video): ⚡ remove duplicated auth request
Browse files Browse the repository at this point in the history
  • Loading branch information
wrzrmzx committed Feb 23, 2024
1 parent 8e868fd commit 5152812
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions components/video/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ const props = withDefaults(defineProps<{
video: schema.Video
videoIndex?: number
opType?: 'none' | 'video' | 'playlist' | 'playlistEditor'
isAdmin: boolean
// Become horizontal to fit mobile view
horizontal?: boolean
responsive?: boolean
}>(), {
videoIndex: 0,
opType: 'none',
isAdmin: false,
horizontal: false,
responsive: true,
})
Expand Down Expand Up @@ -68,6 +70,7 @@ const biliVideoPartNeeded = computed(() => props.video.item.partName && props.vi
<VideoCardOps
:video="video"
:op-type="opType"
:is-admin="props.isAdmin"
@refresh="() => emit('refresh')"
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/video/CardOps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { schema } from '@/composables/graphql'
const props = withDefaults(defineProps<{
video: schema.Video
opType?: 'normal' | 'video' | 'playlist' | 'playlistEditor'
isAdmin: Boolean
}>(),
{
opType: 'normal',
Expand All @@ -15,7 +16,6 @@ const emit = defineEmits<{

const { t } = useI18n()
const { getToken } = useApollo()
const auth = await useAuth()

const hideVideoLoading = ref(false)
async function hideVideo() {
Expand Down Expand Up @@ -68,7 +68,7 @@ async function hideVideo() {
打开源站
</a>

<template v-if="auth.isAdmin && opType !== 'playlist'">
<template v-if="props.isAdmin && opType !== 'playlist'">
<div class="w-full border-b-1 border-purple-300 dark:border-gray-600" />

<button
Expand Down
2 changes: 2 additions & 0 deletions components/video/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const props = defineProps<{
name?: string
titleLinksTo?: RouteLocationRaw
videos: schema.Video[]
isAdmin: boolean
}>()
const emit = defineEmits<{
(event: 'refresh'): void
Expand All @@ -23,6 +24,7 @@ const emit = defineEmits<{
:video="video"
horizontal
op-type="video"
:is-admin="props.isAdmin"
@refresh="() => emit('refresh')"
/>
</div>
Expand Down
3 changes: 3 additions & 0 deletions pages/video-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ const { data, refresh } = await useAsyncQuery<Query>(
)
const listVideo = computed(() => data.value!.listVideo)
const auth = await useAuth()
function updatePage(page: number) {
window.scrollTo(0, 0)
navigateTo({ query: { ...route.query, page } })
Expand All @@ -85,6 +87,7 @@ function updatePage(page: number) {
<VideoList
:videos="listVideo.videos"
:count="limit"
:is-admin="auth.isAdmin"
@refresh="refresh"
/>

Expand Down

0 comments on commit 5152812

Please sign in to comment.