perf: git star
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user