Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
89036f8a
authored
Aug 07, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: git star
parent
c26be2e8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
28 deletions
+37
-28
client/src/components/Layout/index.tsx
+5
-3
client/src/components/Layout/navbar.tsx
+15
-10
client/src/components/MyTooltip/index.tsx
+1
-1
client/src/pages/index.tsx
+2
-13
client/src/pages/tools/index.tsx
+1
-1
client/src/store/global.ts
+13
-0
No files found.
client/src/components/Layout/index.tsx
View file @
89036f8a
...
...
@@ -28,7 +28,7 @@ const Layout = ({ children }: { children: JSX.Element }) => {
const
router
=
useRouter
();
const
{
colorMode
,
setColorMode
}
=
useColorMode
();
const
{
Loading
}
=
useLoading
();
const
{
loading
,
setScreenWidth
,
isPc
}
=
useGlobalStore
();
const
{
loading
,
setScreenWidth
,
isPc
,
loadGitStar
}
=
useGlobalStore
();
const
{
userInfo
}
=
useUserStore
();
const
isChatPage
=
useMemo
(
...
...
@@ -46,14 +46,16 @@ const Layout = ({ children }: { children: JSX.Element }) => {
const
resize
=
throttle
(()
=>
{
setScreenWidth
(
document
.
documentElement
.
clientWidth
);
},
300
);
resize
();
window
.
addEventListener
(
'resize'
,
resize
);
resize
();
loadGitStar
();
return
()
=>
{
window
.
removeEventListener
(
'resize'
,
resize
);
};
},
[]);
},
[
loadGitStar
,
setScreenWidth
]);
const
{
data
:
unread
=
0
}
=
useQuery
([
'getUnreadCount'
],
getUnreadCount
,
{
enabled
:
!!
userInfo
,
...
...
client/src/components/Layout/navbar.tsx
View file @
89036f8a
...
...
@@ -11,6 +11,8 @@ import Avatar from '../Avatar';
import
MyIcon
from
'../Icon'
;
import
Language
from
'../Language'
;
import
{
useTranslation
}
from
'next-i18next'
;
import
{
useGlobalStore
}
from
'@/store/global'
;
import
MyTooltip
from
'../MyTooltip'
;
export
enum
NavbarTypeEnum
{
normal
=
'normal'
,
...
...
@@ -21,6 +23,7 @@ const Navbar = ({ unread }: { unread: number }) => {
const
{
t
}
=
useTranslation
();
const
router
=
useRouter
();
const
{
userInfo
}
=
useUserStore
();
const
{
gitStar
}
=
useGlobalStore
();
const
{
lastChatAppId
,
lastChatId
}
=
useChatStore
();
const
navbarList
=
useMemo
(
()
=>
[
...
...
@@ -158,16 +161,18 @@ const Navbar = ({ unread }: { unread: number }) => {
)
}
<
Language
{
...
itemStyles
}
/>
{
feConfigs
?.
show_git
&&
(
<
Link
as=
{
NextLink
}
href=
"https://github.com/labring/FastGPT"
target=
{
'_blank'
}
{
...
itemStyles
}
mt=
{
0
}
color=
{
'#9096a5'
}
>
<
MyIcon
name=
{
'git'
}
width=
{
'22px'
}
height=
{
'22px'
}
/>
</
Link
>
<
MyTooltip
label=
{
`Git Star: ${gitStar}`
}
placement=
{
'right-end'
}
>
<
Link
as=
{
NextLink
}
href=
"https://github.com/labring/FastGPT"
target=
{
'_blank'
}
{
...
itemStyles
}
mt=
{
0
}
color=
{
'#9096a5'
}
>
<
MyIcon
name=
{
'git'
}
width=
{
'22px'
}
height=
{
'22px'
}
/>
</
Link
>
</
MyTooltip
>
)
}
</
Flex
>
);
...
...
client/src/components/MyTooltip/index.tsx
View file @
89036f8a
...
...
@@ -11,7 +11,7 @@ const MyTooltip = ({ children, forceShow = false, shouldWrapChildren = true, ...
return
isPc
||
forceShow
?
(
<
Tooltip
bg=
{
'white'
}
arrowShadowColor=
{
' rgba(0,0,0,0.
1
)'
}
arrowShadowColor=
{
' rgba(0,0,0,0.
05
)'
}
hasArrow
arrowSize=
{
12
}
offset=
{
[
-
15
,
15
]
}
...
...
client/src/pages/index.tsx
View file @
89036f8a
...
...
@@ -7,15 +7,13 @@ import { serviceSideProps } from '@/utils/i18n';
import
{
useTranslation
}
from
'next-i18next'
;
import
styles
from
'./index.module.scss'
;
import
axios
from
'axios'
;
import
MyIcon
from
'@/components/Icon'
;
const
Home
=
()
=>
{
const
router
=
useRouter
();
const
{
t
}
=
useTranslation
();
const
{
inviterId
}
=
router
.
query
as
{
inviterId
:
string
};
const
{
isPc
}
=
useGlobalStore
();
const
[
star
,
setStar
]
=
useState
(
1500
);
const
{
isPc
,
gitStar
}
=
useGlobalStore
();
useEffect
(()
=>
{
if
(
inviterId
)
{
...
...
@@ -136,15 +134,6 @@ const Home = () => {
},
500
);
},
[
isPc
]);
useEffect
(()
=>
{
(
async
()
=>
{
try
{
const
{
data
:
git
}
=
await
axios
.
get
(
'https://api.github.com/repos/labring/FastGPT'
);
setStar
(
git
.
stargazers_count
);
}
catch
(
error
)
{}
})();
},
[]);
return
(
<
Flex
className=
{
styles
.
home
}
...
...
@@ -200,7 +189,7 @@ const Home = () => {
leftIcon=
{
<
MyIcon
name=
{
'git'
}
w=
{
'20px'
}
/>
}
onClick=
{
()
=>
window
.
open
(
'https://github.com/labring/FastGPT'
,
'_blank'
)
}
>
Stars
{
(
s
tar
/
1000
).
toFixed
(
1
)
}
k
Stars
{
(
gitS
tar
/
1000
).
toFixed
(
1
)
}
k
</
Button
>
)
}
<
Button
...
...
client/src/pages/tools/index.tsx
View file @
89036f8a
...
...
@@ -25,7 +25,7 @@ const list = [
?
[
{
icon
:
'git'
,
label
:
'Git
项目
地址'
,
label
:
'Git
Hub
地址'
,
link
:
'https://github.com/labring/FastGPT'
}
]
...
...
client/src/store/global.ts
View file @
89036f8a
import
{
create
}
from
'zustand'
;
import
{
devtools
}
from
'zustand/middleware'
;
import
{
immer
}
from
'zustand/middleware/immer'
;
import
axios
from
'axios'
;
type
State
=
{
loading
:
boolean
;
...
...
@@ -9,6 +10,8 @@ type State = {
setScreenWidth
:
(
val
:
number
)
=>
void
;
isPc
?:
boolean
;
initIsPc
(
val
:
boolean
):
void
;
gitStar
:
number
;
loadGitStar
:
()
=>
Promise
<
void
>
;
};
export
const
useGlobalStore
=
create
<
State
>
()(
...
...
@@ -35,6 +38,16 @@ export const useGlobalStore = create<State>()(
set
((
state
)
=>
{
state
.
isPc
=
val
;
});
},
gitStar
:
2700
,
async
loadGitStar
()
{
try
{
const
{
data
:
git
}
=
await
axios
.
get
(
'https://api.github.com/repos/labring/FastGPT'
);
set
((
state
)
=>
{
state
.
gitStar
=
git
.
stargazers_count
;
});
}
catch
(
error
)
{}
}
}))
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment