mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-12 11:22:58 +08:00
手机端使用codemirror
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Modal, message, Input, Form } from 'antd';
|
||||
import { request } from '@/utils/http';
|
||||
import config from '@/utils/config';
|
||||
|
||||
const SettingModal = ({
|
||||
file,
|
||||
handleCancel,
|
||||
visible,
|
||||
}: {
|
||||
file?: any;
|
||||
visible: boolean;
|
||||
handleCancel: (cks?: any[]) => void;
|
||||
}) => {
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleOk = async (values: any) => {
|
||||
console.log(file.filename);
|
||||
setLoading(true);
|
||||
const payload = { ...file, ...values };
|
||||
request
|
||||
.post(`${config.apiPrefix}scripts`, {
|
||||
data: payload,
|
||||
})
|
||||
.then(({ code, data }) => {
|
||||
if (code === 200) {
|
||||
message.success('保存文件成功');
|
||||
handleCancel(data);
|
||||
} else {
|
||||
message.error(data);
|
||||
}
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
form.resetFields();
|
||||
setLoading(false);
|
||||
}, [file, visible]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title="运行设置"
|
||||
visible={visible}
|
||||
forceRender
|
||||
onCancel={() => handleCancel()}
|
||||
>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
name="setting_modal"
|
||||
initialValues={file}
|
||||
>
|
||||
<Form.Item
|
||||
name="filename"
|
||||
label="待开发"
|
||||
rules={[{ required: true, message: '待开发' }]}
|
||||
>
|
||||
<Input placeholder="待开发" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingModal;
|
||||
Reference in New Issue
Block a user