Merge pull request #15 from Youzini-afk/dev

Dev1
This commit is contained in:
youzini
2026-04-07 19:48:09 +08:00
committed by GitHub
3 changed files with 1427 additions and 1156 deletions

2045
panel.html

File diff suppressed because it is too large Load Diff

164
panel.js
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;
@@ -3683,8 +3675,8 @@ function _renderTaskProfileWorkspace(state) {
return `
<div class="bme-task-shell">
<div class="bme-task-header">
<div class="bme-task-type-tabs">
<div class="bme-task-action-bar">
<div class="bme-task-segmented-control">
${state.taskTypeOptions
.map(
(item) => `
@@ -3693,111 +3685,89 @@ function _renderTaskProfileWorkspace(state) {
data-task-action="switch-task-type"
data-task-type="${_escAttr(item.id)}"
type="button"
>
<span>${_escHtml(item.label)}</span>
</button>
>${_escHtml(item.label)}</button>
`,
)
.join("")}
<span style="flex:1"></span>
</div>
<div class="bme-task-action-bar-right">
<button class="bme-config-secondary-btn bme-bulk-profile-btn bme-task-btn-danger" data-task-action="restore-all-profiles" type="button" title="恢复全部 6 个任务的默认预设">
<i class="fa-solid fa-arrows-rotate" style="margin-right:4px"></i>恢复全部
<i class="fa-solid fa-arrows-rotate"></i><span>恢复全部</span>
</button>
<button class="bme-config-secondary-btn bme-bulk-profile-btn" data-task-action="export-all-profiles" type="button" title="导出全部 6 个任务预设">
<i class="fa-solid fa-file-export" style="margin-right:4px"></i>导出全部
<i class="fa-solid fa-file-export"></i><span>导出全部</span>
</button>
<button class="bme-config-secondary-btn bme-bulk-profile-btn" data-task-action="import-all-profiles" type="button" title="导入全部预设(覆盖当前)">
<i class="fa-solid fa-file-import" style="margin-right:4px"></i>导入全部
<i class="fa-solid fa-file-import"></i><span>导入全部</span>
</button>
</div>
</div>
<div class="bme-config-card bme-task-header-card">
<div class="bme-config-card-head">
<div>
<div class="bme-config-card-title">
${_escHtml(taskMeta?.label || state.taskType)} 任务预设
</div>
<div class="bme-config-card-subtitle">
${_escHtml(taskMeta?.description || "")}
</div>
</div>
<div class="bme-task-profile-badges">
<span class="bme-task-pill ${state.profile.builtin ? "is-builtin" : ""}">
${state.profile.builtin ? "内置" : "自定义"}
</span>
<span class="bme-task-pill">更新于 ${_escHtml(profileUpdatedAt)}</span>
</div>
</div>
<div class="bme-task-header-fields">
<div class="bme-config-row">
<label for="bme-task-profile-select">当前预设</label>
<select id="bme-task-profile-select" class="bme-config-input">
<div class="bme-task-master-detail">
<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" : ""}
>
${_escHtml(profile.name)}${profile.builtin ? " · 内置" : ""}
</option>
`,
<option
value="${_escAttr(profile.id)}"
${profile.id === state.profile.id ? "selected" : ""}
>
${_escHtml(profile.name)}${profile.builtin ? "内置" : ""}
</option>
`,
)
.join("")}
</select>
<div class="bme-task-profile-badges">
<span class="bme-task-pill ${state.profile.builtin ? "is-builtin" : ""}">
${state.profile.builtin ? "内置" : "自定义"}
</span>
<span class="bme-task-pill">更新于 ${_escHtml(profileUpdatedAt)}</span>
</div>
</div>
<div class="bme-config-row">
<label for="bme-task-profile-name">预设名称</label>
<input
id="bme-task-profile-name"
class="bme-config-input"
type="text"
value="${_escAttr(state.profile.name || "")}"
placeholder="输入预设名称"
/>
<div class="bme-task-editor-actions">
<button class="bme-config-secondary-btn" data-task-action="save-profile" type="button"><i class="fa-solid fa-floppy-disk"></i><span>保存</span></button>
<button class="bme-config-secondary-btn" data-task-action="rename-profile" type="button"><i class="fa-solid fa-pen"></i><span>重命名</span></button>
<button class="bme-config-secondary-btn" data-task-action="save-as-profile" type="button"><i class="fa-solid fa-copy"></i><span>另存为</span></button>
<button class="bme-config-secondary-btn" data-task-action="import-profile" type="button"><i class="fa-solid fa-file-import"></i><span>导入</span></button>
<button class="bme-config-secondary-btn" data-task-action="export-profile" type="button"><i class="fa-solid fa-file-export"></i><span>导出</span></button>
<button class="bme-config-secondary-btn bme-task-btn-danger" data-task-action="restore-default-profile" type="button"><i class="fa-solid fa-arrows-rotate"></i><span>恢复默认</span></button>
</div>
</div>
<div class="bme-task-header-actions">
<button class="bme-config-secondary-btn" data-task-action="save-profile" type="button">保存</button>
<button class="bme-config-secondary-btn" data-task-action="rename-profile" type="button">重命名</button>
<button class="bme-config-secondary-btn" data-task-action="save-as-profile" type="button">另存为</button>
<span class="bme-task-action-sep"></span>
<button class="bme-config-secondary-btn" data-task-action="import-profile" type="button">导入</button>
<button class="bme-config-secondary-btn" data-task-action="export-profile" type="button">导出</button>
<span class="bme-task-action-sep"></span>
<button class="bme-config-secondary-btn bme-task-btn-danger" data-task-action="restore-default-profile" type="button">恢复默认</button>
<div class="bme-task-subtabs">
${TASK_PROFILE_TABS.map(
(tab) => `
<button
class="bme-task-subtab-btn ${tab.id === state.taskTabId ? "active" : ""}"
data-task-action="switch-task-tab"
data-task-tab="${_escAttr(tab.id)}"
type="button"
>
${_escHtml(tab.label)}
</button>
`,
).join("")}
</div>
<div class="bme-task-tab-body">
${
state.taskTabId === "generation"
? _renderTaskGenerationTab(state)
: state.taskTabId === "regex"
? _renderTaskRegexTab(state)
: state.taskTabId === "debug"
? _renderTaskDebugTab(state)
: _renderTaskPromptTab(state)
}
</div>
</div>
</div>
<div class="bme-task-subtabs">
${TASK_PROFILE_TABS.map(
(tab) => `
<button
class="bme-task-subtab-btn ${tab.id === state.taskTabId ? "active" : ""}"
data-task-action="switch-task-tab"
data-task-tab="${_escAttr(tab.id)}"
type="button"
>
${_escHtml(tab.label)}
</button>
`,
).join("")}
</div>
<div class="bme-task-tab-body">
${
state.taskTabId === "generation"
? _renderTaskGenerationTab(state)
: state.taskTabId === "regex"
? _renderTaskRegexTab(state)
: state.taskTabId === "debug"
? _renderTaskDebugTab(state)
: _renderTaskPromptTab(state)
}
</div>
</div>
`;
}

374
style.css
View File

@@ -1311,7 +1311,8 @@
#st-bme-panel textarea.bme-config-textarea,
#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-node-detail-textarea,
#st-bme-panel .bme-task-editor-preset-select {
background-color: var(--bme-surface-high) !important;
color: var(--bme-on-surface) !important;
}
@@ -1381,6 +1382,20 @@
color: #f4f4f5 !important;
}
/* --- 压制宿主注入的原生对号 (SillyTavern 全局 checkbox::before) --- */
#st-bme-panel input[type="checkbox"]::before,
#st-bme-panel-overlay input[type="checkbox"]::before {
content: "" !important;
display: none !important;
background: none !important;
background-image: none !important;
-webkit-mask-image: none !important;
mask-image: none !important;
width: 0 !important;
height: 0 !important;
visibility: hidden !important;
}
#st-bme-panel input.bme-config-input:-webkit-autofill,
#st-bme-panel input.bme-config-input:-webkit-autofill:hover,
#st-bme-panel input.bme-config-input:-webkit-autofill:focus,
@@ -1640,6 +1655,7 @@
.bme-toggle-item input[type="checkbox"] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
width: 40px;
height: 22px;
@@ -1652,6 +1668,8 @@
position: relative;
cursor: pointer;
transition: background 0.2s ease, border-color 0.2s ease;
color: transparent;
overflow: hidden;
}
.bme-toggle-item input[type="checkbox"]::after {
@@ -1667,13 +1685,158 @@
}
.bme-toggle-item input[type="checkbox"]:checked {
background: var(--bme-primary, #a078ff);
border-color: var(--bme-primary, #a078ff);
background: color-mix(in srgb, var(--bme-primary) 45%, var(--bme-surface-high, #2a2a2d));
border-color: color-mix(in srgb, var(--bme-primary) 55%, transparent);
}
.bme-toggle-item input[type="checkbox"]:checked::after {
transform: translateX(18px);
background: #fff;
background: var(--bme-primary-text, #ffb2b7);
}
/* --- CAPABILITY CARD GRID (Feature Toggles) --- */
.bme-capability-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 14px;
}
.bme-capability-card {
display: flex;
flex-direction: column;
background: var(--bme-surface-container);
border: 1px solid var(--bme-border);
border-radius: 12px;
padding: 16px;
cursor: pointer;
transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
position: relative;
}
.bme-capability-card:hover {
border-color: var(--bme-primary);
box-shadow: 0 0 0 1px var(--bme-primary), 0 4px 12px rgba(0, 0, 0, 0.15);
}
.bme-cap-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
}
.bme-cap-icon {
width: 34px;
height: 34px;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
background: var(--bme-primary);
color: #fff;
font-size: 15px;
flex-shrink: 0;
}
.bme-cap-title {
font-size: 13px;
font-weight: 600;
color: var(--bme-on-surface);
margin-bottom: 4px;
line-height: 1.3;
}
.bme-cap-desc {
font-size: 11.5px;
color: var(--bme-on-surface-dim);
line-height: 1.45;
}
.bme-capability-card input[type="checkbox"] {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
width: 40px;
height: 22px;
background: var(--bme-surface-high);
border-radius: 11px;
position: relative;
cursor: pointer;
transition: background 0.2s;
flex-shrink: 0;
border: 1px solid var(--bme-border);
color: transparent;
overflow: hidden;
}
.bme-capability-card input[type="checkbox"]::after {
content: "";
position: absolute;
width: 16px;
height: 16px;
border-radius: 50%;
background: var(--bme-on-surface-dim);
top: 2px;
left: 3px;
transition: transform 0.2s, background 0.2s;
}
.bme-capability-card input[type="checkbox"]:checked {
background: color-mix(in srgb, var(--bme-primary) 45%, var(--bme-surface-high));
border-color: color-mix(in srgb, var(--bme-primary) 55%, transparent);
}
.bme-capability-card input[type="checkbox"]:checked::after {
transform: translateX(18px);
background: var(--bme-primary-text, #ffb2b7);
}
/* --- STRIPE ROW LAYOUT (Advanced Settings) --- */
.bme-stripe-section {
display: flex;
flex-direction: column;
}
.bme-stripe-row {
display: flex;
gap: 32px;
padding: 20px 0;
border-bottom: 1px solid var(--bme-border);
}
.bme-stripe-row:last-child {
border-bottom: none;
}
.bme-stripe-label {
flex: 0 0 28%;
max-width: 28%;
padding-top: 4px;
}
.bme-stripe-label-title {
font-size: 14px;
font-weight: 600;
color: var(--bme-on-surface);
margin-bottom: 6px;
line-height: 1.3;
}
.bme-stripe-label-desc {
font-size: 12px;
color: var(--bme-on-surface-dim);
line-height: 1.55;
}
.bme-stripe-content {
flex: 1;
min-width: 0;
}
.bme-stripe-content > .bme-config-card {
margin-bottom: 0;
}
.bme-prompt-card-actions {
@@ -1715,7 +1878,149 @@
.bme-task-shell {
display: flex;
flex-direction: column;
gap: 16px;
gap: 12px;
}
.bme-task-action-bar {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.bme-task-action-bar-right {
margin-left: auto;
display: flex;
align-items: center;
gap: 6px;
}
.bme-task-segmented-control {
display: inline-flex;
background: var(--bme-surface-container);
border-radius: 10px;
padding: 3px;
gap: 2px;
border: 1px solid var(--bme-border);
}
.bme-task-segmented-control .bme-task-type-btn {
border: none;
border-radius: 8px;
min-height: 32px;
padding: 0 14px;
font-size: 12.5px;
background: transparent;
color: var(--bme-on-surface-dim);
transition: background 0.15s, color 0.15s;
}
.bme-task-segmented-control .bme-task-type-btn:hover {
background: rgba(255, 255, 255, 0.06);
color: var(--bme-on-surface);
}
.bme-task-segmented-control .bme-task-type-btn.active {
background: var(--bme-primary);
color: #fff;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.bme-task-master-detail {
display: flex;
gap: 0;
border: 1px solid var(--bme-border);
border-radius: 12px;
overflow: hidden;
min-height: 480px;
background: var(--bme-surface-container);
}
.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-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;
}
.bme-task-editor-preset-select {
flex: 1;
min-width: 200px;
min-height: 40px;
font-size: 16px;
font-weight: 600;
padding: 6px 32px 6px 12px;
line-height: 1.35;
border-radius: 8px;
border: 1px solid var(--bme-border);
cursor: pointer;
}
.bme-task-profile-editor {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
overflow-y: auto;
}
.bme-task-editor-header {
padding: 16px 20px;
border-bottom: 1px solid var(--bme-border);
display: flex;
flex-direction: column;
gap: 10px;
}
.bme-task-editor-title-row {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.bme-task-editor-preset-select:hover,
.bme-task-editor-preset-select:focus {
border-color: var(--bme-primary);
outline: none;
}
.bme-task-editor-actions {
display: flex;
gap: 6px;
flex-wrap: wrap;
}
.bme-task-editor-actions .bme-config-secondary-btn {
font-size: 12px;
min-height: 28px;
padding: 0 10px;
gap: 4px;
}
.bme-task-profile-editor > .bme-task-subtabs {
padding: 0 20px;
border-bottom: 1px solid var(--bme-border);
}
.bme-task-profile-editor > .bme-task-tab-body {
flex: 1;
padding: 16px 20px;
overflow-y: auto;
}
.bme-task-header {
@@ -3734,3 +4039,62 @@
font-size: 10px;
}
}
/* --- RESPONSIVE: New Layout Components --- */
@media (max-width: 768px) {
.bme-capability-grid {
grid-template-columns: repeat(2, 1fr);
gap: 10px;
}
.bme-stripe-row {
flex-direction: column;
gap: 12px;
}
.bme-stripe-label {
flex: none;
max-width: 100%;
}
.bme-task-master-detail {
flex-direction: column;
min-height: auto;
}
.bme-task-editor-preset-select {
min-width: 0;
width: 100%;
flex: 1 1 100%;
}
.bme-task-editor-title-row {
flex-direction: column;
align-items: stretch;
}
.bme-task-profile-badges {
justify-content: flex-start;
}
.bme-task-segmented-control {
flex-wrap: wrap;
}
.bme-task-action-bar {
flex-direction: column;
align-items: stretch;
}
.bme-task-action-bar-right {
margin-left: 0;
justify-content: flex-end;
}
}
@media (max-width: 520px) {
.bme-capability-grid {
grid-template-columns: 1fr;
}
}