From 487902141a4b82da0481afa8aec32942ca2927f5 Mon Sep 17 00:00:00 2001 From: Fox_block Date: Tue, 27 Jan 2026 10:05:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E8=BE=93=E5=85=A5=E6=96=87=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/main/index.ts | 69 +------ src/main/services/SettingsService.ts | 23 +-- src/main/services/TrayService.ts | 26 --- src/main/services/WindowManager.ts | 24 +-- src/renderer/src/App.tsx | 2 - src/renderer/src/assets/main.css | 67 ------- src/renderer/src/components/GlobalSidebar.tsx | 188 ------------------ src/renderer/src/components/Settings.tsx | 8 +- themes/custom.json | 31 --- 10 files changed, 14 insertions(+), 426 deletions(-) delete mode 100644 src/renderer/src/components/GlobalSidebar.tsx delete mode 100644 themes/custom.json diff --git a/package.json b/package.json index f678115..7c1a82e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "secscore", - "version": "1.0.1", + "version": "1.0.0", "description": "SecScore – Your Education Points Management Expert", "main": "./out/main/index.js", "author": "example.com", diff --git a/src/main/index.ts b/src/main/index.ts index c20b488..55ac2fa 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -87,7 +87,6 @@ const handleProtocolUrl = (rawUrl: string, ctx: MainContext) => { } const parts = s.split('/') const head = parts[0]?.toLowerCase() ?? '' - const tail = parts.slice(1) if (!head) { openMainRoute(ctx, '/') return @@ -120,58 +119,6 @@ const handleProtocolUrl = (rawUrl: string, ctx: MainContext) => { openMainRoute(ctx, '/settings') return } - if (head === 'sidebar') { - const action = tail[0]?.toLowerCase() ?? 'toggle' - const sidebarWin = ctx.windows.get('global-sidebar') - if (action === 'show') { - if (sidebarWin) { - sidebarWin.show() - sidebarWin.focus() - } else { - ctx.windows.open({ - key: 'global-sidebar', - title: 'SecScore Sidebar', - route: '/global-sidebar', - options: { - transparent: true, - alwaysOnTop: true, - hasShadow: false, - type: 'toolbar' - } - }) - } - return - } - if (action === 'hide') { - if (sidebarWin) { - sidebarWin.hide() - } - return - } - if (action === 'toggle') { - if (sidebarWin) { - if (sidebarWin.isVisible()) { - sidebarWin.hide() - } else { - sidebarWin.show() - sidebarWin.focus() - } - } else { - ctx.windows.open({ - key: 'global-sidebar', - title: 'SecScore Sidebar', - route: '/global-sidebar', - options: { - transparent: true, - alwaysOnTop: true, - hasShadow: false, - type: 'toolbar' - } - }) - } - return - } - } } const hasSingleInstanceLock = app.requestSingleInstanceLock() @@ -307,7 +254,6 @@ app.whenReady().then(async () => { }) .configure(async (_builderContext, appCtx) => { const services = appCtx.services - const ctx = services.get(MainContext) services.get(LoggerToken) const db = services.get(DbManagerToken) as DbManager await db.initialize() @@ -325,19 +271,6 @@ app.whenReady().then(async () => { services.get(WindowManagerToken) const tray = services.get(TrayServiceToken) as TrayService tray.initialize() - - // Open Global Sidebar on startup - ctx.windows.open({ - key: 'global-sidebar', - title: 'SecScore Sidebar', - route: '/global-sidebar', - options: { - transparent: true, - alwaysOnTop: true, - hasShadow: false, - type: 'toolbar' - } - }) }) const host = await builder.build() @@ -366,6 +299,8 @@ app.whenReady().then(async () => { if (pendingProtocolUrl) { handleProtocolUrl(pendingProtocolUrl, ctx) pendingProtocolUrl = null + } else { + openMainRoute(ctx, '/') } let disposing = false diff --git a/src/main/services/SettingsService.ts b/src/main/services/SettingsService.ts index 0ee83ff..f344246 100644 --- a/src/main/services/SettingsService.ts +++ b/src/main/services/SettingsService.ts @@ -1,6 +1,6 @@ import { Service } from '../../shared/kernel' import { MainContext } from '../context' -import { BrowserWindow, webContents, screen } from 'electron' +import { BrowserWindow, webContents } from 'electron' import type { IpcMainInvokeEvent } from 'electron' import type { settingsKey, settingsSpec, settingChange } from '../../preload/types' import type { permissionLevel } from './PermissionService' @@ -58,27 +58,6 @@ export class SettingsService extends Service { webContents.getAllWebContents().forEach((wc: any) => { wc.setZoomFactor(zoom) }) - - const sidebarWindow = BrowserWindow.getAllWindows().find((win) => { - try { - return win.webContents.getURL().includes('#global-sidebar') - } catch { - return false - } - }) - - if (sidebarWindow && !sidebarWindow.isDestroyed()) { - const primaryDisplay = screen.getPrimaryDisplay() - const { width, height } = primaryDisplay.workAreaSize - const bounds = sidebarWindow.getBounds() - - sidebarWindow.setBounds({ - x: width - bounds.width, - y: Math.floor(height / 2 - bounds.height / 2), - width: bounds.width, - height: bounds.height - }) - } } }, window_theme: { diff --git a/src/main/services/TrayService.ts b/src/main/services/TrayService.ts index ed53140..66ed34c 100644 --- a/src/main/services/TrayService.ts +++ b/src/main/services/TrayService.ts @@ -28,32 +28,6 @@ export class TrayService extends Service { this.showMainWindow() } }, - { - label: '显隐悬浮侧边栏', - click: () => { - const sidebarWin = this.mainCtx.windows.get('global-sidebar') - if (sidebarWin) { - if (sidebarWin.isVisible()) { - sidebarWin.hide() - } else { - sidebarWin.show() - sidebarWin.focus() - } - } else { - this.mainCtx.windows.open({ - key: 'global-sidebar', - title: 'SecScore Sidebar', - route: '/global-sidebar', - options: { - transparent: true, - alwaysOnTop: true, - hasShadow: false, - type: 'toolbar' - } - }) - } - } - }, { type: 'separator' }, { label: '关闭应用', diff --git a/src/main/services/WindowManager.ts b/src/main/services/WindowManager.ts index b626616..3f2dacb 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, screen } from 'electron' +import { BrowserWindow, shell } from 'electron' import type { BrowserWindowConstructorOptions } from 'electron' let micaElectron: typeof import('mica-electron') | null = null @@ -117,24 +117,6 @@ export class WindowManager extends Service { win = new BrowserWindow(baseOptions) } - // Special positioning for global sidebar - if (input.key === 'global-sidebar') { - const primaryDisplay = screen.getPrimaryDisplay() - const { width, height } = primaryDisplay.workAreaSize - const winWidth = 84 - const winHeight = 300 - win.setBounds({ - x: width - winWidth, - y: Math.floor(height / 2 - winHeight / 2), - width: winWidth, - height: winHeight - }) - win.setAlwaysOnTop(true, 'screen-saver') - win.setVisibleOnAllWorkspaces(true) - win.setSkipTaskbar(true) - win.setResizable(false) - } - const zoomSettings = this.mainCtx.settings const zoom = zoomSettings ? Number(zoomSettings.getValue('window_zoom')) || 1.0 : 1.0 win.webContents.setZoomFactor(zoom) @@ -165,13 +147,13 @@ export class WindowManager extends Service { }) win.on('blur', () => { - if (input.key === 'global-sidebar' || input.key === 'main') { + if (input.key === 'main') { this.applyMicaEffect(win) } }) win.on('focus', () => { - if (input.key === 'global-sidebar' || input.key === 'main') { + if (input.key === 'main') { this.applyMicaEffect(win) } }) diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index e6a860e..c272ef5 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -6,7 +6,6 @@ import { ContentArea } from './components/ContentArea' import { Wizard } from './components/Wizard' import { ThemeProvider } from './contexts/ThemeContext' import { ThemeEditorProvider } from './contexts/ThemeEditorContext' -import { GlobalSidebar } from './components/GlobalSidebar' import { ThemeEditor } from './components/ThemeEditor' function MainContent(): React.JSX.Element { @@ -148,7 +147,6 @@ function App(): React.JSX.Element { - } /> } /> diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css index 4ac71f1..c9a6eea 100644 --- a/src/renderer/src/assets/main.css +++ b/src/renderer/src/assets/main.css @@ -105,70 +105,3 @@ html[theme-mode='dark'] .ss-sidebar .t-menu__item.t-is-active svg:not([fill='non text-align: center; justify-content: center; } - -/* Global Sidebar Toggle Button */ -.global-sidebar-toggle { - width: 100vw; - height: 100vh; - background-color: var(--ss-bg-color); - border-radius: 0px 0 0 0px; - display: flex; - align-items: center; - justify-content: center; - cursor: pointer; - box-shadow: -2px 0 8px rgba(0,0,0,0.1); - border: 1px solid var(--ss-border-color); - border-right: none; - color: var(--ss-text-main); - z-index: 10; - flex-shrink: 0; - animation: twinkle-animation 3s infinite ease-in-out; - transition: opacity 0.07s ease, transform 0.15s ease; -} - -.global-sidebar-toggle.hidden { - opacity: 0; - pointer-events: none; - transform: translateX(10px); -} - -.sidebar-content-area { - display: flex; - flex-direction: column; - background-color: var(--ss-card-bg); - border-radius: 12px 0 0 12px; - box-shadow: -4px 0 16px rgba(0,0,0,0.15); - border: 1px solid var(--ss-border-color); - border-right: none; - padding: 12px 8px; - gap: 12px; - width: 60px; - transition: opacity 0.1s ease, transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1); - backface-visibility: hidden; - transform: translateZ(0); - contain: paint; /* 性能优化:限制重绘范围 */ -} - -.sidebar-content-area.hidden { - opacity: 0; - pointer-events: none; - transform: translateX(20px); -} - -.sidebar-content-area.visible { - opacity: 1; - pointer-events: auto; - transform: translateX(0); -} - -@keyframes twinkle-animation { - 0%, 100% { - box-shadow: -2px 0 8px rgba(0,0,0,0.1); - filter: brightness(1); - } - 50% { - box-shadow: -4px 0 12px var(--td-brand-color-light), 0 0 15px var(--td-brand-color-focus); - filter: brightness(1.2); - color: var(--td-brand-color); - } -} diff --git a/src/renderer/src/components/GlobalSidebar.tsx b/src/renderer/src/components/GlobalSidebar.tsx deleted file mode 100644 index c8fa6d1..0000000 --- a/src/renderer/src/components/GlobalSidebar.tsx +++ /dev/null @@ -1,188 +0,0 @@ -import React, { useState, useEffect } from 'react' -import { Button, Tooltip } from 'tdesign-react' -import { - HomeIcon, - ViewListIcon, - UserAddIcon, - ChevronRightIcon, - ChevronLeftIcon, - SettingIcon, - CodeIcon -} from 'tdesign-icons-react' - -export const GlobalSidebar: React.FC = () => { - const [expanded, setExpanded] = useState(false) - const [showToggle, setShowToggle] = useState(true) - const [zoom, setZoom] = useState(1.0) - - useEffect(() => { - if (!(window as any).api) return - - // 加载初始缩放值 - const loadZoom = async () => { - const res = await (window as any).api.getSetting('window_zoom') - if (res.success && res.data) { - setZoom(res.data) - } - } - loadZoom() - - // 监听缩放变化 - const unsubscribe = (window as any).api.onSettingChanged((change: any) => { - if (change?.key === 'window_zoom') { - setZoom(change.value) - // 缩放变化时,重新应用当前展开/收缩状态的窗口大小 - if ((window as any).api) { - if (expanded) { - const width = Math.round(84 * change.value) - const height = Math.round(300 * change.value) - ;(window as any).api.windowResize(width, height) - } else { - const width = Math.round(24 * change.value) - const height = Math.round(300 * change.value) - ;(window as any).api.windowResize(width, height) - } - } - } - }) - - return () => { - if (typeof unsubscribe === 'function') unsubscribe() - } - }, [expanded]) - - const handleExpand = () => { - // 1. 先隐藏三角 - setShowToggle(false) - - // 2. 稍后扩大窗口 - setTimeout(() => { - if ((window as any).api) { - const width = Math.round(60 * zoom) - const height = Math.round(300 * zoom) - ;(window as any).api.windowResize(width, height) - } - // 3. 最后显示侧边栏内容 - setTimeout(() => { - setExpanded(true) - }, 20) - }, 100) - } - - const handleCollapse = () => { - // 1. 先隐藏侧边栏内容 - setExpanded(false) - - // 2. 稍后缩小窗口 - setTimeout(() => { - if ((window as any).api) { - const width = Math.round(24 * zoom) - const height = Math.round(58 * zoom) - ;(window as any).api.windowResize(width, height) - } - // 3. 最后重新显示三角(等待透明度动画完成) - setTimeout(() => { - setShowToggle(true) - }, 150) - }, 150) - } - - const openMain = () => { - if (!(window as any).api) return - ;(window as any).api.openWindow({ key: 'main', route: '/' }) - } - - return ( -
- {/* 日常展示的三角 */} - - - {/* 侧边栏内容 */} -
- {/* 顶部的关闭/收起按钮 */} - - - - - - - - - - - - - - - - - - - {import.meta.env.DEV && ( - - - - )} -
-
- ) -} diff --git a/src/renderer/src/components/Settings.tsx b/src/renderer/src/components/Settings.tsx index 03a79fb..9dec42a 100644 --- a/src/renderer/src/components/Settings.tsx +++ b/src/renderer/src/components/Settings.tsx @@ -543,7 +543,13 @@ export const Settings: React.FC<{ permission: permissionLevel }> = ({ permission URL 协议 (secscore://) -
+
可以通过 URL 链接唤起 SecScore 并执行操作,例如: