1
This commit is contained in:
@@ -315,6 +315,10 @@ export async function adminChangePassword(oldPwd: string, newPwd: string): Promi
|
||||
await api.post('/admin/change-password', { old_password: oldPwd, new_password: newPwd });
|
||||
}
|
||||
|
||||
export async function getSiteInfo(): Promise<{ siteName: string; siteLogo: string; userAgreementUrl: string; privacyPolicyUrl: string }> {
|
||||
return api.get('/auth/site-info', false);
|
||||
}
|
||||
|
||||
// ── Recharge Packages ───────────────────────────────────
|
||||
|
||||
export async function getRechargePackages(): Promise<any[]> {
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
} from '@ant-design/icons';
|
||||
import { Outlet, useNavigate, useLocation, Navigate } from 'react-router-dom';
|
||||
import { useAdminStore } from '../store';
|
||||
import { getMenuConfigs, adminChangePassword } from '../api';
|
||||
import { getMenuConfigs, adminChangePassword, getSiteInfo } from '../api';
|
||||
|
||||
const { Sider, Content } = Layout;
|
||||
|
||||
@@ -53,6 +53,35 @@ const AdminLayout: React.FC = () => {
|
||||
const [menuItems, setMenuItems] = useState<any[]>([]);
|
||||
const [pwdModal, setPwdModal] = useState(false);
|
||||
const [pwdForm] = Form.useForm();
|
||||
const [siteName, setSiteName] = useState(() => {
|
||||
const cached = localStorage.getItem('siteInfo');
|
||||
return cached ? JSON.parse(cached).siteName || '管理后台' : '管理后台';
|
||||
});
|
||||
const [siteLogo, setSiteLogo] = useState(() => {
|
||||
const cached = localStorage.getItem('siteInfo');
|
||||
return cached ? JSON.parse(cached).siteLogo || '' : '';
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
getSiteInfo().then(info => {
|
||||
const name = info.siteName || '管理后台';
|
||||
const logo = info.siteLogo || '';
|
||||
setSiteName(name);
|
||||
setSiteLogo(logo);
|
||||
document.title = name;
|
||||
localStorage.setItem('siteInfo', JSON.stringify({ siteName: name, siteLogo: logo }));
|
||||
if (logo) {
|
||||
let faviconLink = document.querySelector('link[rel="icon"]') as HTMLLinkElement;
|
||||
if (!faviconLink) {
|
||||
faviconLink = document.createElement('link');
|
||||
faviconLink.rel = 'icon';
|
||||
document.head.appendChild(faviconLink);
|
||||
}
|
||||
faviconLink.href = logo;
|
||||
faviconLink.type = 'image/png';
|
||||
}
|
||||
}).catch(() => {});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
getMenuConfigs().then(data => {
|
||||
@@ -198,12 +227,17 @@ const AdminLayout: React.FC = () => {
|
||||
background: 'linear-gradient(135deg, #6366f1, #8b5cf6)',
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||
boxShadow: '0 2px 8px rgba(99,102,241,0.3)',
|
||||
overflow: 'hidden',
|
||||
}}>
|
||||
<ThunderboltOutlined style={{ fontSize: 16, color: '#fff' }} />
|
||||
{siteLogo ? (
|
||||
<img src={siteLogo} alt="logo" style={{ width: 24, height: 24, objectFit: 'contain' }} />
|
||||
) : (
|
||||
<ThunderboltOutlined style={{ fontSize: 16, color: '#fff' }} />
|
||||
)}
|
||||
</div>
|
||||
{!collapsed && (
|
||||
<span style={{ color: '#1f2937', fontSize: 15, fontWeight: 600, letterSpacing: -0.02 }}>
|
||||
管理后台
|
||||
{siteName}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
@@ -218,12 +252,12 @@ const AdminLayout: React.FC = () => {
|
||||
background: 'transparent',
|
||||
border: 'none',
|
||||
paddingTop: 8,
|
||||
marginTop: 8,
|
||||
}}
|
||||
onClick={({ key }) => {
|
||||
if (key.startsWith('group-')) return;
|
||||
navigate(key);
|
||||
}}
|
||||
style={{ background: 'transparent', borderRight: 0, marginTop: 8 }}
|
||||
theme="light"
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user