panel: an open agent's effort is the effort picker's slider — its name and level over a thin track with a dot per stop, the ends named under it; a level shows at once, the row's bars with it, and is written after in order, so the agent's slow config write no longer holds the control for a second and a half (巨卡 / 变成之前的那种滑轨样式)
This commit is contained in:
@@ -568,10 +568,9 @@ body.panel .ag-open .field.open { box-shadow: inset 0 0 0 1px var(--accent); }
|
||||
.ag-open .field > .ic, .ag-open .field > .ic-stack { order: 2; flex: none; }
|
||||
.row.agent .ag-open .field .ic { width: 14px; height: 14px; }
|
||||
.ag-open .field .chev { order: 3; margin-left: 0; transform: none; }
|
||||
.ag-seg { display: flex; padding: 2px; border-radius: 8px; background: color-mix(in srgb, var(--fg) 6%, transparent); }
|
||||
.ag-seg button { flex: 1; min-width: 0; padding: 4px 0; border-radius: 6px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: color .15s, background-color .15s; }
|
||||
.ag-seg button:hover:not(.on) { color: var(--fg-2); }
|
||||
.ag-seg button.on { background: var(--card); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), var(--card-edge); }
|
||||
.ag-open .effort-control { padding: 2px 4px 0; }
|
||||
.ag-open .effort-head { margin-bottom: 4px; }
|
||||
.ag-open .effort-head span { font-size: 11px; color: var(--faint); }
|
||||
.ag-open .extras-cell { display: flex; justify-content: flex-start; gap: 6px; }
|
||||
.ag-open .extras-cell .field { width: 30px; padding: 0; justify-content: center; }
|
||||
body.panel .row.agent .ag-fix { left: 21px; top: 22px; }
|
||||
|
||||
+51
-23
@@ -972,30 +972,58 @@ function effortBars(f) {
|
||||
return e;
|
||||
}
|
||||
|
||||
// effortSeg: an opened panel row's effort, every level side by side.
|
||||
// effortSeg: an opened panel row's effort, as the effort picker's slider.
|
||||
// A level shows at once, bars and all; the write follows, in order, so a
|
||||
// slow agent config never holds the thumb (巨卡).
|
||||
function effortSeg(a, f) {
|
||||
const seg = el("div", "ag-seg");
|
||||
seg.setAttribute("role", "radiogroup");
|
||||
seg.setAttribute("aria-label", t(f.label));
|
||||
for (const o of f.options) {
|
||||
const b = el("button", o.value === f.value ? "on" : "", effortName(o));
|
||||
b.type = "button";
|
||||
b.setAttribute("role", "radio");
|
||||
b.setAttribute("aria-checked", String(o.value === f.value));
|
||||
if (o.note) b.title = o.note;
|
||||
b.onclick = async () => {
|
||||
if (o.value === f.value) return;
|
||||
try {
|
||||
state = await api("set", { agent: a.id, field: f.key, value: o.value });
|
||||
renderAgents();
|
||||
status(`${a.name} ${t(f.label)} → ${effortName(o)}`, "ok");
|
||||
} catch (e) {
|
||||
status(e.message, "err");
|
||||
}
|
||||
};
|
||||
seg.append(b);
|
||||
}
|
||||
return seg;
|
||||
const options = f.options;
|
||||
const box = el("div", "effort-control");
|
||||
const head = el("div", "effort-head");
|
||||
const value = el("b");
|
||||
head.append(el("span", "", t(f.label)), value);
|
||||
const track = el("div", "effort-track");
|
||||
const ticks = el("span", "effort-ticks");
|
||||
ticks.setAttribute("aria-hidden", "true");
|
||||
ticks.append(...options.map((_, i) => {
|
||||
const dot = el("i");
|
||||
dot.style.setProperty("--at", options.length > 1 ? i / (options.length - 1) : 0);
|
||||
return dot;
|
||||
}));
|
||||
const range = el("input");
|
||||
range.type = "range";
|
||||
range.min = "0";
|
||||
range.step = "1";
|
||||
range.max = String(Math.max(0, options.length - 1));
|
||||
range.value = String(Math.max(0, options.findIndex((o) => o.value === f.value)));
|
||||
range.setAttribute("aria-label", t(f.label));
|
||||
track.append(ticks, range);
|
||||
const ends = el("div", "effort-ends");
|
||||
ends.setAttribute("aria-hidden", "true");
|
||||
ends.append(el("span", "", effortName(options[0])), el("span", "", effortName(options[options.length - 1])));
|
||||
box.append(head, track, ends);
|
||||
const update = () => {
|
||||
const i = Number(range.value);
|
||||
[...ticks.children].forEach((dot, j) => { dot.classList.toggle("on", j < i); dot.classList.toggle("cur", j === i); });
|
||||
value.textContent = effortName(options[i]);
|
||||
const fill = `${options.length > 1 ? 100 * i / (options.length - 1) : 0}%`;
|
||||
range.style.setProperty("--fill", fill);
|
||||
track.style.setProperty("--fill", fill);
|
||||
range.setAttribute("aria-valuetext", effortName(options[i]));
|
||||
};
|
||||
range.oninput = update;
|
||||
let saving = Promise.resolve();
|
||||
range.onchange = () => {
|
||||
const o = options[Number(range.value)];
|
||||
if (!o || o.value === f.value) return;
|
||||
f.value = o.value;
|
||||
box.closest(".row")?.querySelector(".ag-sum .eff")?.replaceWith(effortBars(f));
|
||||
saving = saving.then(async () => {
|
||||
state = await api("set", { agent: a.id, field: f.key, value: o.value });
|
||||
status(`${a.name} ${t(f.label)} → ${effortName(o)}`, "ok");
|
||||
}).catch((e) => { status(e.message, "err"); renderAgents(); });
|
||||
};
|
||||
update();
|
||||
return box;
|
||||
}
|
||||
|
||||
function renderEffortPicker() {
|
||||
|
||||
Reference in New Issue
Block a user