From f27e8c8c86c1da484551a8da3d1a071f9098bfa9 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 2 Oct 2024 05:54:22 +0000 Subject: [PATCH] fix: youtube video player and twitter recents page --- .../components/feed/Changelog/index.vue | 2 +- .../nc-gui/components/feed/Recents/Card.vue | 77 +++++++++++++++++++ .../nc-gui/components/feed/Recents/index.vue | 36 ++++++++- .../nc-gui/components/feed/Twitter/index.vue | 8 +- .../nc-gui/components/feed/Youtube/Player.vue | 44 ++--------- .../nc-gui/components/feed/Youtube/index.vue | 2 +- packages/nc-gui/lib/types.ts | 1 + packages/nc-gui/utils/urlUtils.ts | 24 ++++++ 8 files changed, 149 insertions(+), 45 deletions(-) create mode 100644 packages/nc-gui/components/feed/Recents/Card.vue diff --git a/packages/nc-gui/components/feed/Changelog/index.vue b/packages/nc-gui/components/feed/Changelog/index.vue index 563687e88a..b6bfd91ddc 100644 --- a/packages/nc-gui/components/feed/Changelog/index.vue +++ b/packages/nc-gui/components/feed/Changelog/index.vue @@ -14,7 +14,7 @@ const { isLoading } = useInfiniteScroll( githubFeed.value = [...githubFeed.value, ...data] }, - { distance: 1 }, + { distance: 1, interval: 2000 }, ) diff --git a/packages/nc-gui/components/feed/Recents/Card.vue b/packages/nc-gui/components/feed/Recents/Card.vue new file mode 100644 index 0000000000..2dc2fde945 --- /dev/null +++ b/packages/nc-gui/components/feed/Recents/Card.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/packages/nc-gui/components/feed/Recents/index.vue b/packages/nc-gui/components/feed/Recents/index.vue index 4417d6decb..f028eb9910 100644 --- a/packages/nc-gui/components/feed/Recents/index.vue +++ b/packages/nc-gui/components/feed/Recents/index.vue @@ -1,5 +1,37 @@ - + + + diff --git a/packages/nc-gui/components/feed/Twitter/index.vue b/packages/nc-gui/components/feed/Twitter/index.vue index 9f314da507..8c63ddb90a 100644 --- a/packages/nc-gui/components/feed/Twitter/index.vue +++ b/packages/nc-gui/components/feed/Twitter/index.vue @@ -15,7 +15,7 @@ const { isLoading } = useInfiniteScroll( }) twitterFeed.value = [...twitterFeed.value, ...data] }, - { distance: 1 }, + { distance: 1, interval: 2000 }, ) @@ -27,8 +27,10 @@ const { isLoading } = useInfiniteScroll( }" class="overflow-y-auto nc-scrollbar-md w-full" > -
- +
+
+ +
diff --git a/packages/nc-gui/components/feed/Youtube/Player.vue b/packages/nc-gui/components/feed/Youtube/Player.vue index 6e0c62b1a0..1f49ac9e84 100644 --- a/packages/nc-gui/components/feed/Youtube/Player.vue +++ b/packages/nc-gui/components/feed/Youtube/Player.vue @@ -1,50 +1,22 @@ - + diff --git a/packages/nc-gui/components/feed/Youtube/index.vue b/packages/nc-gui/components/feed/Youtube/index.vue index 25a14a5bd1..7b80c7b4d2 100644 --- a/packages/nc-gui/components/feed/Youtube/index.vue +++ b/packages/nc-gui/components/feed/Youtube/index.vue @@ -13,7 +13,7 @@ const { isLoading } = useInfiniteScroll( }) youtubeFeed.value = [...youtubeFeed.value, ...data] }, - { distance: 1 }, + { distance: 1, interval: 2000 }, ) const gotoChannel = () => { diff --git a/packages/nc-gui/lib/types.ts b/packages/nc-gui/lib/types.ts index 3b78c410d3..c33108c060 100644 --- a/packages/nc-gui/lib/types.ts +++ b/packages/nc-gui/lib/types.ts @@ -285,6 +285,7 @@ interface ProductFeedItem { Url: string Tags?: string CreatedAt: string + Images?: Record[] | null } type SordDirectionType = 'asc' | 'desc' | undefined diff --git a/packages/nc-gui/utils/urlUtils.ts b/packages/nc-gui/utils/urlUtils.ts index fb01a1d062..eb45b881ce 100644 --- a/packages/nc-gui/utils/urlUtils.ts +++ b/packages/nc-gui/utils/urlUtils.ts @@ -63,3 +63,27 @@ export const isLinkExpired = async (url: string) => { return true } + +export const extractYoutubeVideoId = (url: string) => { + if (typeof url !== 'string') { + return '' + } + + // Regular expressions to match different YouTube URL formats + const patterns = [ + /(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?v=([^&]+)/, + /(?:https?:\/\/)?(?:www\.)?youtube\.com\/embed\/([^?]+)/, + /(?:https?:\/\/)?youtu\.be\/([^?]+)/, + /(?:https?:\/\/)?(?:www\.)?youtube\.com\/v\/([^?]+)/, + /(?:https?:\/\/)?(?:www\.)?youtube\.com\/shorts\/([^?]+)/, + ] + + for (const pattern of patterns) { + const match = url.match(pattern) + if (match && match[1]) { + return match[1] + } + } + + return '' +}