fix: add word wrap to task detail script editor

This commit is contained in:
whyour committed 2026-11-22 15:21:37 +08:00
1 parent 188f8805cb
commit cddabbaf0e
2 files changed
+64 -20

No files matched your search

+47 -20
View File
@@ -13,6 +13,8 @@ import {
Divider,
Typography,
Tooltip,
Space,
Switch,
} from 'antd';
import {
ClockCircleOutlined,
@@ -69,6 +71,11 @@ const CronDetailModal = ({
}) => {
const [activeTabKey, setActiveTabKey] = useState('runningHistory');
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<
'loading' | 'ready' | 'failed'
>('loading');
@@ -156,6 +163,7 @@ const CronDetailModal = ({
lineNumbersMinChars: 3,
glyphMargin: false,
accessibilitySupport: 'off',
wordWrap: wordWrap ? 'on' : 'off',
}}
onMount={(editor, monaco) => {
editorRef.current = editor;
@@ -519,6 +527,34 @@ const CronDetailModal = ({
}
}, [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 (
<Modal
title={
@@ -731,27 +767,18 @@ const CronDetailModal = ({
onTabChange={(key) => {
onTabChange(key);
}}
tabBarExtraContent={
activeTabKey === 'script' &&
scriptState === 'ready' && (
<>
<Button
type="primary"
style={{ marginRight: 8 }}
onClick={saveFile}
>
{intl.get('保存')}
</Button>
<Button
type="primary"
icon={<FullscreenOutlined />}
onClick={fullscreen}
/>
</>
)
}
tabBarExtraContent={!isPhone && scriptActions}
>
{contentList[activeTabKey]}
{isPhone && scriptActions ? (
<div className="cron-detail-script-panel">
<div className="cron-detail-script-actions">{scriptActions}</div>
<div className="cron-detail-script-editor">
{contentList[activeTabKey]}
</div>
</div>
) : (
contentList[activeTabKey]
)}
</Card>
</div>
{isLogModalVisible && (
+17
View File
@@ -5,6 +5,23 @@
}
.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 {
.ant-card:last-child {
.ant-card-body {