electron-drag-plus 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
  - **极简 API**:主进程仅需一个方法,渲染进程仅需两个方法
8
8
  - **窗口防抖**:内置窗口拖拽时的防抖优化,解决拖拽时窗口大小抖动问题
9
- - **多窗口支持**:通过 key 参数支持多窗口场景
10
9
  - **自动处理**:自动识别并排除交互元素,避免交互冲突
11
10
  - **TypeScript 支持**:提供完整的类型定义
11
+ - **安全可靠**:内置错误处理和延迟初始化,确保在各种环境下稳定运行
12
12
 
13
13
  ## 安装
14
14
 
@@ -27,13 +27,12 @@ pnpm add electron-drag-plus
27
27
 
28
28
  ### 主进程 API
29
29
 
30
- #### `initializeDragPlus(window, key)`
30
+ #### `initializeDragPlus(window)`
31
31
 
32
32
  初始化窗口拖拽功能。
33
33
 
34
34
  **参数:**
35
35
  - `window: BrowserWindow` - Electron 窗口实例
36
- - `key: string` - 窗口唯一标识,用于与渲染进程通信
37
36
 
38
37
  **示例:**
39
38
  ```typescript
@@ -52,31 +51,30 @@ const mainWindow = new BrowserWindow({
52
51
  }
53
52
  });
54
53
 
55
- // 初始化拖拽功能
56
- initializeDragPlus(mainWindow, 'main-window');
54
+ // 初始化拖拽功能 - 无需key参数
55
+ initializeDragPlus(mainWindow);
57
56
  ```
58
57
 
59
58
  ### 渲染进程 API
60
59
 
61
- #### `enableWindowDrag(element, key?)`
60
+ #### `enableWindowDrag(element)`
62
61
 
63
62
  启用指定元素的窗口拖拽功能。
64
63
 
65
64
  **参数:**
66
65
  - `element: HTMLElement | string` - DOM 元素或 CSS 选择器
67
- - `key?: string` - 窗口唯一标识(可选,也可在主进程中初始化时提供)
68
66
 
69
67
  **示例:**
70
68
  ```typescript
71
69
  import { enableWindowDrag } from 'electron-drag-plus/renderer';
72
70
 
73
71
  // 使用 CSS 选择器
74
- enableWindowDrag('#title-bar', 'main-window');
72
+ enableWindowDrag('#title-bar');
75
73
 
76
74
  // 或使用 DOM 元素
77
75
  const titleBar = document.getElementById('title-bar');
78
76
  if (titleBar instanceof HTMLElement) {
79
- enableWindowDrag(titleBar, 'main-window');
77
+ enableWindowDrag(titleBar);
80
78
  }
81
79
  ```
82
80
 
@@ -119,8 +117,8 @@ function createWindow() {
119
117
  }
120
118
  });
121
119
 
122
- // 初始化拖拽功能
123
- initializeDragPlus(mainWindow, 'main-window');
120
+ // 初始化拖拽功能 - 简化版,无需key参数
121
+ initializeDragPlus(mainWindow);
124
122
 
125
123
  // 加载页面
126
124
  mainWindow.loadFile('index.html');
