Browse Source

feat:handle infinite load

pull/9323/head
DarkPhoenix2704 2 months ago
parent
commit
9f0b5d3b7f
  1. 25
      packages/nc-gui/components/feed/Changelog/index.vue
  2. 3
      packages/nc-gui/components/feed/Roadmap.vue
  3. 12
      packages/nc-gui/components/feed/View.vue
  4. 7
      packages/nc-gui/components/feed/Youtube/Player.vue
  5. 52
      packages/nc-gui/components/feed/Youtube/index.vue
  6. 4
      packages/nc-gui/composables/useProductFeed.ts

25
packages/nc-gui/components/feed/Changelog/index.vue

@ -1,14 +1,29 @@
<script setup lang="ts"> <script setup lang="ts">
const { loadGithubFeed, githubFeed } = useProductFeed() const { loadGithubFeed, githubFeed } = useProductFeed()
onMounted(async () => { const scrollContainer = ref<HTMLElement>()
await loadGithubFeed()
}) const { isLoading } = useInfiniteScroll(
scrollContainer,
async () => {
if (isLoading.value) return
await loadGithubFeed(true)
},
{ distance: 10 },
)
</script> </script>
<template> <template>
<div class="max-w-260 mx-auto"> <div
<FeedChangelogItem v-for="feed in githubFeed" :key="feed.id" :date="feed.published_at" :body="feed?.body" /> ref="scrollContainer"
:style="{
height: 'calc(100dvh - var(--toolbar-height) - 3rem)',
}"
class="overflow-y-auto nc-scrollbar-md mx-auto w-full"
>
<div class="max-w-260 mx-auto">
<FeedChangelogItem v-for="feed in githubFeed" :key="feed.id" :date="feed.published_at" :body="feed?.body" />
</div>
</div> </div>
</template> </template>

3
packages/nc-gui/components/feed/Roadmap.vue

@ -26,6 +26,9 @@ const handleIframeLoad = () => {
<template> <template>
<div <div
:style="{
height: 'calc(100dvh - var(--toolbar-height))',
}"
:class="{ :class="{
'hidden': !isLoaded, 'hidden': !isLoaded,
'block h-full': isLoaded, 'block h-full': isLoaded,

12
packages/nc-gui/components/feed/View.vue

@ -56,17 +56,7 @@ const tabs = [
</span> </span>
</div> </div>
</template> </template>
<div <component :is="tab.container" />
:style="{
height:
activeTab === 'recents'
? 'calc(100dvh - var(--toolbar-height) - var(--topbar-height))'
: 'calc(100dvh - var(--toolbar-height))',
}"
class="overflow-y-auto nc-scrollbar-md mx-auto w-full"
>
<component :is="tab.container" />
</div>
</a-tab-pane> </a-tab-pane>
</NcTabs> </NcTabs>
</div> </div>

7
packages/nc-gui/components/feed/Youtube/Player.vue

@ -29,7 +29,7 @@ onBeforeUnmount(() => {
</script> </script>
<template> <template>
<div class="flex flex-col gap-5"> <div class="flex flex-col mt-6 gap-5">
<div class="aspect-video !rounded-lg mx-auto !h-[428px]"> <div class="aspect-video !rounded-lg mx-auto !h-[428px]">
<div id="player" ref="videoPlayer" class="plyr__video-embed"> <div id="player" ref="videoPlayer" class="plyr__video-embed">
<iframe <iframe
@ -40,9 +40,12 @@ onBeforeUnmount(() => {
></iframe> ></iframe>
</div> </div>
</div> </div>
<div> <div class="text-gray-900 font-bold text-2xl">
{{ name }} {{ name }}
</div> </div>
<div class="text-gray-900">
{{ body }}
</div>
</div> </div>
</template> </template>

52
packages/nc-gui/components/feed/Youtube/index.vue

@ -1,22 +1,48 @@
<script setup lang="ts"> <script setup lang="ts">
const { youtubeFeed, loadYoutubeFeed } = useProductFeed() const { youtubeFeed, loadYoutubeFeed } = useProductFeed()
onMounted(() => { const scrollContainer = ref<HTMLElement>()
loadYoutubeFeed()
}) const { isLoading } = useInfiniteScroll(
scrollContainer,
async () => {
if (isLoading.value) return
await loadYoutubeFeed(true)
},
{ distance: 10 },
)
const gotoChannel = () => {
window.open('https://www.youtube.com/@nocodb?ref=product_feed', '_blank')
}
</script> </script>
<template> <template>
<div class="flex gap-2 flex-col"> <div
<FeedYoutubePlayer ref="scrollContainer"
v-for="feed in youtubeFeed" :style="{
:key="feed.id" height: 'calc(100dvh - var(--toolbar-height) - 5.25rem)',
:html_url="feed.html_url" }"
:name="feed.name" class="overflow-y-auto nc-scrollbar-md mt-9 mx-auto w-full"
:body="feed.body" >
:published_at="feed.published_at" <div class="max-w-[764px] mx-auto">
:embed_url="feed.embed_url" <div class="flex gap-3 items-center justify-between">
/> <span class="text-gray-900 font-semibold"> Recent Videos </span>
<NcButton type="secondary" size="small" @click="gotoChannel"> Go to Youtube </NcButton>
</div>
<div class="flex gap-2 flex-col">
<FeedYoutubePlayer
v-for="feed in youtubeFeed"
:key="feed.id"
:html_url="feed.html_url"
:name="feed.name"
:body="feed.body"
:published_at="feed.published_at"
:embed_url="feed.embed_url"
/>
</div>
</div>
</div> </div>
</template> </template>

4
packages/nc-gui/composables/useProductFeed.ts

@ -64,7 +64,7 @@ export const useProductFeed = createSharedComposable(() => {
}, },
}) })
ytNextPageToken.value = data.nextPageToken ytNextPageToken.value = data.nextPageToken
youtubeFeed.value = data.videos youtubeFeed.value = [...youtubeFeed.value, ...data.videos]
} }
const loadGithubFeed = async (loadMore?: boolean) => { const loadGithubFeed = async (loadMore?: boolean) => {
@ -78,7 +78,7 @@ export const useProductFeed = createSharedComposable(() => {
per_page: 10, per_page: 10,
}, },
}) })
githubFeed.value = data githubFeed.value = [...githubFeed.value, ...data]
} }
return { return {

Loading…
Cancel
Save