style(frontend): 精简脚本语言提示并移除解释器输入框

- 脚本语言提示从大块灰色卡片改成下拉框右侧的一行说明
- Python 表单不再显示解释器输入框,固定使用 .venv 里的 Python
- 虚拟环境目录字段改为全宽并明确自动探测语义
- 非 Python 语言仍由语言自动设置 cmd.exe/node.exe/lua.exe,API 仍可传自定义 interpreter
This commit is contained in:
2026-11-04 22:51:37 +08:00
parent 917674880b
commit 10f8e6bb66
4 changed files with 66 additions and 73 deletions
+4 -3
View File
@@ -228,8 +228,9 @@ queued ──► running ──► succeeded / failed / timed_out / cancelled
- 没装 uv:必须手动准备虚拟环境;Python 任务缺少 `.venv` 时运行失败并给出提示。 - 没装 uv:必须手动准备虚拟环境;Python 任务缺少 `.venv` 时运行失败并给出提示。
- 既没有虚拟环境、也没有 pyproject/requirements:编辑器显示错误,Python 任务运行失败。 - 既没有虚拟环境、也没有 pyproject/requirements:编辑器显示错误,Python 任务运行失败。
Python 任务不再静默回退到系统解释器。 Python 任务不再静默回退到系统解释器。
- 解释器字段只对 Python 显示:留空会自动使用虚拟环境里的 `python.exe`; - 解释器由语言自动决定,界面不再显示解释器输入框:
选择 Shell / Node / Lua 时不需要手填解释器,分别固定使用 `cmd.exe` / `node.exe` / `lua.exe`。 Python 始终使用虚拟环境里的 Python,Shell 使用 `cmd.exe`,Node 使用 `node.exe`,Lua 使用 `lua.exe`。
自定义解释器仍可通过 API 的 `action.interpreter` 字段传入。
命中虚拟环境后注入: 命中虚拟环境后注入:
@@ -253,7 +254,7 @@ queued ──► running ──► succeeded / failed / timed_out / cancelled
- **编辑器**:先选任务类型(脚本 / HTTP / 二进制),脚本类型再选语言(Python / Shell / Node / Lua), - **编辑器**:先选任务类型(脚本 / HTTP / 二进制),脚本类型再选语言(Python / Shell / Node / Lua),
非 Python 语言会自动隐藏虚拟环境字段并调整脚本占位符;Cron 预览(实时计算未来 3/5/8/10 次)、 非 Python 语言会自动隐藏虚拟环境字段并调整脚本占位符;Cron 预览(实时计算未来 3/5/8/10 次)、
时区下拉、虚拟环境状态条、调用预览;探测到虚拟环境会自动回填「虚拟环境目录」,仍可手动修改; 时区下拉、虚拟环境状态条、调用预览;探测到虚拟环境会自动回填「虚拟环境目录」,仍可手动修改;
缺少虚拟环境但项目有依赖文件时可直接用 uv 创建。解释器字段只在 Python 下显示,留空自动使用虚拟环境 Python。 缺少虚拟环境但项目有依赖文件时可直接用 uv 创建。解释器由语言自动选择,界面不再要求手填。
- **目录选择**:页面内目录浏览器(盘符 → 逐级进入 → 使用此目录),同时保留手动输入。 - **目录选择**:页面内目录浏览器(盘符 → 逐级进入 → 使用此目录),同时保留手动输入。
- **日志弹窗**:运行历史筛选、SSE 实时日志、取消运行、下载日志、Escape/焦点陷阱。 - **日志弹窗**:运行历史筛选、SSE 实时日志、取消运行、下载日志、Escape/焦点陷阱。
- **Python 镜像**:内置清华 TUNA / 阿里云 / 中科大 / PyPI 官方;可新增、编辑、启用停用、设为默认。 - **Python 镜像**:内置清华 TUNA / 阿里云 / 中科大 / PyPI 官方;可新增、编辑、启用停用、设为默认。
+25 -18
View File
@@ -292,23 +292,21 @@
gap: 16px; gap: 16px;
} }
/* 虚拟环境目录通常是一条完整路径,给它更多宽度;解释器名很短 */ .script-language-row {
.venv-grid {
grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.9fr);
}
.language-grid {
align-items: start;
}
.language-hint {
display: flex; display: flex;
min-height: 36px; align-items: flex-end;
align-items: center; gap: 16px;
border: 1px solid var(--su-border); }
border-radius: var(--su-radius-md);
padding: 8px 12px; .script-language-field {
background-color: var(--su-bg-subtle); min-width: 0;
flex: 0 0 260px;
}
.script-language-hint {
min-width: 0;
flex: 1;
padding-bottom: 10px;
} }
.form-select { .form-select {
@@ -1118,8 +1116,17 @@
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
.venv-grid { .script-language-row {
grid-template-columns: 1fr; align-items: stretch;
flex-direction: column;
}
.script-language-field {
flex: none;
}
.script-language-hint {
padding-bottom: 0;
} }
.cron-run-grid { .cron-run-grid {
+7 -22
View File
@@ -526,7 +526,8 @@ export function TaskEditorModal({
</div> </div>
{actionType === 'script' ? ( {actionType === 'script' ? (
<div className="form-grid language-grid"> <div className="script-language-row">
<div className="script-language-field">
<FormField label="脚本语言"> <FormField label="脚本语言">
<Controller <Controller
control={control} control={control}
@@ -543,12 +544,11 @@ export function TaskEditorModal({
)} )}
/> />
</FormField> </FormField>
<div className="language-hint"> </div>
<Text size="sm" tone="sub"> <Text className="script-language-hint" size="sm" tone="sub">
{scriptMeta.hint} {scriptMeta.hint}
</Text> </Text>
</div> </div>
</div>
) : null} ) : null}
{actionType === 'script' ? ( {actionType === 'script' ? (
@@ -580,34 +580,19 @@ export function TaskEditorModal({
{isPythonScript ? ( {isPythonScript ? (
<> <>
<div className="form-grid venv-grid">
<FormField <FormField
label="虚拟环境目录 (可选)" label="虚拟环境目录"
htmlFor="task-venv" htmlFor="task-venv"
hint="检测到虚拟环境会自动填入,可直接修改;留空则按工作目录自动探测" hint="自动探测项目里的 .venv;需要时也可以手动指定。Python 任务始终使用 .venv 里的 Python"
error={errors.script?.venv?.message} error={errors.script?.venv?.message}
> >
<Input <Input
id="task-venv" id="task-venv"
{...register('script.venv')} {...register('script.venv')}
className="mono-input" className="mono-input"
placeholder="例如:.venv" placeholder="留空自动探测,例如 .venv"
/> />
</FormField> </FormField>
<FormField
label="解释器(可选)"
htmlFor="task-interpreter"
hint="留空自动使用虚拟环境 Python;也可以填自定义 Python 路径"
error={errors.script?.interpreter?.message}
>
<Input
id="task-interpreter"
{...register('script.interpreter')}
className="mono-input"
placeholder="留空自动使用虚拟环境 Python"
/>
</FormField>
</div>
<VenvDetectorBar <VenvDetectorBar
workingDir={debouncedWorkingDir} workingDir={debouncedWorkingDir}
+3 -3
View File
@@ -31,7 +31,7 @@ export const SCRIPT_LANGUAGE_META: Record<
defaultScript: 'main.py', defaultScript: 'main.py',
scriptLabel: '脚本文件或相对路径', scriptLabel: '脚本文件或相对路径',
scriptPlaceholder: 'main.py 或 scripts\\sync.py', scriptPlaceholder: 'main.py 或 scripts\\sync.py',
hint: '优先复用项目 .venv;没有环境时可用 uv 从 pyproject.toml / requirements.txt 创建,运行时会注入虚拟环境变量。', hint: '自动使用项目 .venv;没有环境时可在下方用 uv 创建。',
}, },
shell: { shell: {
label: 'Shell (cmd)', label: 'Shell (cmd)',
@@ -47,7 +47,7 @@ export const SCRIPT_LANGUAGE_META: Record<
defaultScript: 'index.js', defaultScript: 'index.js',
scriptLabel: 'JavaScript 文件或相对路径', scriptLabel: 'JavaScript 文件或相对路径',
scriptPlaceholder: 'index.js 或 scripts\\worker.js', scriptPlaceholder: 'index.js 或 scripts\\worker.js',
hint: '通过 node.exe 执行脚本,不需要虚拟环境;需要本机 PATH 中已安装 Node.js。', hint: '通过 node.exe 执行,不需要虚拟环境;需已安装 Node.js。',
}, },
lua: { lua: {
label: 'Lua', label: 'Lua',
@@ -55,7 +55,7 @@ export const SCRIPT_LANGUAGE_META: Record<
defaultScript: 'main.lua', defaultScript: 'main.lua',
scriptLabel: 'Lua 文件或相对路径', scriptLabel: 'Lua 文件或相对路径',
scriptPlaceholder: 'main.lua 或 scripts\\task.lua', scriptPlaceholder: 'main.lua 或 scripts\\task.lua',
hint: '通过 lua.exe 执行脚本,不需要虚拟环境;需要本机 PATH 中已安装 Lua。', hint: '通过 lua.exe 执行,不需要虚拟环境;需已安装 Lua。',
}, },
} }