2025-03-16 23:00:31 +08:00
|
|
|
|
import { AllOptionKeyName } from '@/services/enum/optionEnum';
|
2025-02-22 14:58:48 +08:00
|
|
|
|
import { GetOptions, getOptionsStringValue, SaveOptions } from '@/services/services/options/optionsTool';
|
2024-10-18 12:46:58 +08:00
|
|
|
|
import { useOptionsStore } from '@/store/options';
|
|
|
|
|
|
import { useSoftStore } from '@/store/software';
|
|
|
|
|
|
import { Button, Card, Col, Form, Input, message, Row } from 'antd';
|
|
|
|
|
|
import TextArea from 'antd/es/input/TextArea';
|
|
|
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
|
|
|
2025-02-22 14:58:48 +08:00
|
|
|
|
interface DubSettingTTsOptionsProps {
|
|
|
|
|
|
visible?: boolean; // 添加 visible 属性
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const DubSettingTTsOptions: React.FC<DubSettingTTsOptionsProps> = ({ visible }) => {
|
2024-10-18 12:46:58 +08:00
|
|
|
|
|
|
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
|
const { ttsOptions, setTTsOptions } = useOptionsStore();
|
2025-02-22 14:58:48 +08:00
|
|
|
|
const { setTopSpinning, setTopSpinTip } = useSoftStore();
|
2024-10-18 12:46:58 +08:00
|
|
|
|
const [messageApi, messageHolder] = message.useMessage();
|
|
|
|
|
|
|
|
|
|
|
|
async function onFinish(values: any): Promise<void> {
|
|
|
|
|
|
setTopSpinning(true);
|
|
|
|
|
|
setTopSpinTip("正在保存EdgeTTs配置");
|
|
|
|
|
|
try {
|
|
|
|
|
|
await SaveOptions(values);
|
|
|
|
|
|
setTTsOptions(ttsOptions.map((item: OptionModel.Option) => {
|
|
|
|
|
|
if (item.key === "EdgeTTsRoles") {
|
|
|
|
|
|
item.value = values.edgeTTsRoles
|
|
|
|
|
|
}
|
|
|
|
|
|
return item
|
|
|
|
|
|
}));
|
|
|
|
|
|
messageApi.success('设置成功');
|
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
|
messageApi.error(error.message);
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setTopSpinning(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-02-22 14:58:48 +08:00
|
|
|
|
|
2024-10-18 12:46:58 +08:00
|
|
|
|
useEffect(() => {
|
2025-02-22 14:58:48 +08:00
|
|
|
|
if (!visible) return;
|
|
|
|
|
|
setTopSpinning(true);
|
|
|
|
|
|
setTopSpinTip("加载信息中");
|
|
|
|
|
|
// 这边加载所有的配音数据
|
2025-03-16 23:00:31 +08:00
|
|
|
|
GetOptions(AllOptionKeyName.TTS).then((res) => {
|
2025-02-22 14:58:48 +08:00
|
|
|
|
setTTsOptions(res);
|
|
|
|
|
|
form.setFieldsValue({ edgeTTsRoles: getOptionsStringValue(res, 'EdgeTTsRoles', "{}") })
|
|
|
|
|
|
}
|
|
|
|
|
|
).catch((err) => {
|
|
|
|
|
|
console.error(err);
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
setTopSpinning(false);
|
|
|
|
|
|
});
|
|
|
|
|
|
}, [visible]);
|
2024-10-18 12:46:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Card title="配置" >
|
|
|
|
|
|
<Form form={form} name="advanced_search" onFinish={onFinish} layout="vertical">
|
|
|
|
|
|
<Row gutter={24}>
|
|
|
|
|
|
<Col span={8}>
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
|
label="语音合成角色"
|
|
|
|
|
|
name="edgeTTsRoles"
|
|
|
|
|
|
>
|
|
|
|
|
|
<TextArea placeholder="请输入EdgeTTs合成角色,JSON格式" autoSize={{ minRows: 6, maxRows: 6 }} />
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
<Form.Item wrapperCol={{ offset: 0, span: 16 }}>
|
|
|
|
|
|
<Button color="primary" variant="filled" htmlType="submit">
|
|
|
|
|
|
保存EdgeTTs配置
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</Form.Item>
|
|
|
|
|
|
</Form>
|
|
|
|
|
|
{messageHolder}
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default DubSettingTTsOptions;
|