feat(webui): system settings panel (port/host/TLS/trust-proxy)

New Settings → 服务 tab (SystemPanel) over the /api/system/settings + TLS cert
API: edit port / bind host / trust-proxy, paste cert+key PEM to enable HTTPS,
delete cert. Flags env-overridden fields ('被环境变量覆盖') and shows a
restart-to-apply banner (no self-restart). Typed systemSettings API client
domain. View layer — verified by tsc + vite build (webui has no component-test
infra).
This commit is contained in:
DrSmoothl committed 2026-06-18 14:39:35 +08:00
1 parent 7faef1b7c0
commit 82d5f782a3
6 files changed
+256 -3

No files matched your search

+17 -1
View File
@@ -1,4 +1,4 @@
import type { AccountConnections, HookProcessInfo, LogEntry, LogLevel, NotificationDeliveryRecord, NotificationsConfig, QQInfo, SystemInfo, UiAppearance, UiConfig, UpdateInfo } from '@/types';
import type { AccountConnections, 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 {
@@ -45,6 +45,7 @@ class HttpApiClient implements ApiClient {
readonly update: ApiClient['update'];
readonly ui: ApiClient['ui'];
readonly notifications: ApiClient['notifications'];
readonly systemSettings: ApiClient['systemSettings'];
constructor(opts: CreateApiClientOptions = {}) {
this.tokenStore = opts.tokenStore ?? localStorageTokenStore(DEFAULT_TOKEN_KEY);
@@ -98,6 +99,21 @@ class HttpApiClient implements ApiClient {
this.getJson<UpdateInfo>(`/api/update/check${force ? '?force=true' : ''}`),
};
this.systemSettings = {
get: () => this.getJson<SystemSettingsResponse>('/api/system/settings'),
save: (patch: SystemSettingsPatch) =>
this.postJson<{ settings: SystemSettingsResponse['settings']; restartRequiredToApply: boolean }>(
'/api/system/settings',
patch,
),
uploadCert: async (cert: string, key: string) => {
await this.postJson<{ success: boolean }>('/api/system/tls/cert', { cert, key });
},
deleteCert: async () => {
await this.fetchJson<{ success: boolean }>('/api/system/tls/cert', { method: 'DELETE' });
},
};
this.ui = {
get: () => this.getJson<{ config: UiConfig }>('/api/ui').then((d) => d.config),
save: async (config) => {