add header

This commit is contained in:
hobby
2025-02-27 08:12:47 +08:00
parent be84be0f18
commit 8d0d2b64bd
6 changed files with 82 additions and 30 deletions

View File

@@ -1,11 +1,12 @@
import ChatUI from './components/ChatUI'
import './App.css'
import Layout from './components/Layout'
function App() {
return (
<div className="app-container">
<ChatUI />
</div>
<Layout>
<ChatUI />
</Layout>
)
}

49
src/components/Header.tsx Normal file
View File

@@ -0,0 +1,49 @@
import React, { useEffect } from 'react';
import GitHubButton from 'react-github-btn';
const Header: React.FC = () => {
useEffect(() => {
const fetchGitHubStars = async () => {
try {
const response = await fetch('https://api.github.com/repos/maojindao55/botgroup.chat');
const data = await response.json();
const starsElement = document.getElementById('github-stars');
if (starsElement) {
starsElement.textContent = data.stargazers_count.toLocaleString();
}
} catch (error) {
console.error('Failed to fetch GitHub stars:', error);
}
};
fetchGitHubStars();
}, []);
return (
<header className="bg-transparent fixed top-0 left-0 right-0 z-50 hidden md:block">
<div className="w-full px-2 h-10 flex items-center">
{/* Logo */}
<div className="flex-1 flex items-center">
<a href="/" className="text-sm font-medium text-gray-700 hover:text-gray-500">
botgroup.chat
</a>
</div>
{/* GitHub Star Button */}
<div className="flex items-center justify-end">
<GitHubButton
href="https://github.com/maojindao55/botgroup.chat"
data-color-scheme="no-preference: light; light: light; dark: dark;"
data-size="large"
data-show-count="true"
aria-label="Star maojindao55/botgroup.chat on GitHub"
>
Star
</GitHubButton>
</div>
</div>
</header>
);
};
export default Header;

View File

@@ -1,23 +1,15 @@
interface LayoutProps {
children: React.ReactNode
}
import React from 'react';
import Header from './Header';
function Layout({ children }: LayoutProps) {
const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
return (
<div className="app-container">
<header className="app-header">
{/* 这里可以放导航栏 */}
</header>
<main className="app-main">
<div className="flex flex-col min-h-screen">
<Header />
<main className="flex-1 pt-14">
{children}
</main>
<footer className="app-footer">
{/* 这里可以放页脚信息 */}
</footer>
</div>
)
}
);
};
export default Layout
export default Layout;

View File

@@ -140,11 +140,11 @@ export function generateAICharacters(groupName: string): AICharacter[] {
},
{
id: 'ai8',
name: "智",
name: "智",
personality: "glm",
model: modelConfigs[5].model,
avatar: "/img/glm.gif",
custom_prompt: `你是一个名叫"智"的硅基生命体,你当前在一个叫"${groupName}" 的聊天群里`,
custom_prompt: `你是一个名叫"智"的硅基生命体,你当前在一个叫"${groupName}" 的聊天群里`,
tags: ["新闻报道","分析数据","文字游戏","信息总结"]
}
];