chore: update default theme style

This commit is contained in:
JustSong
2025-01-31 23:01:03 +08:00
parent fa2e8f44b1
commit 38a42bb265
5 changed files with 133 additions and 100 deletions

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Header, Segment } from 'semantic-ui-react'; import { Card } from 'semantic-ui-react';
import { API, showError } from '../../helpers'; import { API, showError } from '../../helpers';
import { marked } from 'marked'; import { marked } from 'marked';
@@ -7,52 +7,40 @@ const About = () => {
const [about, setAbout] = useState(''); const [about, setAbout] = useState('');
const [aboutLoaded, setAboutLoaded] = useState(false); const [aboutLoaded, setAboutLoaded] = useState(false);
const displayAbout = async () => { // ... 其他函数保持不变 ...
setAbout(localStorage.getItem('about') || '');
const res = await API.get('/api/about');
const { success, message, data } = res.data;
if (success) {
let aboutContent = data;
if (!data.startsWith('https://')) {
aboutContent = marked.parse(data);
}
setAbout(aboutContent);
localStorage.setItem('about', aboutContent);
} else {
showError(message);
setAbout('加载关于内容失败...');
}
setAboutLoaded(true);
};
useEffect(() => {
displayAbout().then();
}, []);
return ( return (
<> <div className='dashboard-container'>
{ <Card fluid className='chart-card'>
aboutLoaded && about === '' ? <> <Card.Content>
<Segment> <Card.Header className='header'>关于系统</Card.Header>
<Header as='h3'>关于</Header> {aboutLoaded && about === '' ? (
<p>可在设置页面设置关于内容支持 HTML & Markdown</p> <>
项目仓库地址 <p>可在设置页面设置关于内容支持 HTML & Markdown</p>
<a href='https://github.com/songquanpeng/one-api'> 项目仓库地址
https://github.com/songquanpeng/one-api <a href='https://github.com/songquanpeng/one-api'>
</a> https://github.com/songquanpeng/one-api
</Segment> </a>
</> : <> </>
{ ) : (
about.startsWith('https://') ? <iframe <>
src={about} {about.startsWith('https://') ? (
style={{ width: '100%', height: '100vh', border: 'none' }} <iframe
/> : <div style={{ fontSize: 'larger' }} dangerouslySetInnerHTML={{ __html: about }}></div> src={about}
} style={{ width: '100%', height: '100vh', border: 'none' }}
</> />
} ) : (
</> <div
style={{ fontSize: 'larger' }}
dangerouslySetInnerHTML={{ __html: about }}
></div>
)}
</>
)}
</Card.Content>
</Card>
</div>
); );
}; };
export default About; export default About;

View File

@@ -83,4 +83,28 @@
.charts-grid .column { .charts-grid .column {
padding: 0.25rem !important; padding: 0.25rem !important;
} }
}
/* 设置页面的 Tab 样式 */
.settings-tab {
margin-top: 1rem !important;
border-bottom: none !important;
}
.settings-tab .item {
color: #2B3674 !important;
font-weight: 500 !important;
padding: 0.8rem 1.2rem !important;
}
.settings-tab .active.item {
color: #4318FF !important;
font-weight: 600 !important;
border-color: #4318FF !important;
}
.ui.tab.segment {
border: none !important;
box-shadow: none !important;
padding: 1rem 0 !important;
} }

View File

@@ -1,11 +1,16 @@
import React from 'react'; import React from 'react';
import { Header, Segment } from 'semantic-ui-react'; import { Card } from 'semantic-ui-react';
import LogsTable from '../../components/LogsTable'; import LogsTable from '../../components/LogsTable';
const Token = () => ( const Log = () => (
<> <div className='dashboard-container'>
<LogsTable /> <Card fluid className='chart-card'>
</> <Card.Content>
<Card.Header className='header'>操作日志</Card.Header>
<LogsTable />
</Card.Content>
</Card>
</div>
); );
export default Token; export default Log;

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { Segment, Tab } from 'semantic-ui-react'; import { Card, Tab } from 'semantic-ui-react';
import SystemSetting from '../../components/SystemSetting'; import SystemSetting from '../../components/SystemSetting';
import { isRoot } from '../../helpers'; import { isRoot } from '../../helpers';
import OtherSetting from '../../components/OtherSetting'; import OtherSetting from '../../components/OtherSetting';
@@ -14,8 +14,8 @@ const Setting = () => {
<Tab.Pane attached={false}> <Tab.Pane attached={false}>
<PersonalSetting /> <PersonalSetting />
</Tab.Pane> </Tab.Pane>
) ),
} },
]; ];
if (isRoot()) { if (isRoot()) {
@@ -25,7 +25,7 @@ const Setting = () => {
<Tab.Pane attached={false}> <Tab.Pane attached={false}>
<OperationSetting /> <OperationSetting />
</Tab.Pane> </Tab.Pane>
) ),
}); });
panes.push({ panes.push({
menuItem: '系统设置', menuItem: '系统设置',
@@ -33,7 +33,7 @@ const Setting = () => {
<Tab.Pane attached={false}> <Tab.Pane attached={false}>
<SystemSetting /> <SystemSetting />
</Tab.Pane> </Tab.Pane>
) ),
}); });
panes.push({ panes.push({
menuItem: '其他设置', menuItem: '其他设置',
@@ -41,14 +41,26 @@ const Setting = () => {
<Tab.Pane attached={false}> <Tab.Pane attached={false}>
<OtherSetting /> <OtherSetting />
</Tab.Pane> </Tab.Pane>
) ),
}); });
} }
return ( return (
<Segment> <div className='dashboard-container'>
<Tab menu={{ secondary: true, pointing: true }} panes={panes} /> <Card fluid className='chart-card'>
</Segment> <Card.Content>
<Card.Header className='header'>系统设置</Card.Header>
<Tab
menu={{
secondary: true,
pointing: true,
className: 'settings-tab', // 添加自定义类名以便样式化
}}
panes={panes}
/>
</Card.Content>
</Card>
</div>
); );
}; };

