添加全屏支持,更新窗口控制逻辑和图标资源

Adds fullscreen support and updates window controls

Introduces fullscreen detection and change events for windows,
adjusts UI logic for fullscreen state on macOS, and updates icon
and logo assets for improved appearance. Enhances user experience
by better accommodating fullscreen workflows.
This commit is contained in:
bincxz committed 2025-12-19 03:24:00 +08:00
1 parent 7cb97eb681
commit cd367fa44a
7 files changed
+108 -4

No files matched your search

+12 -1
View File
@@ -40,6 +40,16 @@ export const useWindowControls = () => {
return bridge?.windowIsMaximized?.();
}, []);
const isFullscreen = useCallback(async () => {
const bridge = netcattyBridge.get();
return bridge?.windowIsFullscreen?.() ?? false;
}, []);
const onFullscreenChanged = useCallback((cb: (isFullscreen: boolean) => void) => {
const bridge = netcattyBridge.get();
return bridge?.onWindowFullScreenChanged?.(cb) ?? (() => {});
}, []);
return {
notifyRendererReady,
closeSettingsWindow,
@@ -48,6 +58,7 @@ export const useWindowControls = () => {
maximize,
close,
isMaximized,
isFullscreen,
onFullscreenChanged,
};
};
+16 -2
View File
@@ -132,7 +132,7 @@ const TopTabsInner: React.FC<TopTabsProps> = ({
}) => {
const { t } = useI18n();
// Subscribe to activeTabId from external store
const { maximize } = useWindowControls();
const { maximize, isFullscreen, onFullscreenChanged } = useWindowControls();
const activeTabId = useActiveTabId();
const isVaultActive = activeTabId === 'vault';
const isSftpActive = activeTabId === 'sftp';
@@ -142,6 +142,20 @@ const TopTabsInner: React.FC<TopTabsProps> = ({
const [dropIndicator, setDropIndicator] = useState<{ tabId: string; position: 'before' | 'after' } | null>(null);
const [isDraggingForReorder, setIsDraggingForReorder] = useState(false);
const draggedTabIdRef = useRef<string | null>(null);
const [isWindowFullscreen, setIsWindowFullscreen] = useState(false);
useEffect(() => {
if (!isMacClient) return;
let cancelled = false;
isFullscreen().then((value) => {
if (!cancelled) setIsWindowFullscreen(!!value);
});
const unsubscribe = onFullscreenChanged((value) => setIsWindowFullscreen(!!value));
return () => {
cancelled = true;
unsubscribe();
};
}, [isFullscreen, isMacClient, onFullscreenChanged]);
// Refs for scrollable tab container
const tabsContainerRef = useRef<HTMLDivElement>(null);
@@ -512,7 +526,7 @@ const TopTabsInner: React.FC<TopTabsProps> = ({
<div className="absolute inset-x-0 top-0 h-3 app-drag pointer-events-auto z-10" style={dragRegionStyle} aria-hidden />
<div
className="h-10 px-3 flex items-center gap-2 app-drag"
style={{ ...dragRegionStyle, paddingLeft: isMacClient ? 76 : 12 }}
style={{ ...dragRegionStyle, paddingLeft: isMacClient && !isWindowFullscreen ? 76 : 12 }}
>
{/* Fixed left tabs: Vaults and SFTP */}
<div className="flex items-center gap-2 flex-shrink-0 app-drag">
+24
View File
@@ -323,6 +323,14 @@ async function createWindow(electronModule, options) {
mainWindow = win;
win.on("enter-full-screen", () => {
win.webContents?.send("netcatty:window:fullscreen-changed", true);
});
win.on("leave-full-screen", () => {
win.webContents?.send("netcatty:window:fullscreen-changed", false);
});
// Ensure native background matches frontend background, even before first paint.
try {
win.setBackgroundColor(backgroundColor);
@@ -399,6 +407,14 @@ async function openSettingsWindow(electronModule, options) {
settingsWindow = win;
win.on("enter-full-screen", () => {
win.webContents?.send("netcatty:window:fullscreen-changed", true);
});
win.on("leave-full-screen", () => {
win.webContents?.send("netcatty:window:fullscreen-changed", false);
});
// Ensure native background matches frontend background, even before first paint.
try {
win.setBackgroundColor(backgroundColor);
@@ -497,6 +513,14 @@ function registerWindowHandlers(ipcMain, nativeTheme) {
return false;
});
ipcMain.handle("netcatty:window:isFullscreen", (event) => {
const win = getWindowForIpcEvent(event);
if (win && !win.isDestroyed()) {
return win.isFullScreen();
}
return false;
});
ipcMain.handle("netcatty:setTheme", (_event, theme) => {
currentTheme = theme;
nativeTheme.themeSource = theme;
+16
View File
@@ -8,6 +8,7 @@ const transferErrorListeners = new Map();
const chainProgressListeners = new Map();
const authFailedListeners = new Map();
const languageChangeListeners = new Set();
const fullscreenChangeListeners = new Set();
ipcRenderer.on("netcatty:data", (_event, payload) => {
const set = dataListeners.get(payload.sessionId);
@@ -59,6 +60,16 @@ ipcRenderer.on("netcatty:languageChanged", (_event, language) => {
});
});
ipcRenderer.on("netcatty:window:fullscreen-changed", (_event, isFullscreen) => {
fullscreenChangeListeners.forEach((cb) => {
try {
cb(isFullscreen);
} catch (err) {
console.error("Fullscreen changed callback failed", err);
}
});
});
// Authentication failed events
@@ -343,6 +354,11 @@ const api = {
windowMaximize: () => ipcRenderer.invoke("netcatty:window:maximize"),
windowClose: () => ipcRenderer.invoke("netcatty:window:close"),
windowIsMaximized: () => ipcRenderer.invoke("netcatty:window:isMaximized"),
windowIsFullscreen: () => ipcRenderer.invoke("netcatty:window:isFullscreen"),
onWindowFullScreenChanged: (cb) => {
fullscreenChangeListeners.add(cb);
return () => fullscreenChangeListeners.delete(cb);
},
// Settings window
openSettingsWindow: () => ipcRenderer.invoke("netcatty:settings:open"),
Vendored
+2
View File
@@ -227,6 +227,8 @@ interface NetcattyBridge {
windowMaximize?(): Promise<boolean>;
windowClose?(): Promise<void>;
windowIsMaximized?(): Promise<boolean>;
windowIsFullscreen?(): Promise<boolean>;
onWindowFullScreenChanged?(cb: (isFullscreen: boolean) => void): () => void;
// Settings window
openSettingsWindow?(): Promise<boolean>;
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 111 KiB

+38 -1
View File
@@ -1 +1,38 @@
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 56'><rect x='0' y='0' width='56' height='56' rx='12' fill='#2463EB'/><rect x='10' y='13' width='36' height='24' rx='4' fill='white'/><rect x='10' y='13' width='36' height='5' rx='4' fill='#E5ECFF'/><circle cx='14' cy='15.5' r='1' fill='#2463EB'/><circle cx='18' cy='15.5' r='1' fill='#2463EB' opacity='0.7'/><circle cx='22' cy='15.5' r='1' fill='#2463EB' opacity='0.5'/><path d='M16 28 L20 26 L16 24' stroke='#2463EB' fill='none' stroke-width='1.6'/><path d='M24 30 H30' stroke='#2463EB' stroke-width='1.6'/><path d='M20 13 L22 8 L24 13Z' fill='white'/><path d='M32 13 L34 8 L36 13Z' fill='white'/><path d='M36 33 C40 36,42 38,42 42 C42 45,40 47,37 47' stroke='white' fill='none' stroke-width='3.2'/><rect x='34' y='44' width='6' height='5' rx='1' fill='white' stroke='#2463EB'/></svg>
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 56'>
<defs>
<linearGradient id='bg' x1='8' y1='6' x2='46' y2='50' gradientUnits='userSpaceOnUse'>
<stop stop-color='#2F7BFF'/>
<stop offset='1' stop-color='#1C4CCB'/>
</linearGradient>
<linearGradient id='bg-glow' x1='28' y1='4' x2='28' y2='30' gradientUnits='userSpaceOnUse'>
<stop stop-color='white' stop-opacity='0.28'/>
<stop offset='1' stop-color='white' stop-opacity='0'/>
</linearGradient>
<linearGradient id='screen' x1='10' y1='13' x2='46' y2='37' gradientUnits='userSpaceOnUse'>
<stop stop-color='white'/>
<stop offset='1' stop-color='#EEF3FF'/>
</linearGradient>
<linearGradient id='header' x1='10' y1='13' x2='46' y2='18' gradientUnits='userSpaceOnUse'>
<stop stop-color='#F1F5FF'/>
<stop offset='1' stop-color='#D9E4FF'/>
</linearGradient>
<filter id='panel-shadow' x='8' y='11' width='40' height='28' filterUnits='userSpaceOnUse'>
<feDropShadow dx='0' dy='2' stdDeviation='2' flood-color='#0B2D7A' flood-opacity='0.18'/>
</filter>
</defs>
<rect x='0' y='0' width='56' height='56' rx='12' fill='url(#bg)'/>
<rect x='0' y='0' width='56' height='32' rx='12' fill='url(#bg-glow)'/>
<g filter='url(#panel-shadow)'>
<rect x='10' y='13' width='36' height='24' rx='4' fill='url(#screen)' stroke='#1D4FCF' stroke-opacity='0.1'/>
</g>
<rect x='10' y='13' width='36' height='5' rx='4' fill='url(#header)'/>
<circle cx='14' cy='15.5' r='1' fill='#1E4FD1'/>
<circle cx='18' cy='15.5' r='1' fill='#1E4FD1' opacity='0.7'/>
<circle cx='22' cy='15.5' r='1' fill='#1E4FD1' opacity='0.5'/>
<path d='M16 28 L20 26 L16 24' stroke='#1E4FD1' fill='none' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/>
<path d='M24 30 H30' stroke='#1E4FD1' stroke-width='1.6' stroke-linecap='round'/>
<path d='M20 13 L22 8 L24 13Z' fill='white' opacity='0.9'/>
<path d='M32 13 L34 8 L36 13Z' fill='white' opacity='0.9'/>
<path d='M36 33 C40 36,42 38,42 42 C42 45,40 47,37 47' stroke='white' fill='none' stroke-width='3.2' stroke-linecap='round'/>
<rect x='34' y='44' width='6' height='5' rx='1' fill='white' stroke='#1E4FD1'/>
</svg>

Before

Width:  |  Height:  |  Size: 842 B

After

Width:  |  Height:  |  Size: 2.2 KiB