fix: improve Tailscale error handling in UI components and refine backend state mapping

This commit is contained in:
wj-xiao
2026-02-28 11:12:26 +08:00
parent 2a43fb5413
commit 11980b9122
7 changed files with 24 additions and 6 deletions

View File

@@ -20,11 +20,13 @@ const (
)
var StateMap = map[string]proto.TailscaleState{
"NoState": proto.TailscaleNotRunning,
"Starting": proto.TailscaleNotRunning,
"NeedsLogin": proto.TailscaleNotLogin,
"Running": proto.TailscaleRunning,
"Stopped": proto.TailscaleStopped,
"NoState": proto.TailscaleNotRunning,
"Starting": proto.TailscaleNotRunning,
"NeedsLogin": proto.TailscaleNotLogin,
"NeedsMachineAuth": proto.TailscaleNotLogin,
"InUseOtherUser": proto.TailscaleNotLogin,
"Running": proto.TailscaleRunning,
"Stopped": proto.TailscaleStopped,
}
func NewService() *Service {

View File

@@ -55,6 +55,9 @@ export const Device = ({ status, onLogout }: DeviceProps) => {
onLogout();
})
.catch((err) => {
setErrMsg(err?.message || 'Failed to logout');
})
.finally(() => {
setIsLogging(false);
});

View File

@@ -41,6 +41,9 @@ export const Tailscale = ({ setIsLocked }: TailscaleProps) => {
setStatus(rsp.data);
})
.catch((err) => {
setErrMsg(err?.message || 'Failed to get status');
})
.finally(() => {
setIsLoading(false);
});

View File

@@ -29,9 +29,12 @@ export const Install = ({ setIsLocked, onSuccess }: InstallProps) => {
}
onSuccess();
setState('');
})
.catch(() => {
setState('failed');
})
.finally(() => {
setState('');
setIsLocked(false);
});
}

View File

@@ -38,6 +38,9 @@ export const Login = ({ onSuccess }: LoginProps) => {
window.open(url, '_blank');
setTimeout(() => setLoginUrl(''), 10 * 60 * 1000);
})
.catch((err) => {
setErrMsg(err?.message || 'Failed to login');
})
.finally(() => {
setIsLoading(false);
});

View File

@@ -29,6 +29,9 @@ export const Run = ({ onSuccess }: RunProps) => {
onSuccess();
})
.catch((err) => {
setErrMsg(err?.message || 'Failed to run tailscale');
})
.finally(() => {
setIsLoading(false);
});

View File

@@ -45,6 +45,7 @@ export const Uninstall = ({ onSuccess }: UninstallProps) => {
<Modal
title={title}
open={isModalOpen}
centered={true}
okType="danger"
okText={t('settings.tailscale.okBtn')}
cancelText={t('settings.tailscale.cancelBtn')}