From 278800c07765e73973b3ef71236d35ab08d014c4 Mon Sep 17 00:00:00 2001 From: DLmaster361 Date: Thu, 4 Sep 2025 15:53:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=95=B4=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=A2=9D=E5=A4=96=E8=84=9A=E6=9C=AC=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/GeneralUserEdit.vue | 233 +++++++++++++++++-------- 1 file changed, 165 insertions(+), 68 deletions(-) diff --git a/frontend/src/views/GeneralUserEdit.vue b/frontend/src/views/GeneralUserEdit.vue index 563195b..f0c52ab 100644 --- a/frontend/src/views/GeneralUserEdit.vue +++ b/frontend/src/views/GeneralUserEdit.vue @@ -135,84 +135,91 @@ - - - - - + + + + + - 启用后将在任务执行前运行指定脚本 - - - - - + + + + + + + 选择文件 + + + + + + + + + - 启用后将在任务执行后运行指定脚本 - - - - - - - - - - - - - - - - - - + + + + + + + 选择文件 + + + + + @@ -325,6 +332,7 @@ import { useRoute, useRouter } from 'vue-router' import { message } from 'ant-design-vue' import { ArrowLeftOutlined, + FileOutlined, QuestionCircleOutlined, SaveOutlined, SettingOutlined, @@ -590,6 +598,43 @@ const handleGeneralConfig = async () => { } } +// 文件选择方法 +const selectScriptBeforeTask = async () => { + try { + const path = await (window.electronAPI as any)?.selectFile([ + { name: '可执行文件', extensions: ['exe', 'bat', 'cmd', 'ps1'] }, + { name: '脚本文件', extensions: ['py', 'js', 'sh'] }, + { name: '所有文件', extensions: ['*'] }, + ]) + + if (path && path.length > 0) { + formData.Info.ScriptBeforeTask = path[0] + message.success('任务前脚本路径选择成功') + } + } catch (error) { + console.error('选择任务前脚本失败:', error) + message.error('选择文件失败') + } +} + +const selectScriptAfterTask = async () => { + try { + const path = await (window.electronAPI as any)?.selectFile([ + { name: '可执行文件', extensions: ['exe', 'bat', 'cmd', 'ps1'] }, + { name: '脚本文件', extensions: ['py', 'js', 'sh'] }, + { name: '所有文件', extensions: ['*'] }, + ]) + + if (path && path.length > 0) { + formData.Info.ScriptAfterTask = path[0] + message.success('任务后脚本路径选择成功') + } + } catch (error) { + console.error('选择任务后脚本失败:', error) + message.error('选择文件失败') + } +} + const handleCancel = () => { // 清理WebSocket连接 if (generalWebsocketId.value) { @@ -755,4 +800,56 @@ onMounted(() => { width: 60px; height: 60px; } + +/* 路径输入组样式 */ +.path-input-group { + display: flex; + border-radius: 8px; + overflow: hidden; + border: 2px solid var(--ant-color-border); + transition: all 0.3s ease; +} + +.path-input-group:hover { + border-color: var(--ant-color-primary-hover); +} + +.path-input-group:focus-within { + border-color: var(--ant-color-primary); + box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.1); +} + +.path-input { + flex: 1; + border: none !important; + border-radius: 0 !important; + background: var(--ant-color-bg-container) !important; +} + +.path-input:focus { + box-shadow: none !important; +} + +.path-button { + border: none; + border-radius: 0; + background: var(--ant-color-primary-bg); + color: var(--ant-color-primary); + font-weight: 600; + padding: 0 20px; + transition: all 0.3s ease; + border-left: 1px solid var(--ant-color-border-secondary); +} + +.path-button:hover { + background: var(--ant-color-primary); + color: white; + transform: none; +} + +.path-button:disabled { + background: var(--ant-color-bg-container-disabled); + color: var(--ant-color-text-disabled); + cursor: not-allowed; +} \ No newline at end of file