mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 09:45:36 +08:00
fix: add word wrap to task detail script editor
This commit is contained in:
1 parent
188f8805cb
commit
cddabbaf0e
2 files changed
+63
-19
No files matched your search
@@ -13,6 +13,8 @@ import {
|
|||||||
Divider,
|
Divider,
|
||||||
Typography,
|
Typography,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
|
Space,
|
||||||
|
Switch,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import {
|
import {
|
||||||
ClockCircleOutlined,
|
ClockCircleOutlined,
|
||||||
@@ -69,6 +71,11 @@ const CronDetailModal = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [activeTabKey, setActiveTabKey] = useState('runningHistory');
|
const [activeTabKey, setActiveTabKey] = useState('runningHistory');
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState('');
|
||||||
|
const [wordWrap, setWordWrap] = useState(
|
||||||
|
() =>
|
||||||
|
(localStorage.getItem('qinglong_editor_word_wrap') ??
|
||||||
|
localStorage.getItem('qinglong_config_word_wrap')) === 'true',
|
||||||
|
);
|
||||||
const [scriptState, setScriptState] = useState<
|
const [scriptState, setScriptState] = useState<
|
||||||
'loading' | 'ready' | 'failed'
|
'loading' | 'ready' | 'failed'
|
||||||
>('loading');
|
>('loading');
|
||||||
@@ -156,6 +163,7 @@ const CronDetailModal = ({
|
|||||||
lineNumbersMinChars: 3,
|
lineNumbersMinChars: 3,
|
||||||
glyphMargin: false,
|
glyphMargin: false,
|
||||||
accessibilitySupport: 'off',
|
accessibilitySupport: 'off',
|
||||||
|
wordWrap: wordWrap ? 'on' : 'off',
|
||||||
}}
|
}}
|
||||||
onMount={(editor, monaco) => {
|
onMount={(editor, monaco) => {
|
||||||
editorRef.current = editor;
|
editorRef.current = editor;
|
||||||
@@ -519,6 +527,34 @@ const CronDetailModal = ({
|
|||||||
}
|
}
|
||||||
}, [cron]);
|
}, [cron]);
|
||||||
|
|
||||||
|
const scriptActions = activeTabKey === 'script' &&
|
||||||
|
scriptState === 'ready' && (
|
||||||
|
<Space size={8} wrap>
|
||||||
|
<Space size={8} className="editor-wrap-setting">
|
||||||
|
<span className="editor-wrap-label">{intl.get('自动换行')}</span>
|
||||||
|
<Switch
|
||||||
|
aria-label={intl.get('自动换行')}
|
||||||
|
checked={wordWrap}
|
||||||
|
onChange={(checked) => {
|
||||||
|
setWordWrap(checked);
|
||||||
|
localStorage.setItem(
|
||||||
|
'qinglong_editor_word_wrap',
|
||||||
|
String(checked),
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
<Button type="primary" onClick={saveFile}>
|
||||||
|
{intl.get('保存')}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
icon={<FullscreenOutlined />}
|
||||||
|
onClick={fullscreen}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={
|
title={
|
||||||
@@ -731,27 +767,18 @@ const CronDetailModal = ({
|
|||||||
onTabChange={(key) => {
|
onTabChange={(key) => {
|
||||||
onTabChange(key);
|
onTabChange(key);
|
||||||
}}
|
}}
|
||||||
tabBarExtraContent={
|
tabBarExtraContent={!isPhone && scriptActions}
|
||||||
activeTabKey === 'script' &&
|
|
||||||
scriptState === 'ready' && (
|
|
||||||
<>
|
|
||||||
<Button
|
|
||||||
type="primary"
|
|
||||||
style={{ marginRight: 8 }}
|
|
||||||
onClick={saveFile}
|
|
||||||
>
|
|
||||||
{intl.get('保存')}
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
type="primary"
|
|
||||||
icon={<FullscreenOutlined />}
|
|
||||||
onClick={fullscreen}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
|
{isPhone && scriptActions ? (
|
||||||
|
<div className="cron-detail-script-panel">
|
||||||
|
<div className="cron-detail-script-actions">{scriptActions}</div>
|
||||||
|
<div className="cron-detail-script-editor">
|
||||||
{contentList[activeTabKey]}
|
{contentList[activeTabKey]}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
contentList[activeTabKey]
|
||||||
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
{isLogModalVisible && (
|
{isLogModalVisible && (
|
||||||
|
|||||||
@@ -5,6 +5,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.crontab-detail {
|
.crontab-detail {
|
||||||
|
.cron-detail-script-panel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cron-detail-script-actions {
|
||||||
|
display: flex;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
justify-content: flex-end;
|
||||||
|
padding-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cron-detail-script-editor {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.card-wrapper {
|
.card-wrapper {
|
||||||
.ant-card:last-child {
|
.ant-card:last-child {
|
||||||
.ant-card-body {
|
.ant-card-body {
|
||||||
|
|||||||
Reference in new issue
Block a user