From 85505e5c41bf99da1aadf8f58608b155e4d585e0 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 28 Aug 2025 07:32:52 +0000 Subject: [PATCH 1/3] feat: add GitHub star count component to sidebar - Add GitHub star component to sidebar bottom section - Fetch star count from space.langbot.app API - Display star count with proper internationalization - Open GitHub repository in new tab when clicked - Follow existing sidebar styling patterns Co-Authored-By: Rock --- .../components/home-sidebar/HomeSidebar.tsx | 30 ++++++++++++++++++- web/src/i18n/locales/zh-Hans.ts | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/web/src/app/home/components/home-sidebar/HomeSidebar.tsx b/web/src/app/home/components/home-sidebar/HomeSidebar.tsx index 25b3b58f5..9b4731477 100644 --- a/web/src/app/home/components/home-sidebar/HomeSidebar.tsx +++ b/web/src/app/home/components/home-sidebar/HomeSidebar.tsx @@ -9,7 +9,7 @@ import { import { useRouter, usePathname } from 'next/navigation'; import { sidebarConfigList } from '@/app/home/components/home-sidebar/sidbarConfigList'; import langbotIcon from '@/app/assets/langbot-logo.webp'; -import { systemInfo } from '@/app/infra/http/HttpClient'; +import { systemInfo, spaceClient } from '@/app/infra/http/HttpClient'; import { useTranslation } from 'react-i18next'; import { Moon, Sun, Monitor } from 'lucide-react'; import { useTheme } from 'next-themes'; @@ -44,6 +44,7 @@ export default function HomeSidebar({ const [popoverOpen, setPopoverOpen] = useState(false); const [passwordChangeOpen, setPasswordChangeOpen] = useState(false); const [languageSelectorOpen, setLanguageSelectorOpen] = useState(false); + const [starCount, setStarCount] = useState(null); useEffect(() => { initSelect(); @@ -51,6 +52,16 @@ export default function HomeSidebar({ localStorage.setItem('token', 'test-token'); localStorage.setItem('userEmail', 'test@example.com'); } + + spaceClient + .get('/api/v1/dist/info/repo') + .then((response) => { + const data = response as { repo: { stargazers_count: number } }; + setStarCount(data.repo.stargazers_count); + }) + .catch((error) => { + console.error('Failed to fetch GitHub star count:', error); + }); return () => console.log('sidebar.unmounted'); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -150,6 +161,23 @@ export default function HomeSidebar({
+ { + window.open('https://github.com/langbot-app/LangBot', '_blank'); + }} + isSelected={false} + icon={ + + + + } + name={`${t('common.githubStars')} ${starCount !== null ? `(${starCount.toLocaleString()})` : ''}`} + /> + { // open docs.langbot.app diff --git a/web/src/i18n/locales/zh-Hans.ts b/web/src/i18n/locales/zh-Hans.ts index adf20e26b..6e28efeaf 100644 --- a/web/src/i18n/locales/zh-Hans.ts +++ b/web/src/i18n/locales/zh-Hans.ts @@ -57,6 +57,7 @@ const zhHans = { passwordsDoNotMatch: '两次输入的密码不一致', changePasswordSuccess: '密码修改成功', changePasswordFailed: '密码修改失败,请检查当前密码是否正确', + githubStars: 'GitHub 星标', }, notFound: { title: '页面不存在', From deef45af398fd515eeb0e45eda94ed5ae764c29c Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Thu, 28 Aug 2025 21:01:05 +0800 Subject: [PATCH 2/3] perf: ui --- .../components/home-sidebar/HomeSidebar.tsx | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/web/src/app/home/components/home-sidebar/HomeSidebar.tsx b/web/src/app/home/components/home-sidebar/HomeSidebar.tsx index 9b4731477..4009c77a6 100644 --- a/web/src/app/home/components/home-sidebar/HomeSidebar.tsx +++ b/web/src/app/home/components/home-sidebar/HomeSidebar.tsx @@ -22,6 +22,7 @@ import { import { Button } from '@/components/ui/button'; import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group'; import { LanguageSelector } from '@/components/ui/language-selector'; +import { Badge } from '@/components/ui/badge'; import PasswordChangeDialog from '@/app/home/components/password-change-dialog/PasswordChangeDialog'; // TODO 侧边导航栏要加动画 @@ -161,22 +162,29 @@ export default function HomeSidebar({
- { - window.open('https://github.com/langbot-app/LangBot', '_blank'); - }} - isSelected={false} - icon={ - { + window.open('https://github.com/langbot-app/LangBot', '_blank'); + }} + className="flex justify-center cursor-pointer p-2 rounded-lg hover:bg-accent/30 transition-colors" + > + - - - } - name={`${t('common.githubStars')} ${starCount !== null ? `(${starCount.toLocaleString()})` : ''}`} - /> + + + +
+ {starCount.toLocaleString()} + +
+ )} { From 5f629de6de2fc58d1acb75a20d3912fd487f0252 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Thu, 28 Aug 2025 21:03:05 +0800 Subject: [PATCH 3/3] chore: remove githubStars text --- web/src/i18n/locales/zh-Hans.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/web/src/i18n/locales/zh-Hans.ts b/web/src/i18n/locales/zh-Hans.ts index 6e28efeaf..adf20e26b 100644 --- a/web/src/i18n/locales/zh-Hans.ts +++ b/web/src/i18n/locales/zh-Hans.ts @@ -57,7 +57,6 @@ const zhHans = { passwordsDoNotMatch: '两次输入的密码不一致', changePasswordSuccess: '密码修改成功', changePasswordFailed: '密码修改失败,请检查当前密码是否正确', - githubStars: 'GitHub 星标', }, notFound: { title: '页面不存在',