mirror of
https://github.com/linux-do/new-api.git
synced 2025-11-09 23:53:41 +08:00
feat: 允许关闭绘图选项
This commit is contained in:
@@ -3,7 +3,8 @@ import {Divider, Form, Grid, Header} from 'semantic-ui-react';
|
|||||||
import {API, showError, showSuccess, timestamp2string, verifyJSON} from '../helpers';
|
import {API, showError, showSuccess, timestamp2string, verifyJSON} from '../helpers';
|
||||||
|
|
||||||
const OperationSetting = () => {
|
const OperationSetting = () => {
|
||||||
let now = new Date();let [inputs, setInputs] = useState({
|
let now = new Date();
|
||||||
|
let [inputs, setInputs] = useState({
|
||||||
QuotaForNewUser: 0,
|
QuotaForNewUser: 0,
|
||||||
QuotaForInviter: 0,
|
QuotaForInviter: 0,
|
||||||
QuotaForInvitee: 0,
|
QuotaForInvitee: 0,
|
||||||
@@ -20,10 +21,14 @@ const OperationSetting = () => {
|
|||||||
LogConsumeEnabled: '',
|
LogConsumeEnabled: '',
|
||||||
DisplayInCurrencyEnabled: '',
|
DisplayInCurrencyEnabled: '',
|
||||||
DisplayTokenStatEnabled: '',
|
DisplayTokenStatEnabled: '',
|
||||||
|
DrawingEnabled: '',
|
||||||
|
DataExportEnabled: '',
|
||||||
|
DataExportInterval: 5,
|
||||||
RetryTimes: 0
|
RetryTimes: 0
|
||||||
});
|
});
|
||||||
const [originInputs, setOriginInputs] = useState({});
|
const [originInputs, setOriginInputs] = useState({});
|
||||||
let [loading, setLoading] = useState(false);let [historyTimestamp, setHistoryTimestamp] = useState(timestamp2string(now.getTime() / 1000 - 30 * 24 * 3600)); // a month ago
|
let [loading, setLoading] = useState(false);
|
||||||
|
let [historyTimestamp, setHistoryTimestamp] = useState(timestamp2string(now.getTime() / 1000 - 30 * 24 * 3600)); // a month ago
|
||||||
|
|
||||||
const getOptions = async () => {
|
const getOptions = async () => {
|
||||||
const res = await API.get('/api/option/');
|
const res = await API.get('/api/option/');
|
||||||
@@ -66,7 +71,7 @@ const OperationSetting = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleInputChange = async (e, {name, value}) => {
|
const handleInputChange = async (e, {name, value}) => {
|
||||||
if (name.endsWith('Enabled')) {
|
if (name.endsWith('Enabled') || name === 'DataExportInterval') {
|
||||||
await updateOption(name, value);
|
await updateOption(name, value);
|
||||||
} else {
|
} else {
|
||||||
setInputs((inputs) => ({...inputs, [name]: value}));
|
setInputs((inputs) => ({...inputs, [name]: value}));
|
||||||
@@ -146,7 +151,8 @@ const OperationSetting = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showError('日志清理失败:' + message);
|
showError('日志清理失败:' + message);
|
||||||
};return (
|
};
|
||||||
|
return (
|
||||||
<Grid columns={1}>
|
<Grid columns={1}>
|
||||||
<Grid.Column>
|
<Grid.Column>
|
||||||
<Form loading={loading}>
|
<Form loading={loading}>
|
||||||
@@ -208,6 +214,12 @@ const OperationSetting = () => {
|
|||||||
name='DisplayTokenStatEnabled'
|
name='DisplayTokenStatEnabled'
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
/>
|
/>
|
||||||
|
<Form.Checkbox
|
||||||
|
checked={inputs.DrawingEnabled === 'true'}
|
||||||
|
label='启用绘图功能'
|
||||||
|
name='DrawingEnabled'
|
||||||
|
onChange={handleInputChange}
|
||||||
|
/>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Form.Button onClick={() => {
|
<Form.Button onClick={() => {
|
||||||
submitConfig('general').then();
|
submitConfig('general').then();
|
||||||
@@ -222,7 +234,28 @@ const OperationSetting = () => {
|
|||||||
name='LogConsumeEnabled'
|
name='LogConsumeEnabled'
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
|
<Form.Group inline>
|
||||||
|
<Form.Checkbox
|
||||||
|
checked={inputs.DataExportEnabled === 'true'}
|
||||||
|
label='启用数据看板(实验性)'
|
||||||
|
name='DataExportEnabled'
|
||||||
|
onChange={handleInputChange}
|
||||||
|
/>
|
||||||
|
<Form.Input
|
||||||
|
label='数据看板更新间隔(分钟,设置过短会影响数据库性能)'
|
||||||
|
name='DataExportInterval'
|
||||||
|
type={'number'}
|
||||||
|
step='1'
|
||||||
|
min='1'
|
||||||
|
onChange={handleInputChange}
|
||||||
|
autoComplete='new-password'
|
||||||
|
value={inputs.DataExportInterval}
|
||||||
|
placeholder='数据看板更新间隔(分钟,设置过短会影响数据库性能)'
|
||||||
|
/>
|
||||||
|
</Form.Group>
|
||||||
|
<Divider/>
|
||||||
<Form.Group widths={4}>
|
<Form.Group widths={4}>
|
||||||
<Form.Input label='目标时间' value={historyTimestamp} type='datetime-local'
|
<Form.Input label='目标时间' value={historyTimestamp} type='datetime-local'
|
||||||
name='history_timestamp'
|
name='history_timestamp'
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {API, getLogo, getSystemName, isAdmin, isMobile, showSuccess} from '../he
|
|||||||
import '../index.css';
|
import '../index.css';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IconAt,
|
IconCalendarClock,
|
||||||
IconHistogram,
|
IconHistogram,
|
||||||
IconGift,
|
IconGift,
|
||||||
IconKey,
|
IconKey,
|
||||||
@@ -74,11 +74,19 @@ let headerButtons = [
|
|||||||
to: '/log',
|
to: '/log',
|
||||||
icon: <IconHistogram/>
|
icon: <IconHistogram/>
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: '数据看版',
|
||||||
|
itemKey: 'detail',
|
||||||
|
to: '/detail',
|
||||||
|
icon: <IconCalendarClock />,
|
||||||
|
className: localStorage.getItem('enable_data_export') === 'true'?'semi-navigation-item-normal':'tableHiddle',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: '绘图',
|
text: '绘图',
|
||||||
itemKey: 'midjourney',
|
itemKey: 'midjourney',
|
||||||
to: '/midjourney',
|
to: '/midjourney',
|
||||||
icon: <IconImage/>
|
icon: <IconImage/>,
|
||||||
|
className: localStorage.getItem('enable_drawing') === 'true'?'semi-navigation-item-normal':'tableHiddle',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '设置',
|
text: '设置',
|
||||||
@@ -133,6 +141,7 @@ const SiderBar = () => {
|
|||||||
setting: "/setting",
|
setting: "/setting",
|
||||||
about: "/about",
|
about: "/about",
|
||||||
chat: "/chat",
|
chat: "/chat",
|
||||||
|
detail: "/detail",
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
|
|||||||
Reference in New Issue
Block a user