refactor(task-preset): 移除左栏,预设切换并入主区标题下拉框

Made-with: Cursor
This commit is contained in:
Youzini-afk
2026-04-07 19:03:57 +08:00
parent dd4eff4fc9
commit 9c6c4698cf
2 changed files with 50 additions and 101 deletions

View File

@@ -3068,16 +3068,6 @@ function _handleTaskProfileWorkspaceInput(event) {
const target = event.target;
if (!(target instanceof HTMLElement)) return;
if (target.id === "bme-task-profile-name") {
_updateCurrentTaskProfile(
(draft) => {
draft.name = String(target.value || "").trim() || draft.name;
},
{ refresh: false },
);
return;
}
if (target.matches("[data-block-field]")) {
_persistSelectedBlockField(target, false);
return;
@@ -3556,14 +3546,16 @@ async function _handleTaskProfileWorkspaceClick(event) {
toastr.success("当前预设已保存", "ST-BME");
return;
case "rename-profile": {
const nameInput = document.getElementById("bme-task-profile-name");
const nextName = String(nameInput?.value || "").trim();
if (!nextName) {
const current = String(selectedProfile?.name || "").trim();
const nextName = window.prompt("请输入预设名称", current);
if (nextName == null) return;
const trimmed = String(nextName).trim();
if (!trimmed) {
toastr.info("预设名称不能为空", "ST-BME");
return;
}
_updateCurrentTaskProfile((draft) => {
draft.name = nextName;
draft.name = trimmed;
});
toastr.success("预设名称已更新", "ST-BME");
return;
@@ -3712,13 +3704,15 @@ function _renderTaskProfileWorkspace(state) {
</div>
<div class="bme-task-master-detail">
<div class="bme-task-profile-nav" aria-label="任务预设切换">
<div class="bme-task-profile-nav-kicker">${_escHtml(taskMeta?.label || state.taskType)}</div>
<label class="bme-task-profile-nav-label" for="bme-task-profile-select">当前预设</label>
<select id="bme-task-profile-select" class="bme-config-input bme-task-profile-nav-select">
${state.bucket.profiles
.map(
(profile) => `
<div class="bme-task-profile-editor">
<div class="bme-task-editor-header">
<div class="bme-task-editor-kicker">${_escHtml(taskMeta?.label || state.taskType)}</div>
<div class="bme-task-editor-title-row">
<label class="bme-visually-hidden" for="bme-task-profile-select">当前预设</label>
<select id="bme-task-profile-select" class="bme-config-input bme-task-editor-preset-select" title="切换预设">
${state.bucket.profiles
.map(
(profile) => `
<option
value="${_escAttr(profile.id)}"
${profile.id === state.profile.id ? "selected" : ""}
@@ -3726,21 +3720,9 @@ function _renderTaskProfileWorkspace(state) {
${_escHtml(profile.name)}${profile.builtin ? "(内置)" : ""}
</option>
`,
)
.join("")}
</select>
</div>
<div class="bme-task-profile-editor">
<div class="bme-task-editor-header">
<div class="bme-task-editor-title-row">
<input
id="bme-task-profile-name"
class="bme-task-editor-name-input"
type="text"
value="${_escAttr(state.profile.name || "")}"
placeholder="输入预设名称"
/>
)
.join("")}
</select>
<div class="bme-task-profile-badges">
<span class="bme-task-pill ${state.profile.builtin ? "is-builtin" : ""}">
${state.profile.builtin ? "内置" : "自定义"}

View File

@@ -1312,7 +1312,7 @@
#st-bme-panel input.bme-search-input,
#st-bme-panel .bme-node-detail-input,
#st-bme-panel .bme-node-detail-textarea,
#st-bme-panel .bme-task-editor-name-input {
#st-bme-panel .bme-task-editor-preset-select {
background-color: var(--bme-surface-high) !important;
color: var(--bme-on-surface) !important;
}
@@ -1916,41 +1916,38 @@
background: var(--bme-surface-container);
}
/* 左栏:紧凑「任务 + 下拉」切换预设,避免大块列表卡片占宽 */
.bme-task-profile-nav {
width: 168px;
flex-shrink: 0;
border-right: 1px solid var(--bme-border);
display: flex;
flex-direction: column;
gap: 6px;
padding: 10px 10px 12px;
background: var(--bme-surface);
.bme-visually-hidden {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
.bme-task-profile-nav-kicker {
.bme-task-editor-kicker {
font-size: 10px;
font-weight: 700;
letter-spacing: 0.04em;
text-transform: uppercase;
color: var(--bme-on-surface-dim);
line-height: 1.2;
word-break: break-all;
}
.bme-task-profile-nav-label {
font-size: 11px;
.bme-task-editor-preset-select {
flex: 1;
min-width: 200px;
min-height: 40px;
font-size: 16px;
font-weight: 600;
color: var(--bme-on-surface-dim);
margin: 2px 0 0;
}
.bme-task-profile-nav-select {
width: 100%;
min-height: 32px;
font-size: 12px;
padding: 4px 28px 4px 8px;
padding: 6px 32px 6px 12px;
line-height: 1.35;
border-radius: 8px;
border: 1px solid var(--bme-border);
cursor: pointer;
}
.bme-task-profile-editor {
@@ -1976,28 +1973,10 @@
flex-wrap: wrap;
}
.bme-task-editor-name-input {
flex: 1;
min-width: 200px;
font-size: 16px;
font-weight: 600;
padding: 6px 10px;
border-radius: 8px;
border: 1px solid transparent;
background: transparent;
color: var(--bme-on-surface);
transition: border-color 0.15s, background 0.15s;
}
.bme-task-editor-name-input:hover {
border-color: var(--bme-border);
background: var(--bme-surface-high);
}
.bme-task-editor-name-input:focus {
outline: none;
.bme-task-editor-preset-select:hover,
.bme-task-editor-preset-select:focus {
border-color: var(--bme-primary);
background: var(--bme-surface-high);
outline: none;
}
.bme-task-editor-actions {
@@ -4064,31 +4043,19 @@
min-height: auto;
}
.bme-task-profile-nav {
.bme-task-editor-preset-select {
min-width: 0;
width: 100%;
border-right: none;
border-bottom: 1px solid var(--bme-border);
flex-direction: row;
flex-wrap: wrap;
align-items: flex-end;
gap: 8px 12px;
padding: 10px 12px;
flex: 1 1 100%;
}
.bme-task-profile-nav-kicker {
width: 100%;
flex-basis: 100%;
.bme-task-editor-title-row {
flex-direction: column;
align-items: stretch;
}
.bme-task-profile-nav-label {
flex: 0 0 auto;
margin: 0;
align-self: center;
}
.bme-task-profile-nav-select {
flex: 1;
min-width: 140px;
.bme-task-profile-badges {
justify-content: flex-start;
}
.bme-task-segmented-control {