diff --git a/web/app/components/header/assets/github-icon.svg b/web/app/components/header/assets/github-icon.svg new file mode 100644 index 0000000000..f9b3b05b4b --- /dev/null +++ b/web/app/components/header/assets/github-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/web/app/components/header/index.module.css b/web/app/components/header/index.module.css index 1c065608cc..dad8a1a007 100644 --- a/web/app/components/header/index.module.css +++ b/web/app/components/header/index.module.css @@ -16,9 +16,10 @@ } .github-icon { - width: 16px; - height: 16px; - background: url(./assets/github.svg) center center no-repeat; + width: 18px; + height: 18px; + background: url(./assets/github-icon.svg) center center no-repeat; + background-size: contain; } .alpha { diff --git a/web/app/components/header/index.tsx b/web/app/components/header/index.tsx index 44df71205a..6823470cd3 100644 --- a/web/app/components/header/index.tsx +++ b/web/app/components/header/index.tsx @@ -1,5 +1,5 @@ 'use client' -import { useCallback, useState } from 'react' +import { useCallback, useEffect, useState } from 'react' import type { FC } from 'react' import useSWRInfinite from 'swr/infinite' import { useTranslation } from 'react-i18next' @@ -12,8 +12,8 @@ import Link from 'next/link' import AccountDropdown from './account-dropdown' import Nav from './nav' import s from './index.module.css' +import type { GithubRepo, LangGeniusVersionResponse, UserProfileResponse } from '@/models/common' import type { AppListResponse } from '@/models/app' -import type { LangGeniusVersionResponse, UserProfileResponse } from '@/models/common' import NewAppDialog from '@/app/(commonLayout)/apps/NewAppDialog' import { WorkspaceProvider } from '@/context/workspace-context' import { useDatasetsContext } from '@/context/datasets-context' @@ -62,6 +62,13 @@ const Header: FC = ({ const selectedSegment = useSelectedLayoutSegment() const isPluginsComingSoon = selectedSegment === 'plugins-coming-soon' const isExplore = selectedSegment === 'explore' + const [starCount, setStarCount] = useState(0) + + useEffect(() => { + globalThis.fetch('https://api.github.com/repos/langgenius/dify').then(res => res.json()).then((data: GithubRepo) => { + setStarCount(data.stargazers_count) + }) + }, []) const appItems = flatten(appsData?.map(appData => appData.data)) const handleLoadmore = useCallback(() => { @@ -82,17 +89,23 @@ const Header: FC = ({ 'flex flex-1 items-center justify-between px-4', )}>
- +
- {/* Add it when has many stars */} -
-
-
{t('common.menus.status')}
-
+ { + starCount > 0 && ( + +
+
+ Star +
+
{`${starCount}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
+ + ) + }
}> = ({ url, body }) => { @@ -73,7 +73,7 @@ export const updateMemberRole: Fetcher } -export const deleteMemberOrCancelInvitation: Fetcher = ({ url }) => { +export const deleteMemberOrCancelInvitation: Fetcher = ({ url }) => { return del(url) as Promise } @@ -88,4 +88,3 @@ export const fetchWorkspaces: Fetcher<{ workspaces: IWorkspace[] }, { url: strin export const switchWorkspace: Fetcher }> = ({ url, body }) => { return post(url, { body }) as Promise } -