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 }) => {
...
@@ -28,7 +28,7 @@ const Layout = ({ children }: { children: JSX.Element }) => {
const
router
=
useRouter
();
const
router
=
useRouter
();
const
{
colorMode
,
setColorMode
}
=
useColorMode
();
const
{
colorMode
,
setColorMode
}
=
useColorMode
();
const
{
Loading
}
=
useLoading
();
const
{
Loading
}
=
useLoading
();
const
{
loading
,
setScreenWidth
,
isPc
}
=
useGlobalStore
();
const
{
loading
,
setScreenWidth
,
isPc
,
loadGitStar
}
=
useGlobalStore
();
const
{
userInfo
}
=
useUserStore
();
const
{
userInfo
}
=
useUserStore
();
const
isChatPage
=
useMemo
(
const
isChatPage
=
useMemo
(
...
@@ -46,14 +46,16 @@ const Layout = ({ children }: { children: JSX.Element }) => {
...
@@ -46,14 +46,16 @@ const Layout = ({ children }: { children: JSX.Element }) => {
const
resize
=
throttle
(()
=>
{
const
resize
=
throttle
(()
=>
{
setScreenWidth
(
document
.
documentElement
.
clientWidth
);
setScreenWidth
(
document
.
documentElement
.
clientWidth
);
},
300
);
},
300
);
resize
();
window
.
addEventListener
(
'resize'
,
resize
);
window
.
addEventListener
(
'resize'
,
resize
);
resize
();
loadGitStar
();
return
()
=>
{
return
()
=>
{
window
.
removeEventListener
(
'resize'
,
resize
);
window
.
removeEventListener
(
'resize'
,
resize
);
};
};
},
[]);
},
[
loadGitStar
,
setScreenWidth
]);
const
{
data
:
unread
=
0
}
=
useQuery
([
'getUnreadCount'
],
getUnreadCount
,
{
const
{
data
:
unread
=
0
}
=
useQuery
([
'getUnreadCount'
],
getUnreadCount
,
{
enabled
:
!!
userInfo
,
enabled
:
!!
userInfo
,
...
...
client/src/components/Layout/navbar.tsx
View file @
89036f8a
...
@@ -11,6 +11,8 @@ import Avatar from '../Avatar';
...
@@ -11,6 +11,8 @@ import Avatar from '../Avatar';
import
MyIcon
from
'../Icon'
;
import
MyIcon
from
'../Icon'
;
import
Language
from
'../Language'
;
import
Language
from
'../Language'
;
import
{
useTranslation
}
from
'next-i18next'
;
import
{
useTranslation
}
from
'next-i18next'
;
import
{
useGlobalStore
}
from
'@/store/global'
;
import
MyTooltip
from
'../MyTooltip'
;
export
enum
NavbarTypeEnum
{
export
enum
NavbarTypeEnum
{
normal
=
'normal'
,
normal
=
'normal'
,
...
@@ -21,6 +23,7 @@ const Navbar = ({ unread }: { unread: number }) => {
...
@@ -21,6 +23,7 @@ const Navbar = ({ unread }: { unread: number }) => {
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
router
=
useRouter
();
const
router
=
useRouter
();
const
{
userInfo
}
=
useUserStore
();
const
{
userInfo
}
=
useUserStore
();
const
{
gitStar
}
=
useGlobalStore
();
const
{
lastChatAppId
,
lastChatId
}
=
useChatStore
();
const
{
lastChatAppId
,
lastChatId
}
=
useChatStore
();
const
navbarList
=
useMemo
(
const
navbarList
=
useMemo
(
()
=>
[
()
=>
[
...
@@ -158,16 +161,18 @@ const Navbar = ({ unread }: { unread: number }) => {
...
@@ -158,16 +161,18 @@ const Navbar = ({ unread }: { unread: number }) => {
)
}
)
}
<
Language
{
...
itemStyles
}
/>
<
Language
{
...
itemStyles
}
/>
{
feConfigs
?.
show_git
&&
(
{
feConfigs
?.
show_git
&&
(
<
Link
<
MyTooltip
label=
{
`Git Star: ${gitStar}`
}
placement=
{
'right-end'
}
>
as=
{
NextLink
}
<
Link
href=
"https://github.com/labring/FastGPT"
as=
{
NextLink
}
target=
{
'_blank'
}
href=
"https://github.com/labring/FastGPT"
{
...
itemStyles
}
target=
{
'_blank'
}
mt=
{
0
}
{
...
itemStyles
}
color=
{
'#9096a5'
}
mt=
{
0
}
>
color=
{
'#9096a5'
}
<
MyIcon
name=
{
'git'
}
width=
{
'22px'
}
height=
{
'22px'
}
/>
>
</
Link
>
<
MyIcon
name=
{
'git'
}
width=
{
'22px'
}
height=
{
'22px'
}
/>
</
Link
>
</
MyTooltip
>
)
}
)
}
</
Flex
>
</
Flex
>
);
);
...
...
client/src/components/MyTooltip/index.tsx
View file @
89036f8a
...
@@ -11,7 +11,7 @@ const MyTooltip = ({ children, forceShow = false, shouldWrapChildren = true, ...
...
@@ -11,7 +11,7 @@ const MyTooltip = ({ children, forceShow = false, shouldWrapChildren = true, ...
return
isPc
||
forceShow
?
(
return
isPc
||
forceShow
?
(
<
Tooltip
<
Tooltip
bg=
{
'white'
}
bg=
{
'white'
}
arrowShadowColor=
{
' rgba(0,0,0,0.
1
)'
}
arrowShadowColor=
{
' rgba(0,0,0,0.
05
)'
}
hasArrow
hasArrow
arrowSize=
{
12
}
arrowSize=
{
12
}
offset=
{
[
-
15
,
15
]
}
offset=
{
[
-
15
,
15
]
}
...
...
client/src/pages/index.tsx
View file @
89036f8a
...
@@ -7,15 +7,13 @@ import { serviceSideProps } from '@/utils/i18n';
...
@@ -7,15 +7,13 @@ import { serviceSideProps } from '@/utils/i18n';
import
{
useTranslation
}
from
'next-i18next'
;
import
{
useTranslation
}
from
'next-i18next'
;
import
styles
from
'./index.module.scss'
;
import
styles
from
'./index.module.scss'
;
import
axios
from
'axios'
;
import
MyIcon
from
'@/components/Icon'
;
import
MyIcon
from
'@/components/Icon'
;
const
Home
=
()
=>
{
const
Home
=
()
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
{
t
}
=
useTranslation
();
const
{
t
}
=
useTranslation
();
const
{
inviterId
}
=
router
.
query
as
{
inviterId
:
string
};
const
{
inviterId
}
=
router
.
query
as
{
inviterId
:
string
};
const
{
isPc
}
=
useGlobalStore
();
const
{
isPc
,
gitStar
}
=
useGlobalStore
();
const
[
star
,
setStar
]
=
useState
(
1500
);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
inviterId
)
{
if
(
inviterId
)
{
...
@@ -136,15 +134,6 @@ const Home = () => {
...
@@ -136,15 +134,6 @@ const Home = () => {
},
500
);
},
500
);
},
[
isPc
]);
},
[
isPc
]);
useEffect
(()
=>
{
(
async
()
=>
{
try
{
const
{
data
:
git
}
=
await
axios
.
get
(
'https://api.github.com/repos/labring/FastGPT'
);
setStar
(
git
.
stargazers_count
);
}
catch
(
error
)
{}
})();
},
[]);
return
(
return
(
<
Flex
<
Flex
className=
{
styles
.
home
}
className=
{
styles
.
home
}
...
@@ -200,7 +189,7 @@ const Home = () => {
...
@@ -200,7 +189,7 @@ const Home = () => {
leftIcon=
{
<
MyIcon
name=
{
'git'
}
w=
{
'20px'
}
/>
}
leftIcon=
{
<
MyIcon
name=
{
'git'
}
w=
{
'20px'
}
/>
}
onClick=
{
()
=>
window
.
open
(
'https://github.com/labring/FastGPT'
,
'_blank'
)
}
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
>
)
}
)
}
<
Button
<
Button
...
...
client/src/pages/tools/index.tsx
View file @
89036f8a
...
@@ -25,7 +25,7 @@ const list = [
...
@@ -25,7 +25,7 @@ const list = [
?
[
?
[
{
{
icon
:
'git'
,
icon
:
'git'
,
label
:
'Git
项目
地址'
,
label
:
'Git
Hub
地址'
,
link
:
'https://github.com/labring/FastGPT'
link
:
'https://github.com/labring/FastGPT'
}
}
]
]
...
...
client/src/store/global.ts
View file @
89036f8a
import
{
create
}
from
'zustand'
;
import
{
create
}
from
'zustand'
;
import
{
devtools
}
from
'zustand/middleware'
;
import
{
devtools
}
from
'zustand/middleware'
;
import
{
immer
}
from
'zustand/middleware/immer'
;
import
{
immer
}
from
'zustand/middleware/immer'
;
import
axios
from
'axios'
;
type
State
=
{
type
State
=
{
loading
:
boolean
;
loading
:
boolean
;
...
@@ -9,6 +10,8 @@ type State = {
...
@@ -9,6 +10,8 @@ type State = {
setScreenWidth
:
(
val
:
number
)
=>
void
;
setScreenWidth
:
(
val
:
number
)
=>
void
;
isPc
?:
boolean
;
isPc
?:
boolean
;
initIsPc
(
val
:
boolean
):
void
;
initIsPc
(
val
:
boolean
):
void
;
gitStar
:
number
;
loadGitStar
:
()
=>
Promise
<
void
>
;
};
};
export
const
useGlobalStore
=
create
<
State
>
()(
export
const
useGlobalStore
=
create
<
State
>
()(
...
@@ -35,6 +38,16 @@ export const useGlobalStore = create<State>()(
...
@@ -35,6 +38,16 @@ export const useGlobalStore = create<State>()(
set
((
state
)
=>
{
set
((
state
)
=>
{
state
.
isPc
=
val
;
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