diff --git a/app/main.js b/app/main.js index 7f4ca0087532e4b95f94a853feb7445060d8d0e1..13feeeb376ea04234b014586b86f882deeed93d5 100644 --- a/app/main.js +++ b/app/main.js @@ -2,7 +2,7 @@ * @Author: wuruipeng * @Date: 2024-03-06 17:39:06 * @LastEditors: wuruipeng - * @LastEditTime: 2024-04-26 14:37:53 + * @LastEditTime: 2024-05-09 17:55:48 * @description: 主进程配置 */ @@ -35,6 +35,9 @@ function initApp(rootPath) { mainWindow.on('close', event => { confirmExit(event) }) + // 解决初次拖拽窗口尺寸变化问题,手动初始化改变一下size + const mainWindowSize = mainWindow.getSize() + mainWindow.setSize(mainWindowSize[0] - 1, mainWindowSize[1] - 2) } // 应用加载完成配置 app.whenReady().then(() => { diff --git a/app/render/preload.js b/app/render/preload.js index 84bffeb729380c41edad0e0005201fc01f9ab1ca..1f23dd85c75865df04f23a42af1c883f4a915756 100644 --- a/app/render/preload.js +++ b/app/render/preload.js @@ -2,11 +2,11 @@ * @Author: wuruipeng * @Date: 2024-04-08 09:55:51 * @LastEditors: wuruipeng - * @LastEditTime: 2024-04-28 10:06:26 + * @LastEditTime: 2024-05-09 16:41:58 * @description: 渲染进程预加载脚本(用于搭建传递主进程与渲染进程的属性使用和方法) */ -const { app, contextBridge, ipcRenderer } = require('electron') +const { contextBridge, ipcRenderer } = require('electron') const common = require('../utils/common.js') // 可发送通信消息至主进程控制调用 diff --git a/package.json b/package.json index 806d29b0853afeaa404289f1dd43796a41e537b4..967c3437ef65ca231522e721e27b77facef8e288 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "WuRuipeng", "license": "ISC", - "name": "MTLH", + "name": "mantianliuhuo", "version": "1.0.0", "description": "electron-project", "main": "app/main.js", diff --git a/src/components/TitleBar.tsx b/src/components/TitleBar.tsx index faa67488e7a8f555c0740027eceeafc01d28a37d..6893802d7dd1aa957612abe0e60fb4083d489165 100644 --- a/src/components/TitleBar.tsx +++ b/src/components/TitleBar.tsx @@ -2,12 +2,12 @@ * @Author: wuruipeng * @Date: 2024-04-25 14:07:08 * @LastEditors: wuruipeng - * @LastEditTime: 2024-04-30 17:21:14 + * @LastEditTime: 2024-05-09 17:07:05 * @description:自定义应用操作栏组件 */ import React, { ReactElement } from 'react' -import { useEffect, useState } from 'react' +import { useEffect, useState, useRef } from 'react' import '@/styles/components/TitleBar.less' import { keyboardKey } from '@testing-library/user-event' @@ -38,6 +38,7 @@ const TitleBar: React.FC = () => { { context: '◻', role: 'maximize' }, { context: '×', role: 'close' } ]) + const titleBarRef = useRef(null) // 更新应用当前信息和状态 const updateAppInfo = (): void => { ;(window as any).resultAPI.invoke('get-app-info') @@ -118,9 +119,8 @@ const TitleBar: React.FC = () => { // 更改全屏状态操作 const changeFullScreen = (status: boolean): void => { // 如果为全屏状态,应隐藏边框和操作栏 - const titleBar: TitleBarType = document.getElementById('title-bar') const app: TitleBarType = document.getElementById('app') - if (!titleBar || !app) return + if (!titleBarRef.current || !app) return // 获取根元素(:root)并修改CSS变量 const _root = document.documentElement if (status) { @@ -155,12 +155,12 @@ const TitleBar: React.FC = () => { } }, []) return ( -
-
+
+
-
-
+
+
    {controls.map((item, index) => (
  • { ))}
-
+
    {menus?.map((item, index) => (