diff --git a/.helloagents/CHANGELOG.md b/.helloagents/CHANGELOG.md index 0c9eb48..6d0e719 100644 --- a/.helloagents/CHANGELOG.md +++ b/.helloagents/CHANGELOG.md @@ -38,6 +38,9 @@ - 方案: [202603250614_terminal-ansi-color-effects](archive/2026-03/202603250614_terminal-ansi-color-effects/) ### 快速修改 +- **[frontend]**: 将“添加新连接”弹窗的脚本模式开关上移到基本信息之前,并在脚本导入时自动忽略空格、空行与 Markdown 代码围栏行 — by yinjianm + - 类型: 快速修改(无方案包) + - 文件: packages/frontend/src/components/AddConnectionForm.vue, packages/frontend/src/composables/useAddConnectionForm.ts - **[workspace-root]**: 将双语 README 的仓库、发布与下载链接统一切到 `Micah123321/nexus-terminal`,移除 Ko-fi,并补充源项目指向 — by yinjianm - 类型: 快速修改(无方案包) - 文件: README.md, doc/README_EN.md diff --git a/packages/frontend/src/components/AddConnectionForm.vue b/packages/frontend/src/components/AddConnectionForm.vue index 51938d1..af3bb7a 100644 --- a/packages/frontend/src/components/AddConnectionForm.vue +++ b/packages/frontend/src/components/AddConnectionForm.vue @@ -104,6 +104,44 @@ const handleHostIconMouseLeave = () => {

{{ formTitle }}

+ +
+
+

{{ t('connections.form.sectionScriptMode', '脚本模式') }}

+ +
+
+ +

+ {{ scriptModeFormatInfo }} +

+
+
+ - - -
-
-

{{ t('connections.form.sectionScriptMode', '脚本模式') }}

- -
-
- -

- {{ scriptModeFormatInfo }} -

-
-
diff --git a/packages/frontend/src/composables/useAddConnectionForm.ts b/packages/frontend/src/composables/useAddConnectionForm.ts index c4b4bf2..9b458fc 100644 --- a/packages/frontend/src/composables/useAddConnectionForm.ts +++ b/packages/frontend/src/composables/useAddConnectionForm.ts @@ -286,9 +286,9 @@ export function useAddConnectionForm(props: AddConnectionFormProps, emit: AddCon } // 1. Extract user@host:port - const firstSpaceIndex = line.indexOf(' '); - const userHostPortPart = firstSpaceIndex === -1 ? line : line.substring(0, firstSpaceIndex); - const optionsString = firstSpaceIndex === -1 ? '' : line.substring(firstSpaceIndex + 1).trim(); + const firstWhitespaceIndex = line.search(/\s/); + const userHostPortPart = firstWhitespaceIndex === -1 ? line : line.substring(0, firstWhitespaceIndex); + const optionsString = firstWhitespaceIndex === -1 ? '' : line.substring(firstWhitespaceIndex).trim(); // 2. Validate user@host:port (allow user@host without port) const userHostPortRegex = /^([^@\s]+)@([^:\s]+)(?::([0-9]+))?$/; @@ -398,9 +398,24 @@ export function useAddConnectionForm(props: AddConnectionFormProps, emit: AddCon return { type, userHostPort: userHostPortPart, name, password, keyName, proxyName, tags, note }; }; + const normalizeScriptModeInput = (rawInput: string): { cleanedText: string; lines: string[] } => { + const lines = rawInput + .replace(/\r\n?/g, '\n') + .split('\n') + .map((line) => line.trim()) + .filter((line) => line.length > 0 && !line.startsWith('```')); + + return { + cleanedText: lines.join('\n'), + lines, + }; + }; + // 处理表单提交 const handleScriptModeSubmit = async () => { - const lines = scriptInputText.value.split('\n').filter(line => line.trim() !== ''); + const normalizedScriptInput = normalizeScriptModeInput(scriptInputText.value); + const lines = normalizedScriptInput.lines; + scriptInputText.value = normalizedScriptInput.cleanedText; if (lines.length === 0) { uiNotificationsStore.showError(t('connections.form.scriptModeEmpty', '脚本输入不能为空。'));