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:
6 files changed
+256
-3
No files matched your search
@@ -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) => {
|
||||
|
||||
@@ -8,6 +8,9 @@ import type {
|
||||
OneBotConfig,
|
||||
QQInfo,
|
||||
SystemInfo,
|
||||
SystemSettings,
|
||||
SystemSettingsPatch,
|
||||
SystemSettingsResponse,
|
||||
UiAppearance,
|
||||
UiConfig,
|
||||
UpdateInfo,
|
||||
@@ -74,6 +77,15 @@ export interface ApiClient {
|
||||
save(uin: string, config: OneBotConfig): Promise<OneBotConfig>;
|
||||
};
|
||||
|
||||
// ---- WebUI listener self-config (port / host / TLS / trust-proxy) ----
|
||||
systemSettings: {
|
||||
get(): Promise<SystemSettingsResponse>;
|
||||
save(patch: SystemSettingsPatch): Promise<{ settings: SystemSettings; restartRequiredToApply: boolean }>;
|
||||
/** Validate + write config/cert.pem + key.pem (restart to apply). */
|
||||
uploadCert(cert: string, key: string): Promise<void>;
|
||||
deleteCert(): Promise<void>;
|
||||
};
|
||||
|
||||
// ---- notifications (account up/down webhooks) ----
|
||||
notifications: {
|
||||
/** Global channel store (channels + debounce). Bearer-gated. */
|
||||
|
||||
Reference in new issue
Block a user