diff --git a/src/main/index.ts b/src/main/index.ts index 2c13ac6..eb78310 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -6,7 +6,7 @@ import { electronApp, optimizer, is } from '@electron-toolkit/utils' import icon from '../../resources/SecScore_logo.ico?asset' import { MainContext } from './context' import { DbManager } from './db/DbManager' -import { LoggerService, logLevel } from './services/LoggerService' +import { LoggerService } from './services/LoggerService' import { SettingsService } from './services/SettingsService' import { SecurityService } from './services/SecurityService' import { PermissionService } from './services/PermissionService' diff --git a/src/main/services/WindowManager.ts b/src/main/services/WindowManager.ts index 779562b..bb4ffeb 100644 --- a/src/main/services/WindowManager.ts +++ b/src/main/services/WindowManager.ts @@ -1,6 +1,6 @@ import { Service } from '../../shared/kernel' import { MainContext } from '../context' -import { BrowserWindow, shell } from 'electron' +import { BrowserWindow, shell, screen } from 'electron' import type { BrowserWindowConstructorOptions } from 'electron' export type windowOpenInput = { @@ -77,7 +77,6 @@ export class WindowManager extends Service { // Special positioning for global sidebar if (input.key === 'global-sidebar') { - const { screen } = require('electron') const primaryDisplay = screen.getPrimaryDisplay() const { width, height } = primaryDisplay.workAreaSize const winWidth = 84 diff --git a/src/renderer/src/components/GlobalSidebar.tsx b/src/renderer/src/components/GlobalSidebar.tsx index d7bc00d..27b9fc1 100644 --- a/src/renderer/src/components/GlobalSidebar.tsx +++ b/src/renderer/src/components/GlobalSidebar.tsx @@ -1,10 +1,10 @@ -import React, { useState, useEffect } from 'react' +import React, { useState } from 'react' import { Button, Tooltip } from 'tdesign-react' -import { - HomeIcon, - ViewListIcon, - UserAddIcon, - ChevronRightIcon, +import { + HomeIcon, + ViewListIcon, + UserAddIcon, + ChevronRightIcon, ChevronLeftIcon, SettingIcon } from 'tdesign-icons-react' @@ -12,15 +12,15 @@ import { export const GlobalSidebar: React.FC = () => { const [expanded, setExpanded] = useState(false) const [showToggle, setShowToggle] = useState(true) - + const handleExpand = () => { // 1. 先隐藏三角 setShowToggle(false) - + // 2. 稍后扩大窗口 setTimeout(() => { if ((window as any).api) { - (window as any).api.windowResize(84, 300) + ;(window as any).api.windowResize(84, 300) } // 3. 最后显示侧边栏内容 setTimeout(() => { @@ -32,11 +32,11 @@ export const GlobalSidebar: React.FC = () => { const handleCollapse = () => { // 1. 先隐藏侧边栏内容 setExpanded(false) - + // 2. 稍后缩小窗口 setTimeout(() => { if ((window as any).api) { - (window as any).api.windowResize(24, 300) + ;(window as any).api.windowResize(24, 300) } // 3. 最后重新显示三角(等待透明度动画完成) setTimeout(() => { @@ -47,11 +47,11 @@ export const GlobalSidebar: React.FC = () => { const openMain = () => { if (!(window as any).api) return - (window as any).api.openWindow({ key: 'main', route: '/' }) + ;(window as any).api.openWindow({ key: 'main', route: '/' }) } return ( -