Files
hermes-web/packages/client/src/components/hermes/settings/SessionSettings.vue
T
toor 993b6b968c give the pages the CYBER shell they were missing
The token swap made every control dark, but the pages themselves kept
their Arco defaults — bare `padding: 20px` with components laid straight
on the background. That is why the running app still read as "not the
prototype" no matter how many variables were replaced: the prototype's
page structure (panel / panel-h / panel-b / kv / tabs) was never built.

Rather than restate that shell in each of the 25 views, it now lives in
global.scss as .cy-view / .cy-panel / .cy-panel-h / .cy-panel-b /
.cy-kv / .cy-tabs / .cy-tab / .cy-stack / .cy-sec-t, and the settings
components share a global .settings-section + .section-title so all nine
panes pick up the mono section headers at once. The per-component
duplicates of those two rules were deleted.

Settings is converted as the reference case: Arco's a-tabs/a-tab-pane
became the underline tab strip, and the pane body sits in a panel. The
URL-query sync moved to a watcher on activeTab so pane order and deep
links still hold. Pane order is a contract, so it is asserted.

Two tests lock the shell in place — one for the global classes and the
cyan underline selected state, one for the settings structure and pane
order. Without them the next edit easily slides back to bare Arco.
2026-10-19 15:23:01 +08:00

149 lines
4.9 KiB
Vue

<script setup lang="ts">
import { useMessage } from "@/composables/useMessage";
import { useI18n } from "vue-i18n";
import { useSettingsStore } from "@/stores/hermes/settings";
import { useSessionBrowserPrefsStore } from "@/stores/hermes/session-browser-prefs";
import SettingRow from "./SettingRow.vue";
const settingsStore = useSettingsStore();
const sessionBrowserPrefsStore = useSessionBrowserPrefsStore();
const message = useMessage();
const { t } = useI18n();
// 防抖保存:每个字段独立定时器,300ms 内只发最后一次 HTTP 请求
const debounceTimers: Record<string, ReturnType<typeof setTimeout>> = {};
function save(values: Record<string, any>) {
// 下拉/开关等一次性操作,直接保存,不需要防抖
settingsStore.updateLocal('session_reset', values)
settingsStore.saveSection('session_reset', values).then(() => {
message.success(t("settings.saved"));
}).catch(() => {
message.error(t("settings.saveFailed"));
});
}
function debouncedSave(key: string, value: any) {
// 先立即更新本地 store(UI 即时响应)
settingsStore.updateLocal('session_reset', { [key]: value });
// 再防抖发 HTTP 保存
if (debounceTimers[key]) clearTimeout(debounceTimers[key])
debounceTimers[key] = setTimeout(async () => {
try {
await settingsStore.saveSection('session_reset', { [key]: value });
message.success(t("settings.saved"));
} catch (err: any) {
message.error(t("settings.saveFailed"));
}
}, 300);
}
async function toggleRequireAuth(value: boolean) {
try {
await settingsStore.saveSection("approvals", { mode: value ? "manual" : "off" });
message.success(t("settings.saved"));
} catch (err: any) {
message.error(t("settings.saveFailed"));
}
}
async function toggleWriteApproval(section: "memory" | "skills", value: boolean) {
try {
settingsStore.updateLocal(section, { write_approval: value });
await settingsStore.saveSection(section, { write_approval: value });
message.success(t("settings.saved"));
} catch (err: any) {
message.error(t("settings.saveFailed"));
}
}
</script>
<template>
<section class="settings-section">
<SettingRow
:label="t('settings.session.requireAuth')"
:hint="t('settings.session.requireAuthHint')"
>
<a-switch :model-value="settingsStore.approvals.mode === 'manual'" @update:model-value="(v) => toggleRequireAuth(v as boolean)" />
</SettingRow>
<SettingRow
:label="t('settings.session.memoryWriteApproval')"
:hint="t('settings.session.memoryWriteApprovalHint')"
>
<a-switch
:model-value="settingsStore.memory.write_approval === true"
@update:model-value="(value) => toggleWriteApproval('memory', value as boolean)"
/>
</SettingRow>
<SettingRow
:label="t('settings.session.skillsWriteApproval')"
:hint="t('settings.session.skillsWriteApprovalHint')"
>
<a-switch
:model-value="settingsStore.skills.write_approval === true"
@update:model-value="(value) => toggleWriteApproval('skills', value as boolean)"
/>
</SettingRow>
<SettingRow
:label="t('settings.session.mode')"
:hint="t('settings.session.modeHint')"
>
<a-select
:model-value="settingsStore.sessionReset.mode || 'both'"
:options="[
{ label: t('settings.session.modeBoth'), value: 'both' },
{ label: t('settings.session.modeIdle'), value: 'idle' },
{ label: t('settings.session.modeDaily'), value: 'daily' },
{ label: t('settings.session.modeNone'), value: 'none' },
]"
size="small"
class="input-md"
@update:model-value="(v) => save({ mode: v })"
/>
</SettingRow>
<SettingRow
:label="t('settings.session.idleMinutes')"
:hint="t('settings.session.idleMinutesHint')"
>
<a-input-number
:model-value="settingsStore.sessionReset.idle_minutes"
:min="10"
:max="10080"
:step="30"
size="small"
class="input-sm"
@update:model-value="(v) => v != null && debouncedSave('idle_minutes', v)"
/>
</SettingRow>
<SettingRow
:label="t('settings.session.atHour')"
:hint="t('settings.session.atHourHint')"
>
<a-input-number
:model-value="settingsStore.sessionReset.at_hour"
:min="0"
:max="23"
:step="1"
size="small"
class="input-sm"
@update:model-value="(v) => v != null && debouncedSave('at_hour', v)"
/>
</SettingRow>
<SettingRow
:label="t('settings.session.liveMonitorHumanOnly')"
:hint="t('settings.session.liveMonitorHumanOnlyHint')"
>
<a-switch
:model-value="sessionBrowserPrefsStore.humanOnly"
@update:model-value="(value) => sessionBrowserPrefsStore.setHumanOnly(value as boolean)"
/>
</SettingRow>
</section>
</template>
<style scoped lang="scss">
@use "@/styles/variables" as *;
</style>