|
|
@ -2,8 +2,7 @@ import axios from 'axios' |
|
|
|
import type { ProductFeedItem } from '../lib/types' |
|
|
|
import type { ProductFeedItem } from '../lib/types' |
|
|
|
|
|
|
|
|
|
|
|
const axiosInstance = axios.create({ |
|
|
|
const axiosInstance = axios.create({ |
|
|
|
// baseURL: 'https://nocodb.com/api',
|
|
|
|
baseURL: 'https://nocodb.com/api/v1', |
|
|
|
baseURL: 'http://localhost:8000/api/v1', |
|
|
|
|
|
|
|
headers: { |
|
|
|
headers: { |
|
|
|
'Content-Type': 'application/json', |
|
|
|
'Content-Type': 'application/json', |
|
|
|
}, |
|
|
|
}, |
|
|
@ -19,31 +18,36 @@ export const useProductFeed = createSharedComposable(() => { |
|
|
|
const socialFeed = ref<ProductFeedItem[]>([]) |
|
|
|
const socialFeed = ref<ProductFeedItem[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
const loadFeed = async ({ loadMore, type }: { loadMore: boolean; type: 'youtube' | 'github' | 'all' | 'twitter' }) => { |
|
|
|
const loadFeed = async ({ loadMore, type }: { loadMore: boolean; type: 'youtube' | 'github' | 'all' | 'twitter' }) => { |
|
|
|
let page = 1 |
|
|
|
try { |
|
|
|
|
|
|
|
let page = 1 |
|
|
|
if (loadMore) { |
|
|
|
|
|
|
|
switch (type) { |
|
|
|
if (loadMore) { |
|
|
|
case 'youtube': |
|
|
|
switch (type) { |
|
|
|
page = Math.ceil(youtubeFeed.value.length / 10) + 1 |
|
|
|
case 'youtube': |
|
|
|
break |
|
|
|
page = Math.ceil(youtubeFeed.value.length / 10) + 1 |
|
|
|
case 'github': |
|
|
|
break |
|
|
|
page = Math.ceil(githubFeed.value.length / 10) + 1 |
|
|
|
case 'github': |
|
|
|
break |
|
|
|
page = Math.ceil(githubFeed.value.length / 10) + 1 |
|
|
|
case 'all': |
|
|
|
break |
|
|
|
page = Math.ceil(socialFeed.value.length / 10) + 1 |
|
|
|
case 'all': |
|
|
|
break |
|
|
|
page = Math.ceil(socialFeed.value.length / 10) + 1 |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const response = await axiosInstance.get('/social/feed', { |
|
|
|
|
|
|
|
params: { |
|
|
|
|
|
|
|
per_page: 10, |
|
|
|
|
|
|
|
page, |
|
|
|
|
|
|
|
type, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response.data |
|
|
|
const response = await axiosInstance.get('/social/feed', { |
|
|
|
|
|
|
|
params: { |
|
|
|
|
|
|
|
per_page: 10, |
|
|
|
|
|
|
|
page, |
|
|
|
|
|
|
|
type, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response.data |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
console.error(error) |
|
|
|
|
|
|
|
return [] |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|