设置: 限制 TLS 与远程管理开关

This commit is contained in:
jiesen
2025-12-21 01:23:43 +07:00
parent 1295f48eaf
commit 3411f92c3d
2 changed files with 25 additions and 9 deletions
@@ -90,6 +90,11 @@ export function RemoteManagementSettings() {
const rm = config.remote_management;
const isEnabled = Boolean(rm.secret_key && rm.secret_key.length > 0);
const remoteAccessSupported = false;
const allowRemoteToggleEnabled = remoteAccessSupported && isEnabled;
const allowRemoteToggleDisabled =
!allowRemoteToggleEnabled && !rm.allow_remote;
const remoteAccessUnsupportedEnabled =
rm.allow_remote && !remoteAccessSupported;
return (
<div className="space-y-4">
@@ -187,7 +192,7 @@ export function RemoteManagementSettings() {
{/* 允许远程访问 */}
<label
className={`flex items-center justify-between p-3 rounded-lg border cursor-pointer hover:bg-muted/50 ${!isEnabled || !remoteAccessSupported ? "opacity-50 pointer-events-none" : ""}`}
className={`flex items-center justify-between p-3 rounded-lg border cursor-pointer hover:bg-muted/50 ${allowRemoteToggleDisabled ? "opacity-50 pointer-events-none" : ""}`}
>
<div>
<span className="text-sm font-medium">允许远程访问</span>
@@ -198,11 +203,14 @@ export function RemoteManagementSettings() {
<input
type="checkbox"
checked={rm.allow_remote}
onChange={(e) =>
updateRemoteManagement({ allow_remote: e.target.checked })
}
onChange={(e) => {
if (e.target.checked && !allowRemoteToggleEnabled) {
return;
}
updateRemoteManagement({ allow_remote: e.target.checked });
}}
className="w-4 h-4 rounded border-gray-300"
disabled={!isEnabled || !remoteAccessSupported}
disabled={allowRemoteToggleDisabled}
/>
</label>
@@ -241,7 +249,7 @@ export function RemoteManagementSettings() {
<button
onClick={handleSave}
disabled={saving}
disabled={saving || remoteAccessUnsupportedEnabled}
className="w-full px-4 py-2 rounded-lg bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90 disabled:opacity-50"
>
{saving ? "保存中..." : "保存远程管理设置"}
+11 -3
View File
@@ -92,6 +92,7 @@ export function TlsSettings() {
const tlsSupported = false;
const tls = config.server.tls;
const isConfigValid = !tls.enable || (tls.cert_path && tls.key_path);
const tlsUnsupportedEnabled = tls.enable && !tlsSupported;
return (
<div className="space-y-4">
@@ -143,8 +144,13 @@ export function TlsSettings() {
<input
type="checkbox"
checked={tls.enable}
onChange={(e) => updateTls({ enable: e.target.checked })}
disabled={!tlsSupported}
onChange={(e) => {
if (!tlsSupported && e.target.checked) {
return;
}
updateTls({ enable: e.target.checked });
}}
disabled={!tlsSupported && !tls.enable}
className="w-4 h-4 rounded border-gray-300"
/>
</label>
@@ -221,7 +227,9 @@ export function TlsSettings() {
<button
onClick={handleSave}
disabled={saving || !tlsSupported || (tls.enable && !isConfigValid)}
disabled={
saving || tlsUnsupportedEnabled || (tls.enable && !isConfigValid)
}
className="w-full px-4 py-2 rounded-lg bg-primary text-primary-foreground text-sm font-medium hover:bg-primary/90 disabled:opacity-50"
>
{saving ? "保存中..." : "保存 TLS 设置"}