当前位置: 首页 > news >正文

公司做网站的 oa办公系统贵州萝岗seo整站优化

公司做网站的 oa办公系统,贵州萝岗seo整站优化,做湲兔费网站视颍,广西免费网站制作最近使用了electron框架,发现如果自定义拖动是比较实用的;特别是定制化比较高的项目,如果单纯的使用-webkit-app-region: drag;会让鼠标事件无法触发; 过程中发现问题: 1.windows缩放不是100%后设置偏移界面会缩放,感觉像吹起的气…

最近使用了electron框架,发现如果自定义拖动是比较实用的;特别是定制化比较高的项目,如果单纯的使用-webkit-app-region: drag;会让鼠标事件无法触发;

过程中发现问题:

1.windows缩放不是100%后设置偏移界面会缩放,感觉像吹起的气球;

2.单纯的添加css;-webkit-app-region: drag; 会让鼠标事件无法触发;

封装核心方法
import { screen  } from 'electron'
/* 自定义窗口移动 */
export class AzCustomWindowMove {// 是否开启isOpen: boolean;// 传入要处理的窗口win: any;// 窗口偏移winStartPosition: {x: number, y: number, width: number, height: number,}// 现在鼠标所在位置startPosition: {x: number, y: number,}constructor() {this.isOpen = false;this.win = null;this.winStartPosition = {x: 0,y: 0,width: 0,height: 0,}this.startPosition = {x: 0,y: 0,}}init(win: any) {this.win = win;}start() {this.isOpen = true;// 获取当前窗口偏移[x, y]const winPosition = this.win.getPosition();// 获取当前缩放[width, height]const winSize = this.win.getSize();this.winStartPosition.x = winPosition[0];this.winStartPosition.y = winPosition[1];this.winStartPosition.width = winSize[0];this.winStartPosition.height = winSize[1];// 获取鼠标绝对位置const mouseStartPosition = screen.getCursorScreenPoint();this.startPosition.x = mouseStartPosition.x;this.startPosition.y = mouseStartPosition.y;// 开启刷新this.move();}move() {if (!this.isOpen) {return;};console.log('this.win.isDestroyed()', this.win.isDestroyed(), this.win.isFocused());// 如果窗口已销毁if (this.win.isDestroyed()) {this.end();return;}// 判断窗口是否聚焦if (!this.win.isFocused()) {this.end();return;}const cursorPosition = screen.getCursorScreenPoint();const x = this.winStartPosition.x + cursorPosition.x - this.startPosition.x;const y = this.winStartPosition.y + cursorPosition.y - this.startPosition.y;// this.win.setPosition(120, 120, false);// this.win.setBounds({x: 120, y: 120})// 更新位置的同时设置窗口原大小, windows上设置=>显示设置=>文本缩放 不是100%时,窗口会拖拽放大this.win.setBounds({x: x,y: y,width: this.winStartPosition.width,height: this.winStartPosition.height,})setTimeout(() => {this.move();}, 20)}end() {this.isOpen = false;}
}
在main.js中引入
import { AzCustomWindowMove } from './util';/* new 自定义窗口移动 */
const CustomWindowMove = new AzCustomWindowMove();// 创建一个窗口
const mainWindow = new BrowserWindow({frame: false,webPreferences: {preload: join(__dirname, '../preload/index.js'),sandbox: false}
})// 将窗口传进去
CustomWindowMove.init(mainWindow)// 通信监听
ipcMain.on("Main_Window_Operate", (event, info) => {    const operateEvent = info.event || '';switch(operateEvent) {// 拖拽窗口-开始case 'homeDragWindowStart':{/*如果别的窗口也想复用这个自定义拖拽方法可以这么用;const webContents = event.sender;const win = BrowserWindow.fromWebContents(webContents);CustomWindowMove.init(win);CustomWindowMove.start();*/CustomWindowMove.start();}break;// 拖拽窗口-结束case 'homeDragWindowEnd':{CustomWindowMove.end();}break;default:break;}})
preload.ts 预加载脚本
import { contextBridge, ipcRenderer } from 'electron'
import { electronAPI } from '@electron-toolkit/preload'
...contextBridge.exposeInMainWorld('customAPI', {/***  发布main窗口操作消息* @param info {type: 操作类型, data: 参数}*/publishMainWindowOperateMessage: (info: {event: string, data: {}}) => {ipcRenderer.send("Main_Window_Operate", info);} 
})
...
React绑定事件
 const handleMouseDown = (e) => {(window as any).customAPI.publishMainWindowOperateMessage({event: 'homeDragWindowStart'});
}
const handleMouseUp = (e) => {(window as any).customAPI.publishMainWindowOperateMessage({event: 'homeDragWindowEnd'});
}
/*第二个思路, 当按下后监听document的事件*/
const handleMouseDown = (e) => {// 通知开始(window as any).customAPI.publishMainWindowOperateMessage({event: 'homeDragWindowStart'});// 鼠标抬起document.onmouseup = function () {document.onmousemove = null;document.onmouseup = null;document.onselectstart = null;// 通知结束(window as any).customAPI.publishMainWindowOperateMessage({event: 'homeDragWindowEnd'});}
}
<divonMouseDown={handleMouseDown} onMouseUp={handleMouseUp} 
>自定义窗口移动</div>
http://www.zhongyajixie.com/news/25652.html

相关文章:

  • 仿网站制作教学视频教程百度站长中心
  • 唐河网站建设seo的搜索排名影响因素主要有
  • 做公司网站公司多少钱设计培训班学费一般多少
  • 视频网站建设 方案上海网站seo外包
  • 网站建设与开发论文免费搜索引擎入口
  • 网站设计与制作一般步骤百度搜索图片
  • 如何让做的网站自动适应浏览器武汉seo网站优化技巧
  • 美女图片网站源码商业版本带数据全站生成html_带采集功能天津关键词优化平台
  • 北京做网站优化网站在线客服系统免费
  • 青岛做网站的如何进行网站制作
  • 山东网站建设.com怎么优化标题和关键词排名
  • 政府网站建设栏目情况肇庆seo优化
  • 推广方法有哪些技巧seo搜索优化费用
  • 做网站和论坛区别网站策划书
  • 信息最全的网站sem网络推广公司
  • 引流效果最好的平台seo网站分析工具
  • 他人委托我做网站抖音seo优化排名
  • dw怎么做phpcms网站教育机构培训
  • 重庆黔江做防溺水的网站seo专业培训中心
  • 广州网站建设好做吗谷歌搜索排名规则
  • 制作网站教学项目网站
  • 所有做运动的网站如何网站关键词优化
  • 精通网站建设 100seo怎么读
  • 做一些网站的弹出页面百度网页版链接
  • 几何图形生成网站软件注册推广平台
  • 免费模板网站下载国际军事新闻
  • 苏州设置网站建设怎么申请网站空间
  • 山东圣大建设集团网站引流推广怎么做
  • 手机数据线东莞网站建设地推的方法和技巧
  • 怎么做类似淘宝的网站链接平台