1
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
Button, Card, Form, Input, InputNumber, Modal, message, Select, Space, Switch, Tabs, Typography, Upload,
|
Button, Card, Form, Input, InputNumber, message, Select, Space, Switch, Tabs, Typography, Upload,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import {
|
import {
|
||||||
SettingOutlined, SaveOutlined, UploadOutlined, FilePdfOutlined, EyeOutlined, DatabaseOutlined, PlusOutlined, VideoCameraOutlined, RobotOutlined,
|
SettingOutlined, SaveOutlined, UploadOutlined, FilePdfOutlined, EyeOutlined, DatabaseOutlined, VideoCameraOutlined, RobotOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
createSystemConfig,
|
createSystemConfig,
|
||||||
@@ -28,8 +28,6 @@ const AdminSettings: React.FC = () => {
|
|||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const [uploading, setUploading] = useState('');
|
const [uploading, setUploading] = useState('');
|
||||||
const [addModalOpen, setAddModalOpen] = useState(false);
|
|
||||||
const [addForm] = Form.useForm();
|
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -50,6 +48,8 @@ const AdminSettings: React.FC = () => {
|
|||||||
setConfigs(data);
|
setConfigs(data);
|
||||||
const formValues: Record<string, any> = {};
|
const formValues: Record<string, any> = {};
|
||||||
data.forEach(c => { formValues[c.key] = c.value; });
|
data.forEach(c => { formValues[c.key] = c.value; });
|
||||||
|
// 预扣积分默认值
|
||||||
|
if (!formValues.optimize_hold_credits) formValues.optimize_hold_credits = '5';
|
||||||
formValues.resource_capacity_enabled = capacity.enabled;
|
formValues.resource_capacity_enabled = capacity.enabled;
|
||||||
formValues.resource_capacity_limit_value = capacity.limitValue || '1.000';
|
formValues.resource_capacity_limit_value = capacity.limitValue || '1.000';
|
||||||
formValues.resource_capacity_limit_unit = capacity.limitUnit || 'GB';
|
formValues.resource_capacity_limit_unit = capacity.limitUnit || 'GB';
|
||||||
@@ -71,6 +71,18 @@ const AdminSettings: React.FC = () => {
|
|||||||
await updateSystemConfig(config.id, String(newVal ?? ''));
|
await updateSystemConfig(config.id, String(newVal ?? ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// AI创作预扣积分 - 不存在则创建
|
||||||
|
const holdVal = values.optimize_hold_credits;
|
||||||
|
if (holdVal !== undefined && holdVal !== null && holdVal !== '') {
|
||||||
|
const existing = configs.find(c => c.key === 'optimize_hold_credits');
|
||||||
|
if (existing) {
|
||||||
|
if (String(holdVal) !== existing.value) {
|
||||||
|
await updateSystemConfig(existing.id, String(holdVal));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await createSystemConfig('optimize_hold_credits', String(holdVal), 'AI创作预扣积分数量(防止并发超卖)');
|
||||||
|
}
|
||||||
|
}
|
||||||
await saveGlobalResourceCapacity({
|
await saveGlobalResourceCapacity({
|
||||||
enabled: !!values.resource_capacity_enabled,
|
enabled: !!values.resource_capacity_enabled,
|
||||||
limitValue: String(values.resource_capacity_limit_value ?? '1.000'),
|
limitValue: String(values.resource_capacity_limit_value ?? '1.000'),
|
||||||
@@ -333,20 +345,6 @@ const AdminSettings: React.FC = () => {
|
|||||||
return <Input placeholder={config.description} size="large" />;
|
return <Input placeholder={config.description} size="large" />;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddConfig = async () => {
|
|
||||||
try {
|
|
||||||
const values = await addForm.validateFields();
|
|
||||||
const res = await createSystemConfig(values.key, values.value, values.description || '');
|
|
||||||
setConfigs(prev => [...prev, res]);
|
|
||||||
form.setFieldsValue({ [res.key]: res.value });
|
|
||||||
setAddModalOpen(false);
|
|
||||||
addForm.resetFields();
|
|
||||||
message.success('配置已添加');
|
|
||||||
} catch (e: any) {
|
|
||||||
message.error(e?.message || '添加失败');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <Card loading variant="outlined" style={{ borderRadius: 12 }} />;
|
return <Card loading variant="outlined" style={{ borderRadius: 12 }} />;
|
||||||
}
|
}
|
||||||
@@ -402,6 +400,14 @@ const AdminSettings: React.FC = () => {
|
|||||||
{getFieldComponent(config)}
|
{getFieldComponent(config)}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
))}
|
))}
|
||||||
|
{/* AI创作预扣积分 - 固定显示 */}
|
||||||
|
<Form.Item
|
||||||
|
name="optimize_hold_credits"
|
||||||
|
label={<span style={{ fontWeight: 500 }}>AI创作预扣积分数量</span>}
|
||||||
|
extra="AI创作时预扣积分数量,用于防止并发超卖。预扣后按实际消耗多退少补"
|
||||||
|
>
|
||||||
|
<Input type="number" min={1} placeholder="默认5" size="large" />
|
||||||
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
),
|
),
|
||||||
@@ -536,34 +542,12 @@ const AdminSettings: React.FC = () => {
|
|||||||
<Tabs items={tabItems} defaultActiveKey="basic" />
|
<Tabs items={tabItems} defaultActiveKey="basic" />
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
|
||||||
<Button icon={<PlusOutlined />} onClick={() => setAddModalOpen(true)}>添加配置</Button>
|
|
||||||
<Button type="primary" icon={<SaveOutlined />} onClick={handleSave} loading={saving}
|
<Button type="primary" icon={<SaveOutlined />} onClick={handleSave} loading={saving}
|
||||||
size="large" style={{ borderRadius: 8, minWidth: 140 }}>
|
size="large" style={{ borderRadius: 8, minWidth: 140 }}>
|
||||||
保存配置
|
保存配置
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Modal
|
|
||||||
title="添加系统配置"
|
|
||||||
open={addModalOpen}
|
|
||||||
onOk={handleAddConfig}
|
|
||||||
onCancel={() => { setAddModalOpen(false); addForm.resetFields(); }}
|
|
||||||
okText="添加"
|
|
||||||
cancelText="取消"
|
|
||||||
>
|
|
||||||
<Form form={addForm} layout="vertical">
|
|
||||||
<Form.Item name="key" label="配置键名" rules={[{ required: true, message: '请输入配置键名' }]}>
|
|
||||||
<Input placeholder="例如: optimize_hold_credits" />
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item name="value" label="配置值" rules={[{ required: true, message: '请输入配置值' }]}>
|
|
||||||
<Input placeholder="例如: 5" />
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item name="description" label="描述">
|
|
||||||
<Input placeholder="配置说明(可选)" />
|
|
||||||
</Form.Item>
|
|
||||||
</Form>
|
|
||||||
</Modal>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Vendored
+35
-35
@@ -1,37 +1,37 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
|
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
|
||||||
<title>民众智创</title>
|
<title>民众智创</title>
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
var cached = localStorage.getItem('siteInfo');
|
var cached = localStorage.getItem('siteInfo');
|
||||||
if (cached) {
|
if (cached) {
|
||||||
try {
|
try {
|
||||||
var info = JSON.parse(cached);
|
var info = JSON.parse(cached);
|
||||||
if (info.siteName) {
|
if (info.siteName) {
|
||||||
document.title = info.siteName;
|
document.title = info.siteName;
|
||||||
}
|
}
|
||||||
if (info.siteLogo) {
|
if (info.siteLogo) {
|
||||||
var link = document.querySelector('link[rel="icon"]');
|
var link = document.querySelector('link[rel="icon"]');
|
||||||
if (link) {
|
if (link) {
|
||||||
link.href = info.siteLogo;
|
link.href = info.siteLogo;
|
||||||
link.type = 'image/png';
|
link.type = 'image/png';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<script type="module" crossorigin src="/assets/index-DZg1zviY.js"></script>
|
<script type="module" crossorigin src="/assets/index-DZg1zviY.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-Bsz_Xon-.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-Bsz_Xon-.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>␍
|
<div id="root"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user