@@ -155,10 +153,10 @@ contextBridge.exposeInMainWorld('electron', {
155
153
  ```javascript
156
154
  import { enableWindowDrag, disableWindowDrag } from 'electron-drag-plus/renderer';
157
155
 
158
- // 启用标题栏拖拽功能
156
+ // 启用标题栏拖拽功能 - 简化版,无需key参数
159
157
  const titleBar = document.getElementById('title-bar');
160
158
  if (titleBar) {
161
- enableWindowDrag(titleBar, 'main-window');
159
+ enableWindowDrag(titleBar);
162
160
  }
163
161
 
164
162
  // 禁用控制按钮的拖拽
@@ -274,9 +272,9 @@ closeButton?.addEventListener('click', () => {
274
272
 
275
273
  3. **元素识别**:库会自动识别并排除常见的交互元素(如按钮、输入框等),避免交互冲突
276
274
 
277
- 4. **多窗口支持**:为不同窗口使用不同的 key 值,确保拖拽事件正确传递
275
+ 4. **错误处理**:库内置了基本的错误处理和日志警告,便于调试
278
276
 
279
- 5. **错误处理**:库内置了基本的错误处理和日志警告,便于调试
277
+ 5. **DOM 就绪**:库会自动检测 DOM 就绪状态,确保在合适的时机初始化
280
278
 
281
279
  ## 兼容性
282
280
 
package/dist/example.js CHANGED
@@ -2,38 +2,61 @@
2
2
  /**
3
3
  * electron-drag-plus 简化版API使用示例
4
4
  */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
5
8
  Object.defineProperty(exports, "__esModule", { value: true });
6
9
  // 主进程使用示例(main.js 或 main.ts)
7
10
  const electron_1 = require("electron");
8
- const index_1 = require("./index");
11
+ const index_1 = __importDefault(require("./index"));
9
12
  // 创建窗口
10
13
  const win = new electron_1.BrowserWindow({
11
14
  width: 800,
12
15
  height: 600,
13
- frame: false, // 无边框窗口
16
+ frame: false, // 无边框窗口通常需要自定义拖拽
14
17
  webPreferences: {
15
- nodeIntegration: true,
16
- contextIsolation: false
18
+ contextIsolation: false, // 确保能访问ipcRenderer
19
+ nodeIntegration: true
17
20
  }
18
21
  });
19
- // 初始化拖拽功能,使用唯一key关联
20
- (0, index_1.initializeDragPlus)(win, 'main-window-key');
22
+ // 初始化拖拽功能 - 只需传递窗口实例
23
+ (0, index_1.default)(win);
21
24
  // 加载页面
22
25
  win.loadFile('index.html');
23
26
  // 渲染进程使用示例(renderer.js 或 renderer.ts)
24
- const renderer_1 = require("./renderer");
25
- // 为标题栏启用拖拽功能,key应与主进程保持一致
26
- // 方法1:使用CSS选择器
27
- (0, renderer_1.enableWindowDrag)('#title-bar', 'main-window-key');
28
- // 方法2:使用DOM元素
29
- const titleBar = document.getElementById('title-bar');
30
- if (titleBar instanceof HTMLElement) {
31
- (0, renderer_1.enableWindowDrag)(titleBar, 'main-window-key');
32
- }
33
- // 禁用特定元素的拖拽
34
- const renderer_2 = require("./renderer");
35
- // 禁止按钮拖拽
36
- const closeButton = document.getElementById('close-button');
37
- if (closeButton instanceof HTMLElement) {
38
- (0, renderer_2.disableWindowDrag)(closeButton);
39
- }
27
+ // 在渲染进程文件中:
28
+ /*
29
+ import { enableWindowDrag, disableWindowDrag } from './renderer';
30
+
31
+ // DOM加载完成后调用
32
+ window.addEventListener('DOMContentLoaded', () => {
33
+ // 方式1:使用CSS选择器启用拖拽区域
34
+ enableWindowDrag('#title-bar');
35
+
36
+ // 方式2:直接传递DOM元素
37
+ const titleBar = document.getElementById('title-bar');
38
+ if (titleBar) {
39
+ enableWindowDrag(titleBar);
40
+ }
41
+
42
+ // 为按钮禁用拖拽,确保可以正常点击
43
+ const minimizeButton = document.getElementById('minimize-button');
44
+ const maximizeButton = document.getElementById('maximize-button');
45
+ const closeButton = document.getElementById('close-button');
46
+
47
+ if (minimizeButton) disableWindowDrag(minimizeButton);
48
+ if (maximizeButton) disableWindowDrag(maximizeButton);
49
+ if (closeButton) disableWindowDrag(closeButton);
50
+ });
51
+ */
52
+ // HTML示例
53
+ /*
54
+ <div id="title-bar" style="height: 30px; background: #333; color: white; display: flex; justify-content: space-between; align-items: center; padding: 0 10px;">
55
+ <div>窗口标题</div>
56
+ <div>
57
+ <button id="minimize-button">-</button>
58
+ <button id="maximize-button">□</button>
59
+ <button id="close-button">×</button>
60
+ </div>
61
+ </div>
62
+ */
package/dist/index.d.ts CHANGED
@@ -2,10 +2,6 @@ import { BrowserWindow } from 'electron';
2
2
  /**
3
3
  * 主进程初始化拖拽功能
4
4
  * @param win Electron窗口实例
5
- * @param key 唯一标识,用于关联主进程和渲染进程
6
5
  */
7
- export declare function initializeDragPlus(win: BrowserWindow, key: string): void;
8
- declare const _default: {
9
- initialize: typeof initializeDragPlus;
10
- };
11
- export default _default;
6
+ export declare function initializeDragPlus(win: BrowserWindow): void;
7
+ export default initializeDragPlus;
package/dist/index.js CHANGED
@@ -2,82 +2,71 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initializeDragPlus = initializeDragPlus;
4
4
  const electron_1 = require("electron");
5
- // 存储窗口实例和配置的Map
6
- const windowInstances = new Map();
5
+ // 存储当前拖拽的窗口实例
6
+ let currentWindow = null;
7
+ let dragData = null;
7
8
  /**
8
9
  * 主进程初始化拖拽功能
9
10
  * @param win Electron窗口实例
10
- * @param key 唯一标识,用于关联主进程和渲染进程
11
11
  */
12
- function initializeDragPlus(win, key) {
13
- if (!win || !key) {
14
- throw new Error('窗口实例和key不能为空');
12
+ function initializeDragPlus(win) {
13
+ if (!win) {
14
+ throw new Error('窗口实例不能为空');
15
15
  }
16
- const webContents = win.webContents;
17
- // 存储窗口实例
18
- windowInstances.set(key, { window: win, webContents });
19
- // 清理函数
20
- const cleanup = () => {
21
- windowInstances.delete(key);
22
- };
23
- // 监听窗口关闭事件进行清理
24
- win.on('closed', cleanup);
25
- // 发送key到渲染进程
26
- webContents.on('did-finish-load', () => {
27
- webContents.send('drag-plus:init', { key });
16
+ // 监听窗口关闭事件清理资源
17
+ win.on('closed', () => {
18
+ if (currentWindow === win) {
19
+ currentWindow = null;
20
+ dragData = null;
21
+ }
28
22
  });
29
23
  }
30
- // 处理拖拽事件
31
- electron_1.ipcMain.on('drag-plus:start', (event, { key, x, y }) => {
32
- const instance = windowInstances.get(key);
33
- if (!instance)
24
+ // 监听拖拽开始事件
25
+ electron_1.ipcMain.on('electron-drag:start', (event, { x, y }) => {
26
+ // 获取触发事件的窗口
27
+ const win = electron_1.BrowserWindow.fromWebContents(event.sender);
28
+ if (!win)
34
29
  return;
35
- const { window } = instance;
36
- const data = {
30
+ // 设置当前窗口和拖拽数据
31
+ currentWindow = win;
32
+ dragData = {
37
33
  isDragging: true,
38
34
  startX: x,
39
35
  startY: y,
40
- originalResizable: window.isResizable()
36
+ originalResizable: win.isResizable()
41
37
  };
42
- // 关联拖拽状态到窗口实例
43
- instance.dragData = data;
38
+ // 临时禁用窗口大小调整以优化拖拽体验
39
+ win.setResizable(false);
44
40
  });
45
- electron_1.ipcMain.on('drag-plus:drag', (event, { key, x, y }) => {
46
- const instance = windowInstances.get(key);
47
- if (!instance || !instance.dragData?.isDragging)
41
+ // 监听拖拽移动事件
42
+ electron_1.ipcMain.on('electron-drag:drag', (event, { x, y }) => {
43
+ if (!currentWindow || !dragData || !dragData.isDragging)
48
44
  return;
49
- const { window, dragData } = instance;
50
- const winBounds = window.getBounds();
51
- // 计算新位置
52
- const newX = winBounds.x + (x - dragData.startX);
53
- const newY = winBounds.y + (y - dragData.startY);
54
- // 应用窗口防抖优化
55
- // 1. 记住当前尺寸
56
- const size = window.getSize();
57
- // 2. 关闭缩放
58
- window.setResizable(false);
59
- // 3. 设置新坐标
60
- window.setPosition(newX, newY, false);
61
- // 4. 强制写回尺寸
62
- window.setSize(size[0], size[1], false);
63
- // 更新拖拽起始位置
64
- dragData.startX = x;
65
- dragData.startY = y;
45
+ try {
46
+ const winBounds = currentWindow.getBounds();
47
+ // 计算新位置
48
+ const newX = winBounds.x + (x - dragData.startX);
49
+ const newY = winBounds.y + (y - dragData.startY);
50
+ // 设置窗口位置
51
+ currentWindow.setPosition(newX, newY, false);
52
+ // 更新拖拽起始位置
53
+ dragData.startX = x;
54
+ dragData.startY = y;
55
+ }
56
+ catch (error) {
57
+ console.error('拖拽移动出错:', error);
58
+ }
66
59
  });
67
- electron_1.ipcMain.on('drag-plus:stop', (event, { key }) => {
68
- const instance = windowInstances.get(key);
69
- if (!instance || !instance.dragData)
60
+ // 监听拖拽结束事件
61
+ electron_1.ipcMain.on('electron-drag:stop', () => {
62
+ if (!currentWindow || !dragData)
70
63
  return;
71
- const { window, dragData } = instance;
72
- // 恢复原始的可缩放状态
64
+ // 恢复窗口原始大小调整状态
73
65
  if (dragData.originalResizable !== undefined) {
74
- window.setResizable(dragData.originalResizable);
66
+ currentWindow.setResizable(dragData.originalResizable);
75
67
  }
76
- // 清理拖拽数据
77
- delete instance.dragData;
68
+ // 清理拖拽状态
69
+ dragData = null;
78
70
  });
79
- // 确保Map类型正确
80
71
  // 默认导出
81
- exports.default = {
82
- initialize: initializeDragPlus
83
- };
72
+ exports.default = initializeDragPlus;
@@ -1,16 +1,15 @@
1
1
  /**
2
- * 渲染进程启用拖拽功能
3
- * @param element 元素或元素选择器
4
- * @param key 窗口标识,用于与主进程通信
2
+ * 为DOM元素启用窗口拖拽功能
3
+ * @param selector CSS选择器或HTMLElement对象
5
4
  */
6
- export declare function enableWindowDrag(element: HTMLElement | string, key?: string): void;
5
+ export declare function enableWindowDrag(selector: string | HTMLElement): void;
7
6
  /**
8
- * 渲染进程禁用拖拽功能
9
- * @param element 元素或元素选择器
7
+ * 禁用DOM元素的窗口拖拽功能
8
+ * @param selector CSS选择器或HTMLElement对象
10
9
  */
11
- export declare function disableWindowDrag(element: HTMLElement | string): void;
10
+ export declare function disableWindowDrag(selector: string | HTMLElement): void;
12
11
  declare const _default: {
13
- enableDrag: typeof enableWindowDrag;
14
- disableDrag: typeof disableWindowDrag;
12
+ enableWindowDrag: typeof enableWindowDrag;
13
+ disableWindowDrag: typeof disableWindowDrag;
15
14
  };
16
15
  export default _default;
package/dist/renderer.js CHANGED
@@ -3,19 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.enableWindowDrag = enableWindowDrag;
4
4
  exports.disableWindowDrag = disableWindowDrag;
5
5
  const electron_1 = require("electron");
6
- // 存储当前窗口的key
7
- let currentWindowKey = null;
8
6
  // 拖拽状态
9
7
  let isDragging = false;
10
8
  let dragStartX = 0;
11
9
  let dragStartY = 0;
12
- // 初始化
13
- function initDragSystem() {
14
- // 接收主进程发送的key
15
- electron_1.ipcRenderer.on('drag-plus:init', (event, { key }) => {
16
- currentWindowKey = key;
17
- });
18
- // 设置全局事件监听器
10
+ // 初始化拖拽事件系统
11
+ function initDragEvents() {
12
+ // 设置全局鼠标事件监听器
19
13
  document.addEventListener('mousedown', handleMouseDown, true);
20
14
  document.addEventListener('mousemove', handleMouseMove, true);
21
15
  document.addEventListener('mouseup', handleMouseUp, true);
@@ -24,70 +18,70 @@ function initDragSystem() {
24
18
  document.removeEventListener('mousedown', handleMouseDown, true);
25
19
  document.removeEventListener('mousemove', handleMouseMove, true);
26
20
  document.removeEventListener('mouseup', handleMouseUp, true);
27
- electron_1.ipcRenderer.removeAllListeners('drag-plus:init');
28
21
  };
29
22
  }
30
- // 自动初始化
23
+ // 初始化系统
31
24
  let cleanupFunction = null;
32
- try {
33
- cleanupFunction = initDragSystem();
34
- }
35
- catch (error) {
36
- console.warn('初始化拖拽系统失败:', error);
25
+ if (typeof document !== 'undefined') {
26
+ cleanupFunction = initDragEvents();
27
+ // 页面卸载时清理
28
+ window.addEventListener('beforeunload', () => {
29
+ if (cleanupFunction) {
30
+ cleanupFunction();
31
+ }
32
+ });
37
33
  }
38
- // 页面卸载时清理
39
- window.addEventListener('beforeunload', () => {
40
- if (cleanupFunction) {
41
- cleanupFunction();
42
- }
43
- });
44
34
  // 鼠标按下事件处理器
45
35
  function handleMouseDown(e) {
46
36
  const target = e.target;
47
- // 检查元素是否是可拖拽区域
48
- if (target.style.appRegion === 'drag' && !isElementOrParentNoDrag(target)) {
37
+ if (!target)
38
+ return;
39
+ // 检查元素是否是可拖拽区域且不是no-drag区域
40
+ if (target.style.appRegion === 'drag' && !isElementNoDrag(target)) {
49
41
  isDragging = true;
50
42
  dragStartX = e.screenX;
51
43
  dragStartY = e.screenY;
52
44
  // 通知主进程开始拖拽
53
- if (currentWindowKey) {
54
- electron_1.ipcRenderer.send('drag-plus:start', {
55
- key: currentWindowKey,
56
- x: e.screenX,
57
- y: e.screenY
58
- });
59
- }
45
+ electron_1.ipcRenderer.send('electron-drag:start', {
46
+ x: e.screenX,
47
+ y: e.screenY
48
+ });
60
49
  }
61
50
  }
62
51
  // 鼠标移动事件处理器
63
52
  function handleMouseMove(e) {
64
- if (isDragging && currentWindowKey) {
65
- // 计算鼠标移动距离
66
- const deltaX = e.screenX - dragStartX;
67
- const deltaY = e.screenY - dragStartY;
68
- // 只有在移动超过一定阈值时才发送拖拽事件,减少抖动
69
- if (Math.abs(deltaX) > 2 || Math.abs(deltaY) > 2) {
70
- electron_1.ipcRenderer.send('drag-plus:drag', {
71
- key: currentWindowKey,
72
- x: e.screenX,
73
- y: e.screenY
74
- });
75
- }
53
+ if (!isDragging)
54
+ return;
55
+ // 计算鼠标移动距离
56
+ const deltaX = e.screenX - dragStartX;
57
+ const deltaY = e.screenY - dragStartY;
58
+ // 只有在移动超过一定阈值时才发送拖拽事件,减少抖动
59
+ if (Math.abs(deltaX) > 1 || Math.abs(deltaY) > 1) {
60
+ // 通知主进程进行拖拽
61
+ electron_1.ipcRenderer.send('electron-drag:drag', {
62
+ x: e.screenX,
63
+ y: e.screenY
64
+ });
65
+ // 更新拖拽起始位置
66
+ dragStartX = e.screenX;
67
+ dragStartY = e.screenY;
76
68
  }
77
69
  }
78
70
  // 鼠标释放事件处理器
79
71
  function handleMouseUp() {
80
- if (isDragging && currentWindowKey) {
81
- isDragging = false;
82
- // 通知主进程结束拖拽
83
- electron_1.ipcRenderer.send('drag-plus:stop', { key: currentWindowKey });
84
- }
72
+ if (!isDragging)
73
+ return;
74
+ // 重置拖拽状态
75
+ isDragging = false;
76
+ // 通知主进程结束拖拽
77
+ electron_1.ipcRenderer.send('electron-drag:stop');
85
78
  }
86
- // 检查元素或其父元素是否有no-drag样式
87
- function isElementOrParentNoDrag(element) {
79
+ // 检查元素是否是不可拖拽区域
80
+ function isElementNoDrag(element) {
88
81
  if (element.style.appRegion === 'no-drag') {
89
82
  return true;
90
83
  }
84
+ // 检查父元素链
91
85
  let parent = element.parentElement;
92
86
  while (parent) {
93
87
  if (parent.style.appRegion === 'no-drag') {
@@ -98,56 +92,55 @@ function isElementOrParentNoDrag(element) {
98
92
  return false;
99
93
  }
100
94
  /**
101
- * 渲染进程启用拖拽功能
102
- * @param element 元素或元素选择器
103
- * @param key 窗口标识,用于与主进程通信
95
+ * 为DOM元素启用窗口拖拽功能
96
+ * @param selector CSS选择器或HTMLElement对象
104
97
  */
105
- function enableWindowDrag(element, key) {
106
- // 如果提供了key,使用它更新当前窗口的key
107
- if (key) {
108
- currentWindowKey = key;
109
- }
98
+ function enableWindowDrag(selector) {
99
+ // 确保在DOM环境中执行
100
+ if (typeof document === 'undefined')
101
+ return;
110
102
  // 获取目标元素
111
- const target = typeof element === 'string'
112
- ? document.querySelector(element)
113
- : element;
114
- if (!target || !(target instanceof HTMLElement)) {
115
- console.warn('元素不存在或不是有效的HTMLElement');
103
+ const element = typeof selector === 'string'
104
+ ? document.querySelector(selector)
105
+ : selector;
106
+ if (!element || !(element instanceof HTMLElement)) {
116
107
  return;
117
108
  }
118
- // 设置为可拖拽区域
119
- target.style.appRegion = 'drag';
120
- // 自动为子交互元素设置no-drag
121
- try {
122
- const interactiveElements = target.querySelectorAll('button, input, select, textarea, a, [onclick], [href], [tabindex]:not([tabindex="-1"])');
123
- interactiveElements.forEach(child => {
124
- if (child instanceof HTMLElement && !child.classList.contains('ignore-no-drag')) {
125
- child.style.userSelect = 'none';
126
- child.style.webkitAppRegion = 'no-drag';
127
- child.style.appRegion = 'no-drag';
128
- }
129
- });
130
- }
131
- catch (error) {
132
- console.warn('设置交互元素失败:', error);
133
- }
109
+ // 设置拖拽区域样式
110
+ element.style.userSelect = 'none';
111
+ element.style.webkitAppRegion = 'drag';
112
+ element.style.appRegion = 'drag';
113
+ // 为交互元素设置不可拖拽,确保正常操作
114
+ const interactiveElements = element.querySelectorAll('button, input, select, textarea, a, [onclick], [href], [tabindex]:not([tabindex="-1"])');
115
+ interactiveElements.forEach(child => {
116
+ if (child instanceof HTMLElement) {
117
+ child.style.userSelect = 'none';
118
+ child.style.webkitAppRegion = 'no-drag';
119
+ child.style.appRegion = 'no-drag';
120
+ }
121
+ });
134
122
  }
135
123
  /**
136
- * 渲染进程禁用拖拽功能
137
- * @param element 元素或元素选择器
124
+ * 禁用DOM元素的窗口拖拽功能
125
+ * @param selector CSS选择器或HTMLElement对象
138
126
  */
139
- function disableWindowDrag(element) {
140
- const target = typeof element === 'string'
141
- ? document.querySelector(element)
142
- : element;
143
- if (!target || !(target instanceof HTMLElement)) {
127
+ function disableWindowDrag(selector) {
128
+ // 确保在DOM环境中执行
129
+ if (typeof document === 'undefined')
130
+ return;
131
+ // 获取目标元素
132
+ const element = typeof selector === 'string'
133
+ ? document.querySelector(selector)
134
+ : selector;
135
+ if (!element || !(element instanceof HTMLElement)) {
144
136
  return;
145
137
  }
146
138
  // 设置为不可拖拽区域
147
- target.style.appRegion = 'no-drag';
139
+ element.style.webkitAppRegion = 'no-drag';
140
+ element.style.appRegion = 'no-drag';
148
141
  }
149
142
  // 默认导出
150
143
  exports.default = {
151
- enableDrag: enableWindowDrag,
152
- disableDrag: disableWindowDrag
144
+ enableWindowDrag,
145
+ disableWindowDrag
153
146
  };
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "electron-drag-plus",
3
- "version": "1.0.1",
4
- "description": "增强版Electron窗口拖拽库,解决窗口抖动、不同分辨率/缩放导致的闪屏问题,并支持拖拽区域忽略鼠标事件",
3
+ "version": "1.0.3",
4
+ "description": "简单高效的Electron窗口拖拽库,支持自定义拖拽区域和交互元素,适用于无边框窗口应用",
5
5
  "main": "dist/index.js",
6
+ "browser": "dist/renderer.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "scripts": {
8
9
  "build": "tsc",