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:
9 files changed
+283
-22
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import type { AccountConnections, BackupBundle, BackupImportResult, DebugActionDoc, DebugInvokeResult, DebugStreamMessage, HookProcessInfo, LogEntry, LogLevel, NotificationDeliveryRecord, NotificationsConfig, QQInfo, SystemInfo, SystemSettingsPatch, SystemSettingsResponse, UiAppearance, UiConfig, UpdateInfo } from '@/types';
|
||||
import type { AccountConnections, BackupBundle, BackupImportResult, DebugActionDoc, DebugInvokeResult, DebugStreamMessage, GlobalSettings, HookProcessInfo, LogEntry, LogLevel, NotificationDeliveryRecord, NotificationsConfig, QQInfo, SystemInfo, SystemSettingsPatch, SystemSettingsResponse, UiAppearance, UiConfig, UpdateInfo } from '@/types';
|
||||
import type { PasswordRule } from '@/components/pages/change-password-page';
|
||||
import { normalizeOneBotConfig } from '@/lib/onebot-config';
|
||||
import {
|
||||
@@ -48,6 +48,7 @@ class HttpApiClient implements ApiClient {
|
||||
readonly update: ApiClient['update'];
|
||||
readonly ui: ApiClient['ui'];
|
||||
readonly notifications: ApiClient['notifications'];
|
||||
readonly globalConfig: ApiClient['globalConfig'];
|
||||
readonly systemSettings: ApiClient['systemSettings'];
|
||||
readonly debug: ApiClient['debug'];
|
||||
readonly agreements: ApiClient['agreements'];
|
||||
@@ -190,6 +191,18 @@ class HttpApiClient implements ApiClient {
|
||||
}),
|
||||
};
|
||||
|
||||
this.globalConfig = {
|
||||
get: () =>
|
||||
this.getJson<{ config: GlobalSettings }>('/api/global-config').then((d) => d.config),
|
||||
save: async (config) => {
|
||||
const data = await this.postJson<{ success: boolean; config: GlobalSettings }>(
|
||||
'/api/global-config',
|
||||
config,
|
||||
);
|
||||
return data.config;
|
||||
},
|
||||
};
|
||||
|
||||
this.agreements = {
|
||||
get: () => this.getJson<AgreementsPayload>('/api/agreements'),
|
||||
recordConsent: async (version) => {
|
||||
|
||||
@@ -5,6 +5,7 @@ import type {
|
||||
DebugActionDoc,
|
||||
DebugInvokeResult,
|
||||
DebugStreamMessage,
|
||||
GlobalSettings,
|
||||
HookProcessInfo,
|
||||
LogEntry,
|
||||
LogLevel,
|
||||
@@ -167,6 +168,14 @@ export interface ApiClient {
|
||||
test(channelId: string): Promise<{ success: boolean; message?: string; status?: number }>;
|
||||
};
|
||||
|
||||
// ---- global deployment config (rkey fallback servers + musicSignUrl) ----
|
||||
globalConfig: {
|
||||
/** Fetch the all-accounts global settings (config/snowluma.json). Bearer-gated. */
|
||||
get(): Promise<GlobalSettings>;
|
||||
/** Persist global settings (section-merged + normalized server-side). */
|
||||
save(config: Partial<GlobalSettings>): Promise<GlobalSettings>;
|
||||
};
|
||||
|
||||
// ---- update check ----
|
||||
update: {
|
||||
/** Advisory check for a newer stable release. Read-only — never downloads. */
|
||||
|
||||
Reference in new issue
Block a user