mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
修复文件为空无法保存
This commit is contained in:
parent
d8587b64a5
commit
9e4b41ce48
|
@ -59,7 +59,7 @@ export default (app: Router) => {
|
|||
celebrate({
|
||||
body: Joi.object({
|
||||
name: Joi.string().required(),
|
||||
content: Joi.string().required(),
|
||||
content: Joi.string().allow('').optional(),
|
||||
}),
|
||||
}),
|
||||
async (req: Request, res: Response, next: NextFunction) => {
|
||||
|
|
|
@ -179,9 +179,6 @@ const Log = () => {
|
|||
glyphMargin: false,
|
||||
wordWrap: 'on',
|
||||
}}
|
||||
onChange={(val, ev) => {
|
||||
setValue((val as string).replace(/\r\n/g, '\n'));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useEffect, useState, useRef } from 'react';
|
||||
import { Drawer, Button, Tabs, Badge, Select, TreeSelect } from 'antd';
|
||||
import { request } from '@/utils/http';
|
||||
import config from '@/utils/config';
|
||||
|
@ -44,6 +44,7 @@ const EditModal = ({
|
|||
const [isNewFile, setIsNewFile] = useState<boolean>(false);
|
||||
const [log, setLog] = useState<string>('');
|
||||
const { theme } = useTheme();
|
||||
const editorRef = useRef<any>(null);
|
||||
|
||||
const cancel = () => {
|
||||
handleCancel();
|
||||
|
@ -164,8 +165,8 @@ const EditModal = ({
|
|||
lineNumbersMinChars: 3,
|
||||
glyphMargin: false,
|
||||
}}
|
||||
onChange={(val) => {
|
||||
setValue((val as string).replace(/\r\n/g, '\n'));
|
||||
onMount={(editor) => {
|
||||
editorRef.current = editor;
|
||||
}}
|
||||
/>
|
||||
<div>
|
||||
|
@ -178,7 +179,7 @@ const EditModal = ({
|
|||
setSaveModalVisible(false);
|
||||
}}
|
||||
isNewFile={isNewFile}
|
||||
file={{ content: value, filename: fileName }}
|
||||
file={{ content: editorRef.current.getValue(1), filename: fileName }}
|
||||
/>
|
||||
<SettingModal
|
||||
visible={settingModalVisible}
|
||||
|
|
|
@ -167,9 +167,6 @@ const Script = () => {
|
|||
folding: false,
|
||||
glyphMargin: false,
|
||||
}}
|
||||
onChange={(val) => {
|
||||
setValue((val as string).replace(/\r\n/g, '\n'));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<EditModal
|
||||
|
|
Loading…
Reference in New Issue
Block a user