Browse Source

feat:handle infinite load

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

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

@ -1,15 +1,30 @@
<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
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"> <div class="max-w-260 mx-auto">
<FeedChangelogItem v-for="feed in githubFeed" :key="feed.id" :date="feed.published_at" :body="feed?.body" /> <FeedChangelogItem v-for="feed in githubFeed" :key="feed.id" :date="feed.published_at" :body="feed?.body" />
</div> </div>
</div>
</template> </template>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>

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,

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

@ -56,17 +56,7 @@ const tabs = [
</span> </span>
</div> </div>
</template> </template>
<div
: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" /> <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>

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

@ -1,12 +1,36 @@
<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
ref="scrollContainer"
:style="{
height: 'calc(100dvh - var(--toolbar-height) - 5.25rem)',
}"
class="overflow-y-auto nc-scrollbar-md mt-9 mx-auto w-full"
>
<div class="max-w-[764px] mx-auto">
<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"> <div class="flex gap-2 flex-col">
<FeedYoutubePlayer <FeedYoutubePlayer
v-for="feed in youtubeFeed" v-for="feed in youtubeFeed"
@ -18,6 +42,8 @@ onMounted(() => {
:embed_url="feed.embed_url" :embed_url="feed.embed_url"
/> />
</div> </div>
</div>
</div>
</template> </template>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>

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