系统配置保存

This commit is contained in:
禺狨 2023-03-28 14:57:48 +08:00
parent e029de2c68
commit dbb7c2802e

View File

@ -10,6 +10,7 @@ import {
Switch, Switch,
Checkbox, Checkbox,
Slider, Slider,
Space,
} from "antd"; } from "antd";
// import styles from "./index.module.less"; // import styles from "./index.module.less";
import { appConfig } from "../../../api/index"; import { appConfig } from "../../../api/index";
@ -56,6 +57,7 @@ const SystemConfigPage = () => {
"system.h5_url": configData[i].key_value, "system.h5_url": configData[i].key_value,
}); });
} else if (configData[i].key_name === "player.poster") { } else if (configData[i].key_name === "player.poster") {
setThumb(configData[i].key_value);
form.setFieldsValue({ form.setFieldsValue({
"player.poster": configData[i].key_value, "player.poster": configData[i].key_value,
}); });
@ -63,8 +65,8 @@ const SystemConfigPage = () => {
configData[i].key_name === "player.is_enabled_bullet_secret" configData[i].key_name === "player.is_enabled_bullet_secret"
) { ) {
let value = 0; let value = 0;
if (configData[i].key_value !== "") { if (configData[i].key_value === "1") {
value = Number(configData[i].key_value); value = 1;
} }
form.setFieldsValue({ form.setFieldsValue({
"player.is_enabled_bullet_secret": value, "player.is_enabled_bullet_secret": value,
@ -85,6 +87,10 @@ const SystemConfigPage = () => {
form.setFieldsValue({ form.setFieldsValue({
"player.bullet_secret_opacity": value, "player.bullet_secret_opacity": value,
}); });
} else if (configData[i].key_name === "system.pc_index_footer_msg") {
form.setFieldsValue({
"system.pc_index_footer_msg": configData[i].key_value,
});
} }
} }
}); });
@ -102,7 +108,25 @@ const SystemConfigPage = () => {
var value = form.getFieldValue("player.bullet_secret_text"); var value = form.getFieldValue("player.bullet_secret_text");
if (e.target.checked) { if (e.target.checked) {
value += "{name}"; value += "{name}";
console.log(value); form.setFieldsValue({
"player.bullet_secret_text": value,
});
}
};
const addEmail = (e: CheckboxChangeEvent) => {
var value = form.getFieldValue("player.bullet_secret_text");
if (e.target.checked) {
value += "{email}";
form.setFieldsValue({
"player.bullet_secret_text": value,
});
}
};
const addIdCard = (e: CheckboxChangeEvent) => {
var value = form.getFieldValue("player.bullet_secret_text");
if (e.target.checked) {
value += "{idCard}";
form.setFieldsValue({ form.setFieldsValue({
"player.bullet_secret_text": value, "player.bullet_secret_text": value,
}); });
@ -115,7 +139,7 @@ const SystemConfigPage = () => {
} }
setLoading(true); setLoading(true);
values["player.bullet_secret_opacity"] = values["player.bullet_secret_opacity"] =
values["player.bullet_secret_opacity"][0] / 100; values["player.bullet_secret_opacity"] / 100;
appConfig.saveAppConfig(values).then((res: any) => { appConfig.saveAppConfig(values).then((res: any) => {
message.success("保存成功!"); message.success("保存成功!");
setLoading(false); setLoading(false);
@ -254,35 +278,37 @@ const SystemConfigPage = () => {
)} )}
{tabKey === 2 && ( {tabKey === 2 && (
<> <>
<Form.Item style={{ marginBottom: 30 }} label="播放器跑马灯">
<Space align="baseline" style={{ height: 32 }}>
<Form.Item <Form.Item
style={{ marginBottom: 30 }}
label="播放器跑马灯"
name="player.is_enabled_bullet_secret" name="player.is_enabled_bullet_secret"
valuePropName="checked" valuePropName="checked"
> >
<div className="d-flex">
<Switch onChange={onSwitchChange} /> <Switch onChange={onSwitchChange} />
</Form.Item>
<div className="helper-text ml-24"> <div className="helper-text ml-24">
</div> </div>
</div> </Space>
</Form.Item> </Form.Item>
<Form.Item <Form.Item style={{ marginBottom: 30 }} label="跑马灯内容">
style={{ marginBottom: 30 }} <Space align="baseline" style={{ height: 32 }}>
label="跑马灯内容" <Form.Item name="player.bullet_secret_text">
name="player.bullet_secret_text"
>
<div className="d-flex">
<Input <Input
style={{ width: 274 }} style={{ width: 274 }}
placeholder="自定义跑马灯内容" placeholder="自定义跑马灯内容"
/> />
</Form.Item>
<Checkbox className="ml-24" onChange={addName}> <Checkbox className="ml-24" onChange={addName}>
</Checkbox> </Checkbox>
<Checkbox className="ml-24"></Checkbox> <Checkbox className="ml-24" onChange={addEmail}>
<Checkbox className="ml-24"></Checkbox>
</div> </Checkbox>
<Checkbox className="ml-24" onChange={addIdCard}>
</Checkbox>
</Space>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
style={{ marginBottom: 30 }} style={{ marginBottom: 30 }}
@ -302,6 +328,13 @@ const SystemConfigPage = () => {
defaultValue={[0, 100]} defaultValue={[0, 100]}
/> />
</Form.Item> </Form.Item>
<Form.Item
style={{ marginBottom: 30 }}
label="网站页脚"
name="system.pc_index_footer_msg"
>
<Input style={{ width: 274 }} placeholder="请填写网站页脚" />
</Form.Item>
{thumb && ( {thumb && (
<Form.Item <Form.Item
style={{ marginBottom: 30 }} style={{ marginBottom: 30 }}