View File

@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Button, Form, Grid, Header, Segment, Statistic } from 'semantic-ui-react'; import { Button, Form, Grid, Header, Card, Statistic } from 'semantic-ui-react';
import { API, showError, showInfo, showSuccess } from '../../helpers'; import { API, showError, showInfo, showSuccess } from '../../helpers';
import { renderQuota } from '../../helpers/render'; import { renderQuota } from '../../helpers/render';
@@ -12,13 +12,13 @@ const TopUp = () => {
const topUp = async () => { const topUp = async () => {
if (redemptionCode === '') { if (redemptionCode === '') {
showInfo('请输入充值码!') showInfo('请输入充值码!');
return; return;
} }
setIsSubmitting(true); setIsSubmitting(true);
try { try {
const res = await API.post('/api/user/topup', { const res = await API.post('/api/user/topup', {
key: redemptionCode key: redemptionCode,
}); });
const { success, message, data } = res.data; const { success, message, data } = res.data;
if (success) { if (success) {
@@ -33,7 +33,7 @@ const TopUp = () => {
} catch (err) { } catch (err) {
showError('请求失败'); showError('请求失败');
} finally { } finally {
setIsSubmitting(false); setIsSubmitting(false);
} }
}; };
@@ -45,23 +45,23 @@ const TopUp = () => {
let url = new URL(topUpLink); let url = new URL(topUpLink);
let username = user.username; let username = user.username;
let user_id = user.id; let user_id = user.id;
// add username and user_id to the topup link // add username and user_id to the topup link
url.searchParams.append('username', username); url.searchParams.append('username', username);
url.searchParams.append('user_id', user_id); url.searchParams.append('user_id', user_id);
url.searchParams.append('transaction_id', crypto.randomUUID()); url.searchParams.append('transaction_id', crypto.randomUUID());
window.open(url.toString(), '_blank'); window.open(url.toString(), '_blank');
}; };
const getUserQuota = async ()=>{ const getUserQuota = async () => {
let res = await API.get(`/api/user/self`); let res = await API.get(`/api/user/self`);
const {success, message, data} = res.data; const { success, message, data } = res.data;
if (success) { if (success) {
setUserQuota(data.quota); setUserQuota(data.quota);
setUser(data); setUser(data);
} else { } else {
showError(message); showError(message);
} }
} };
useEffect(() => { useEffect(() => {
let status = localStorage.getItem('status'); let status = localStorage.getItem('status');
@@ -75,38 +75,42 @@ const TopUp = () => {
}, []); }, []);
return ( return (
<Segment> <div className='dashboard-container'>
<Header as='h3'>充值额度</Header> <Card fluid className='chart-card'>
<Grid columns={2} stackable> <Card.Content>
<Grid.Column> <Card.Header className='header'>充值额度</Card.Header>
<Form> <Grid columns={2} stackable>
<Form.Input <Grid.Column>
placeholder='兑换码' <Form>
name='redemptionCode' <Form.Input
value={redemptionCode} placeholder='兑换码'
onChange={(e) => { name='redemptionCode'
setRedemptionCode(e.target.value); value={redemptionCode}
}} onChange={(e) => {
/> setRedemptionCode(e.target.value);
<Button color='green' onClick={openTopUpLink}> }}
充值 />
</Button> <Button color='green' onClick={openTopUpLink}>
<Button color='yellow' onClick={topUp} disabled={isSubmitting}> 充值
{isSubmitting ? '兑换中...' : '兑换'} </Button>
</Button> <Button color='yellow' onClick={topUp} disabled={isSubmitting}>
</Form> {isSubmitting ? '兑换中...' : '兑换'}
</Grid.Column> </Button>
<Grid.Column> </Form>
<Statistic.Group widths='one'> </Grid.Column>
<Statistic> <Grid.Column>
<Statistic.Value>{renderQuota(userQuota)}</Statistic.Value> <Statistic.Group widths='one'>
<Statistic.Label>剩余额度</Statistic.Label> <Statistic>
</Statistic> <Statistic.Value>{renderQuota(userQuota)}</Statistic.Value>
</Statistic.Group> <Statistic.Label>剩余额度</Statistic.Label>
</Grid.Column> </Statistic>
</Grid> </Statistic.Group>
</Segment> </Grid.Column>
</Grid>
</Card.Content>
</Card>
</div>
); );
}; };
export default TopUp; export default TopUp;