- Create a new DrawingSetting component for managing drawing-related configurations - Add a dedicated "Drawing Settings" tab with Palette icon in the settings page - Remove drawing settings section from the OperationSetting component - Update import path to use Drawing directory instead of Operation directory - Improve UI organization by separating drawing settings from general operations
65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
import React, { useEffect, useState } from 'react';
|
|
import { Card, Spin } from '@douyinfe/semi-ui';
|
|
import SettingsDrawing from '../../pages/Setting/Drawing/SettingsDrawing.js';
|
|
import { API, showError } from '../../helpers';
|
|
|
|
const DrawingSetting = () => {
|
|
let [inputs, setInputs] = useState({
|
|
/* 绘图设置 */
|
|
DrawingEnabled: false,
|
|
MjNotifyEnabled: false,
|
|
MjAccountFilterEnabled: false,
|
|
MjForwardUrlEnabled: false,
|
|
MjModeClearEnabled: false,
|
|
MjActionCheckSuccessEnabled: false,
|
|
});
|
|
|
|
let [loading, setLoading] = useState(false);
|
|
|
|
const getOptions = async () => {
|
|
const res = await API.get('/api/option/');
|
|
const { success, message, data } = res.data;
|
|
if (success) {
|
|
let newInputs = {};
|
|
data.forEach((item) => {
|
|
if (item.key.endsWith('Enabled')) {
|
|
newInputs[item.key] = item.value === 'true' ? true : false;
|
|
} else {
|
|
newInputs[item.key] = item.value;
|
|
}
|
|
});
|
|
|
|
setInputs(newInputs);
|
|
} else {
|
|
showError(message);
|
|
}
|
|
};
|
|
|
|
async function onRefresh() {
|
|
try {
|
|
setLoading(true);
|
|
await getOptions();
|
|
} catch (error) {
|
|
showError('刷新失败');
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
}
|
|
|
|
useEffect(() => {
|
|
onRefresh();
|
|
}, []);
|
|
|
|
return (
|
|
<>
|
|
<Spin spinning={loading} size='large'>
|
|
{/* 绘图设置 */}
|
|
<Card style={{ marginTop: '10px' }}>
|
|
<SettingsDrawing options={inputs} refresh={onRefresh} />
|
|
</Card>
|
|
</Spin>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default DrawingSetting;
|