mirror of
https://github.com/whyour/qinglong.git
synced 2026-11-08 14:29:29 +08:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bf814e562 |
@@ -508,6 +508,7 @@
|
|||||||
"脚本(只读)": "Scripts (read only)",
|
"脚本(只读)": "Scripts (read only)",
|
||||||
"自动删除任务": "Automatically Delete Tasks",
|
"自动删除任务": "Automatically Delete Tasks",
|
||||||
"自动拆分": "Auto Split",
|
"自动拆分": "Auto Split",
|
||||||
|
"自动换行": "Word wrap",
|
||||||
"自动添加任务": "Automatically Add Tasks",
|
"自动添加任务": "Automatically Add Tasks",
|
||||||
"自动生成": "Auto-generated",
|
"自动生成": "Auto-generated",
|
||||||
"自定义日志文件夹名称,用于区分不同任务的日志,留空则自动生成": "Custom log folder name to distinguish logs from different tasks. Leave blank to auto-generate",
|
"自定义日志文件夹名称,用于区分不同任务的日志,留空则自动生成": "Custom log folder name to distinguish logs from different tasks. Leave blank to auto-generate",
|
||||||
|
|||||||
@@ -508,6 +508,7 @@
|
|||||||
"脚本(只读)": "脚本(只读)",
|
"脚本(只读)": "脚本(只读)",
|
||||||
"自动删除任务": "自动删除任务",
|
"自动删除任务": "自动删除任务",
|
||||||
"自动拆分": "自动拆分",
|
"自动拆分": "自动拆分",
|
||||||
|
"自动换行": "自动换行",
|
||||||
"自动添加任务": "自动添加任务",
|
"自动添加任务": "自动添加任务",
|
||||||
"自动生成": "自动生成",
|
"自动生成": "自动生成",
|
||||||
"自定义日志文件夹名称,用于区分不同任务的日志,留空则自动生成": "自定义日志文件夹名称,用于区分不同任务的日志,留空则自动生成",
|
"自定义日志文件夹名称,用于区分不同任务的日志,留空则自动生成": "自定义日志文件夹名称,用于区分不同任务的日志,留空则自动生成",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import React, {
|
|||||||
useEffect,
|
useEffect,
|
||||||
useRef,
|
useRef,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { Button, message, Modal, TreeSelect } from 'antd';
|
import { Button, message, Modal, Space, Switch, TreeSelect } from 'antd';
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
import { PageContainer } from '@ant-design/pro-layout';
|
import { PageContainer } from '@ant-design/pro-layout';
|
||||||
import { request } from '@/utils/http';
|
import { request } from '@/utils/http';
|
||||||
@@ -15,6 +15,7 @@ import CodeMirror from '@uiw/react-codemirror';
|
|||||||
import { useOutletContext } from '@umijs/max';
|
import { useOutletContext } from '@umijs/max';
|
||||||
import { SharedContext } from '@/layouts';
|
import { SharedContext } from '@/layouts';
|
||||||
import { langs } from '@uiw/codemirror-extensions-langs';
|
import { langs } from '@uiw/codemirror-extensions-langs';
|
||||||
|
import { EditorView } from '@codemirror/view';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
import { getEditorMode } from '@/utils';
|
import { getEditorMode } from '@/utils';
|
||||||
|
|
||||||
@@ -28,6 +29,11 @@ const Config = () => {
|
|||||||
const editorRef = useRef<any>(null);
|
const editorRef = useRef<any>(null);
|
||||||
const [confirmLoading, setConfirmLoading] = useState(false);
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
||||||
const [language, setLanguage] = useState<string>('shell');
|
const [language, setLanguage] = useState<string>('shell');
|
||||||
|
const [wordWrap, setWordWrap] = useState(
|
||||||
|
() =>
|
||||||
|
(localStorage.getItem('qinglong_editor_word_wrap') ??
|
||||||
|
localStorage.getItem('qinglong_config_word_wrap')) === 'true',
|
||||||
|
);
|
||||||
|
|
||||||
const getConfig = (name: string) => {
|
const getConfig = (name: string) => {
|
||||||
request
|
request
|
||||||
@@ -104,6 +110,20 @@ const Config = () => {
|
|||||||
defaultValue="config.sh"
|
defaultValue="config.sh"
|
||||||
onSelect={onSelect}
|
onSelect={onSelect}
|
||||||
/>,
|
/>,
|
||||||
|
<Space key="word-wrap" size={8}>
|
||||||
|
<span>{intl.get('自动换行')}</span>
|
||||||
|
<Switch
|
||||||
|
aria-label={intl.get('自动换行')}
|
||||||
|
checked={wordWrap}
|
||||||
|
onChange={(checked) => {
|
||||||
|
setWordWrap(checked);
|
||||||
|
localStorage.setItem(
|
||||||
|
'qinglong_editor_word_wrap',
|
||||||
|
String(checked),
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Space>,
|
||||||
<Button
|
<Button
|
||||||
key="1"
|
key="1"
|
||||||
loading={confirmLoading}
|
loading={confirmLoading}
|
||||||
@@ -121,7 +141,10 @@ const Config = () => {
|
|||||||
<CodeMirror
|
<CodeMirror
|
||||||
value={value}
|
value={value}
|
||||||
theme={theme.includes('dark') ? 'dark' : 'light'}
|
theme={theme.includes('dark') ? 'dark' : 'light'}
|
||||||
extensions={[langs.shell()]}
|
extensions={[
|
||||||
|
langs.shell(),
|
||||||
|
...(wordWrap ? [EditorView.lineWrapping] : []),
|
||||||
|
]}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
setValue(value);
|
setValue(value);
|
||||||
}}
|
}}
|
||||||
@@ -136,7 +159,8 @@ const Config = () => {
|
|||||||
lineNumbersMinChars: 3,
|
lineNumbersMinChars: 3,
|
||||||
folding: false,
|
folding: false,
|
||||||
glyphMargin: false,
|
glyphMargin: false,
|
||||||
accessibilitySupport: 'off'
|
accessibilitySupport: 'off',
|
||||||
|
wordWrap: wordWrap ? 'on' : 'off',
|
||||||
}}
|
}}
|
||||||
onMount={(editor) => {
|
onMount={(editor) => {
|
||||||
editorRef.current = editor;
|
editorRef.current = editor;
|
||||||
|
|||||||
@@ -6,7 +6,16 @@ import React, {
|
|||||||
useCallback,
|
useCallback,
|
||||||
useReducer,
|
useReducer,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { Drawer, Button, Tabs, Badge, Select, TreeSelect } from 'antd';
|
import {
|
||||||
|
Drawer,
|
||||||
|
Button,
|
||||||
|
Tabs,
|
||||||
|
Badge,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Switch,
|
||||||
|
TreeSelect,
|
||||||
|
} from 'antd';
|
||||||
import { request } from '@/utils/http';
|
import { request } from '@/utils/http';
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
import SplitPane from 'react-split-pane';
|
import SplitPane from 'react-split-pane';
|
||||||
@@ -24,11 +33,15 @@ const EditModal = ({
|
|||||||
treeData,
|
treeData,
|
||||||
currentNode,
|
currentNode,
|
||||||
content,
|
content,
|
||||||
|
wordWrap,
|
||||||
|
onWordWrapChange,
|
||||||
handleCancel,
|
handleCancel,
|
||||||
}: {
|
}: {
|
||||||
treeData?: any;
|
treeData?: any;
|
||||||
content?: string;
|
content?: string;
|
||||||
currentNode: any;
|
currentNode: any;
|
||||||
|
wordWrap: boolean;
|
||||||
|
onWordWrapChange: (checked: boolean) => void;
|
||||||
handleCancel: () => void;
|
handleCancel: () => void;
|
||||||
}) => {
|
}) => {
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState('');
|
||||||
@@ -219,6 +232,16 @@ const EditModal = ({
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
width={'100%'}
|
width={'100%'}
|
||||||
|
extra={
|
||||||
|
<Space size={8}>
|
||||||
|
<span>{intl.get('自动换行')}</span>
|
||||||
|
<Switch
|
||||||
|
aria-label={intl.get('自动换行')}
|
||||||
|
checked={wordWrap}
|
||||||
|
onChange={onWordWrapChange}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
headerStyle={{ padding: '11px 24px' }}
|
headerStyle={{ padding: '11px 24px' }}
|
||||||
onClose={cancel}
|
onClose={cancel}
|
||||||
open={true}
|
open={true}
|
||||||
@@ -241,6 +264,7 @@ const EditModal = ({
|
|||||||
lineNumbersMinChars: 3,
|
lineNumbersMinChars: 3,
|
||||||
glyphMargin: false,
|
glyphMargin: false,
|
||||||
accessibilitySupport: 'off',
|
accessibilitySupport: 'off',
|
||||||
|
wordWrap: wordWrap ? 'on' : 'off',
|
||||||
}}
|
}}
|
||||||
onMount={(editor) => {
|
onMount={(editor) => {
|
||||||
editorRef.current = editor;
|
editorRef.current = editor;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
PlusOutlined,
|
PlusOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { PageContainer } from '@ant-design/pro-layout';
|
import { PageContainer } from '@ant-design/pro-layout';
|
||||||
|
import { EditorView } from '@codemirror/view';
|
||||||
import Editor from '@monaco-editor/react';
|
import Editor from '@monaco-editor/react';
|
||||||
import CodeMirror from '@uiw/react-codemirror';
|
import CodeMirror from '@uiw/react-codemirror';
|
||||||
import { history, useOutletContext } from '@umijs/max';
|
import { history, useOutletContext } from '@umijs/max';
|
||||||
@@ -26,6 +27,8 @@ import {
|
|||||||
MenuProps,
|
MenuProps,
|
||||||
message,
|
message,
|
||||||
Modal,
|
Modal,
|
||||||
|
Space,
|
||||||
|
Switch,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Tree,
|
Tree,
|
||||||
TreeSelect,
|
TreeSelect,
|
||||||
@@ -70,6 +73,11 @@ const Script = () => {
|
|||||||
const [showMonaco, setShowMonaco] = useState(true);
|
const [showMonaco, setShowMonaco] = useState(true);
|
||||||
const [historyVisible, setHistoryVisible] = useState(false);
|
const [historyVisible, setHistoryVisible] = useState(false);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
|
const [wordWrap, setWordWrap] = useState(
|
||||||
|
() =>
|
||||||
|
(localStorage.getItem('qinglong_editor_word_wrap') ??
|
||||||
|
localStorage.getItem('qinglong_config_word_wrap')) === 'true',
|
||||||
|
);
|
||||||
const savingRef = useRef(false);
|
const savingRef = useRef(false);
|
||||||
const savedContentRef = useRef('');
|
const savedContentRef = useRef('');
|
||||||
const currentKeyRef = useRef(currentNode?.key);
|
const currentKeyRef = useRef(currentNode?.key);
|
||||||
@@ -544,6 +552,11 @@ const Script = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const changeWordWrap = (checked: boolean) => {
|
||||||
|
setWordWrap(checked);
|
||||||
|
localStorage.setItem('qinglong_editor_word_wrap', String(checked));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer
|
<PageContainer
|
||||||
className="ql-container-wrapper log-wrapper"
|
className="ql-container-wrapper log-wrapper"
|
||||||
@@ -567,6 +580,14 @@ const Script = () => {
|
|||||||
}
|
}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
extra={[
|
extra={[
|
||||||
|
<Space key="word-wrap" size={8}>
|
||||||
|
<span>{intl.get('自动换行')}</span>
|
||||||
|
<Switch
|
||||||
|
aria-label={intl.get('自动换行')}
|
||||||
|
checked={wordWrap}
|
||||||
|
onChange={changeWordWrap}
|
||||||
|
/>
|
||||||
|
</Space>,
|
||||||
...(currentNode?.type === 'file' && showMonaco
|
...(currentNode?.type === 'file' && showMonaco
|
||||||
? [
|
? [
|
||||||
<Button
|
<Button
|
||||||
@@ -734,6 +755,7 @@ const Script = () => {
|
|||||||
lineNumbersMinChars: 3,
|
lineNumbersMinChars: 3,
|
||||||
glyphMargin: false,
|
glyphMargin: false,
|
||||||
accessibilitySupport: 'off',
|
accessibilitySupport: 'off',
|
||||||
|
wordWrap: wordWrap ? 'on' : 'off',
|
||||||
}}
|
}}
|
||||||
onMount={(editor) => {
|
onMount={(editor) => {
|
||||||
editorRef.current = editor;
|
editorRef.current = editor;
|
||||||
@@ -747,7 +769,10 @@ const Script = () => {
|
|||||||
{isPhone && (
|
{isPhone && (
|
||||||
<CodeMirror
|
<CodeMirror
|
||||||
value={value}
|
value={value}
|
||||||
extensions={getCodeMirrorExtensions(mode)}
|
extensions={[
|
||||||
|
...getCodeMirrorExtensions(mode),
|
||||||
|
...(wordWrap ? [EditorView.lineWrapping] : []),
|
||||||
|
]}
|
||||||
theme={theme.includes('dark') ? 'dark' : 'light'}
|
theme={theme.includes('dark') ? 'dark' : 'light'}
|
||||||
readOnly={!isEditing || saving}
|
readOnly={!isEditing || saving}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
@@ -760,6 +785,8 @@ const Script = () => {
|
|||||||
treeData={data}
|
treeData={data}
|
||||||
currentNode={currentNode}
|
currentNode={currentNode}
|
||||||
content={value}
|
content={value}
|
||||||
|
wordWrap={wordWrap}
|
||||||
|
onWordWrapChange={changeWordWrap}
|
||||||
handleCancel={() => {
|
handleCancel={() => {
|
||||||
setIsLogModalVisible(false);
|
setIsLogModalVisible(false);
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user