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