fix: widget deletion and layout persistence issues

This commit is contained in:
ZacharyZcR
2025-10-09 09:02:38 +08:00
parent 74f537ea0b
commit a671ad79a1
3 changed files with 19 additions and 7 deletions

View File

@@ -414,6 +414,7 @@ router.put(
enableFileManager, enableFileManager,
defaultPath, defaultPath,
tunnelConnections, tunnelConnections,
statsConfig,
} = hostData; } = hostData;
if ( if (
!isNonEmptyString(userId) || !isNonEmptyString(userId) ||
@@ -450,6 +451,7 @@ router.put(
: null, : null,
enableFileManager: enableFileManager ? 1 : 0, enableFileManager: enableFileManager ? 1 : 0,
defaultPath: defaultPath || null, defaultPath: defaultPath || null,
statsConfig: statsConfig || null,
}; };
if (effectiveAuthType === "password") { if (effectiveAuthType === "password") {

View File

@@ -35,6 +35,7 @@ export interface SSHHost {
enableFileManager: boolean; enableFileManager: boolean;
defaultPath: string; defaultPath: string;
tunnelConnections: TunnelConnection[]; tunnelConnections: TunnelConnection[];
statsConfig?: string;
createdAt: string; createdAt: string;
updatedAt: string; updatedAt: string;
} }
@@ -58,6 +59,7 @@ export interface SSHHostData {
enableFileManager?: boolean; enableFileManager?: boolean;
defaultPath?: string; defaultPath?: string;
tunnelConnections?: any[]; tunnelConnections?: any[];
statsConfig?: string;
} }
// ============================================================================ // ============================================================================

View File

@@ -110,7 +110,12 @@ export function Server({
setHasUnsavedChanges(true); setHasUnsavedChanges(true);
}; };
const handleDeleteWidget = (widgetId: string) => { const handleDeleteWidget = (
widgetId: string,
e: React.MouseEvent<HTMLButtonElement>,
) => {
e.stopPropagation();
e.preventDefault();
setWidgets((prev) => prev.filter((w) => w.id !== widgetId)); setWidgets((prev) => prev.filter((w) => w.id !== widgetId));
setHasUnsavedChanges(true); setHasUnsavedChanges(true);
}; };
@@ -147,8 +152,9 @@ export function Server({
<div className="h-full w-full space-y-3 p-4 rounded-lg bg-dark-bg/50 border border-dark-border/50 hover:bg-dark-bg/70 transition-colors duration-200"> <div className="h-full w-full space-y-3 p-4 rounded-lg bg-dark-bg/50 border border-dark-border/50 hover:bg-dark-bg/70 transition-colors duration-200">
{isEditMode && ( {isEditMode && (
<button <button
onClick={() => handleDeleteWidget(widget.id)} onClick={(e) => handleDeleteWidget(widget.id, e)}
className="absolute top-2 right-2 z-10 w-6 h-6 bg-red-500/80 hover:bg-red-500 text-white rounded-full flex items-center justify-center" className="absolute top-2 right-2 z-[9999] w-6 h-6 bg-red-500/80 hover:bg-red-500 text-white rounded-full flex items-center justify-center cursor-pointer"
type="button"
> >
<X className="h-4 w-4" /> <X className="h-4 w-4" />
</button> </button>
@@ -198,8 +204,9 @@ export function Server({
<div className="h-full w-full space-y-3 p-4 rounded-lg bg-dark-bg/50 border border-dark-border/50 hover:bg-dark-bg/70 transition-colors duration-200"> <div className="h-full w-full space-y-3 p-4 rounded-lg bg-dark-bg/50 border border-dark-border/50 hover:bg-dark-bg/70 transition-colors duration-200">
{isEditMode && ( {isEditMode && (
<button <button
onClick={() => handleDeleteWidget(widget.id)} onClick={(e) => handleDeleteWidget(widget.id, e)}
className="absolute top-2 right-2 z-10 w-6 h-6 bg-red-500/80 hover:bg-red-500 text-white rounded-full flex items-center justify-center" className="absolute top-2 right-2 z-[9999] w-6 h-6 bg-red-500/80 hover:bg-red-500 text-white rounded-full flex items-center justify-center cursor-pointer"
type="button"
> >
<X className="h-4 w-4" /> <X className="h-4 w-4" />
</button> </button>
@@ -260,8 +267,9 @@ export function Server({
<div className="h-full w-full space-y-3 p-4 rounded-lg bg-dark-bg/50 border border-dark-border/50 hover:bg-dark-bg/70 transition-colors duration-200"> <div className="h-full w-full space-y-3 p-4 rounded-lg bg-dark-bg/50 border border-dark-border/50 hover:bg-dark-bg/70 transition-colors duration-200">
{isEditMode && ( {isEditMode && (
<button <button
onClick={() => handleDeleteWidget(widget.id)} onClick={(e) => handleDeleteWidget(widget.id, e)}
className="absolute top-2 right-2 z-10 w-6 h-6 bg-red-500/80 hover:bg-red-500 text-white rounded-full flex items-center justify-center" className="absolute top-2 right-2 z-[9999] w-6 h-6 bg-red-500/80 hover:bg-red-500 text-white rounded-full flex items-center justify-center cursor-pointer"
type="button"
> >
<X className="h-4 w-4" /> <X className="h-4 w-4" />
</button> </button>