mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 06:29:03 +08:00
fix: server side render trigger GitHub api rate limit (#685)
This commit is contained in:
parent
f369202c12
commit
6a564e2d5c
@ -1,3 +1,5 @@
|
|||||||
|
'use client'
|
||||||
|
import React, { useEffect, useState } from 'react'
|
||||||
import { Github } from '@/app/components/base/icons/src/public/common'
|
import { Github } from '@/app/components/base/icons/src/public/common'
|
||||||
import type { GithubRepo } from '@/models/common'
|
import type { GithubRepo } from '@/models/common'
|
||||||
|
|
||||||
@ -10,18 +12,26 @@ const getStar = async () => {
|
|||||||
return res.json()
|
return res.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
const GithubStar = async () => {
|
const GithubStar = () => {
|
||||||
let githubRepo: GithubRepo = { stargazers_count: 0 }
|
const [githubRepo, setGithubRepo] = useState<GithubRepo>({ stargazers_count: 6000 })
|
||||||
|
const [isFetched, setIsFetched] = useState(false)
|
||||||
|
useEffect(() => {
|
||||||
|
(async () => {
|
||||||
|
try {
|
||||||
|
if (process.env.NODE_ENV === 'development')
|
||||||
|
return
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'development')
|
await setGithubRepo(await getStar())
|
||||||
return null
|
setIsFetched(true)
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
|
||||||
try {
|
}
|
||||||
githubRepo = await getStar()
|
})()
|
||||||
}
|
}, [])
|
||||||
catch (e) {
|
|
||||||
|
if (!isFetched)
|
||||||
return null
|
return null
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user