feat(webui): global-config settings tab + /api/global-config

Adds a '全局配置' Settings tab that edits config/snowluma.json — the rkey
fallback-server list and the deployment-wide musicSignUrl — backed by a new
bearer-gated GET/POST /api/global-config (load/saveGlobalSettings, then
oneBotManager.reloadGlobalSettings to hot-apply to live instances).

The panel reuses the established settings-panel idiom (Input/Button/Label,
debounced auto-save, flash); rkey servers are an inline add/remove list with
client-side http(s) validation hints. It deliberately does not reconcile inputs
from the server's normalized response (would erase a half-typed URL); a
load-failure shows an error+retry, and the save toast says '无效项已忽略' when
the server would drop an entry.

Removes the now-dead per-UIN musicSignUrl form (moved to global in Phase 2).
Phase 3 of the global-settings split (nav grouping is Phase 4).
This commit is contained in:
DrSmoothl committed 2026-06-28 22:16:07 +08:00
1 parent ea1c5ff9eb
commit 196f98e97c
9 files changed
+283 -22

No files matched your search

@@ -1,7 +1,8 @@
// "通用设置" tab — fields that apply to the whole OneBotInstance rather
// than any specific adapter: the music-sign service URL and the built-in
// `#sl` status command. Edits here mark the config dirty and are
// auto-saved with debounce by the parent ConfigPage.
// "通用设置" tab — per-account fields that apply to the whole OneBotInstance
// rather than any specific adapter: the built-in `#sl` status command and the
// notification opt-in. Edits here mark the config dirty and are auto-saved with
// debounce by the parent ConfigPage. (Deployment-wide knobs like the music-sign
// URL live in Settings → 全局配置, not here.)
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
@@ -21,19 +22,6 @@ export function GeneralSettingsTab({ config, onChange }: GeneralSettingsTabProps
return (
<div className="flex flex-col gap-4">
<div className="flex flex-col gap-1.5 rounded-lg border bg-card/40 p-4">
<Label>音乐签名服务 URL</Label>
<Input
type="url"
placeholder="留空则不启用"
value={config.musicSignUrl ?? ''}
onChange={(e) => onChange({ ...config, musicSignUrl: e.target.value || undefined })}
/>
<p className="text-[11px] leading-relaxed text-muted-foreground">
用于音乐分享卡片签名。未配置时音乐相关消息段会回落为普通文本。
</p>
</div>
<div className="flex flex-col gap-4 rounded-lg border bg-card/40 p-4">
<div className="flex items-start justify-between gap-3">
<div className="min-w-0">