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