diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index b7dc85dcf..97610576c 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -763,6 +763,7 @@ const message = { downlodSuccess: 'Download Success', theme: 'Theme', language: 'Language', + eol: 'End Of Line', }, setting: { all: 'All', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index a9a149bea..9871f0851 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -767,6 +767,7 @@ const message = { downlodSuccess: '下载完成', theme: '主题', language: '语言', + eol: '行尾符', }, setting: { all: '全部', diff --git a/frontend/src/views/host/file-management/code-editor/index.vue b/frontend/src/views/host/file-management/code-editor/index.vue index 94d237aff..38ad1d33b 100644 --- a/frontend/src/views/host/file-management/code-editor/index.vue +++ b/frontend/src/views/host/file-management/code-editor/index.vue @@ -18,6 +18,11 @@ + + + + +
@@ -74,6 +79,7 @@ interface EditProps { interface EditorConfig { theme: string; language: string; + eol: number; } let open = ref(false); @@ -82,8 +88,20 @@ let loading = ref(false); let config = reactive({ theme: 'vs-dark', language: 'plaintext', + eol: monaco.editor.EndOfLineSequence.LF, }); +const eols = [ + { + label: 'LF', + value: monaco.editor.EndOfLineSequence.LF, + }, + { + label: 'CRLF', + value: monaco.editor.EndOfLineSequence.CRLF, + }, +]; + const themes = [ { label: 'Visual Studio', @@ -121,6 +139,10 @@ const changeTheme = () => { monaco.editor.setTheme(config.theme); }; +const changeEOL = () => { + editor.getModel().pushEOL(config.eol); +}; + const initEditor = () => { if (editor) { editor.dispose(); @@ -144,6 +166,9 @@ const initEditor = () => { } }); + // After onDidChangeModelContent + editor.getModel().pushEOL(config.eol); + editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, quickSave); }); }; @@ -165,6 +190,9 @@ const acceptParams = (props: EditProps) => { form.value.content = props.content; form.value.path = props.path; config.language = props.language; + // TODO Now,1panel only support liunux,so we can use LF. + // better,We should rely on the actual line feed character of the file returned from the background + config.eol = monaco.editor.EndOfLineSequence.LF; open.value = true; }; diff --git a/frontend/src/views/host/terminal/terminal/terminal.vue b/frontend/src/views/host/terminal/terminal/terminal.vue index 1e916e451..7be8f04cb 100644 --- a/frontend/src/views/host/terminal/terminal/terminal.vue +++ b/frontend/src/views/host/terminal/terminal/terminal.vue @@ -1,5 +1,5 @@