electron-screenshots 0.0.17
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/LICENSE +21 -0
- package/README.md +126 -0
- package/lib/event.d.ts +4 -0
- package/lib/event.js +12 -0
- package/lib/getBoundAndDisplay.d.ts +10 -0
- package/lib/getBoundAndDisplay.js +27 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +38 -0
- package/lib/padStart0.d.ts +8 -0
- package/lib/padStart0.js +16 -0
- package/lib/screenshots.d.ts +23 -0
- package/lib/screenshots.js +178 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 nashaofu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# electron-screenshots
|
|
2
|
+
|
|
3
|
+
> electron 截图插件
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
[](https://nodei.co/npm/electron-screenshots/)
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import debug from 'electron-debug'
|
|
13
|
+
import { app, globalShortcut } from 'electron'
|
|
14
|
+
import Screenshots from './screenshots'
|
|
15
|
+
|
|
16
|
+
app.on('ready', () => {
|
|
17
|
+
const screenshots = new Screenshots()
|
|
18
|
+
globalShortcut.register('ctrl+shift+a', () => screenshots.startCapture())
|
|
19
|
+
// 点击确定按钮回调事件
|
|
20
|
+
screenshots.on('ok', (e, { viewer }) => {
|
|
21
|
+
console.log('capture', viewer)
|
|
22
|
+
})
|
|
23
|
+
// 点击取消按钮回调事件
|
|
24
|
+
screenshots.on('cancel', () => {
|
|
25
|
+
console.log('capture', 'cancel1')
|
|
26
|
+
})
|
|
27
|
+
screenshots.on('cancel', e => {
|
|
28
|
+
// 执行了preventDefault
|
|
29
|
+
// 点击取消不会关闭截图窗口
|
|
30
|
+
e.preventDefault()
|
|
31
|
+
console.log('capture', 'cancel2')
|
|
32
|
+
})
|
|
33
|
+
// 点击保存按钮回调事件
|
|
34
|
+
screenshots.on('save', (e, { viewer }) => {
|
|
35
|
+
console.log('capture', viewer)
|
|
36
|
+
})
|
|
37
|
+
debug({ showDevTools: true, devToolsMode: 'undocked' })
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
app.on('window-all-closed', () => {
|
|
41
|
+
if (process.platform !== 'darwin') {
|
|
42
|
+
app.quit()
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 注意
|
|
48
|
+
|
|
49
|
+
* 如果使用了 webpack 打包主进程,请在主进程 webpack 配置中修改如下配置,否则可能会出现不能调用截图窗口的情况
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
{
|
|
53
|
+
externals: {
|
|
54
|
+
'electron-screenshots': 'require("electron-screenshots")'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
* `vue-cli-plugin-electron-builder`配置示例[vue-cli-plugin-electron-builder-issue](https://github.com/nashaofu/vue-cli-plugin-electron-builder-issue/blob/0f774a90b09e10b02f86fcb6b50645058fe1a4e8/vue.config.js#L1-L8)
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
// vue.config.js
|
|
63
|
+
module.exports = {
|
|
64
|
+
publicPath: '.',
|
|
65
|
+
pluginOptions: {
|
|
66
|
+
electronBuilder: {
|
|
67
|
+
// 不打包,使用 require 加载
|
|
68
|
+
externals: ['shortcut-capture']
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Methods
|
|
75
|
+
|
|
76
|
+
| 名称 | 说明 | 参数 | 返回值 |
|
|
77
|
+
| ------------ | ---------------- | ---- | ------ |
|
|
78
|
+
| startCapture | 调用截图方法截图 | - | - |
|
|
79
|
+
| endCapture | 手动结束截图 | - | - |
|
|
80
|
+
|
|
81
|
+
## Events
|
|
82
|
+
|
|
83
|
+
- 数据类型
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
interface Bounds {
|
|
87
|
+
x1: number
|
|
88
|
+
y1: number
|
|
89
|
+
x2: number
|
|
90
|
+
y2: number
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
interface CaptureData {
|
|
94
|
+
dataURL: string // 图片资源base64
|
|
95
|
+
bounds: Bounds // 截图区域坐标信息
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
type OkData = CaptureData
|
|
99
|
+
type SaveData = CaptureData
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
| 名称 | 说明 | 回调参数 |
|
|
103
|
+
| ------ | ------------ | ----------------------------------------- |
|
|
104
|
+
| ok | 截图确认事件 | `event`:事件对象, `data:OkData`: 截图信息 |
|
|
105
|
+
| cancel | 截图取消事件 | `event`:事件对象 |
|
|
106
|
+
| save | 截图保存事件 | `event`:事件对象,`data:OkData`: 截图信息 |
|
|
107
|
+
|
|
108
|
+
`event`对象可调用`preventDefault`方法来阻止默认事件,例如阻止默认保存事件
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
const screenshots = new Screenshots()
|
|
112
|
+
|
|
113
|
+
screenshots.on('save', (e, data) => {
|
|
114
|
+
// 阻止插件自带的保存功能
|
|
115
|
+
// 用户自己控制保存功能
|
|
116
|
+
e.preventDefault()
|
|
117
|
+
// 用户可在这里自己定义保存功能
|
|
118
|
+
console.log('capture', data)
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
screenshots.startCapture()
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Screenshot
|
|
125
|
+
|
|
126
|
+

|
package/lib/event.d.ts
ADDED
package/lib/event.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var Event = /** @class */ (function () {
|
|
4
|
+
function Event() {
|
|
5
|
+
this.defaultPrevented = false;
|
|
6
|
+
}
|
|
7
|
+
Event.prototype.preventDefault = function () {
|
|
8
|
+
this.defaultPrevented = true;
|
|
9
|
+
};
|
|
10
|
+
return Event;
|
|
11
|
+
}());
|
|
12
|
+
exports.default = Event;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var electron_1 = require("electron");
|
|
4
|
+
exports.default = (function () {
|
|
5
|
+
var point = electron_1.screen.getCursorScreenPoint();
|
|
6
|
+
var _a = electron_1.screen.getDisplayNearestPoint(point), id = _a.id, bounds = _a.bounds, workArea = _a.workArea, scaleFactor = _a.scaleFactor;
|
|
7
|
+
// win32 darwin linux平台分别处理
|
|
8
|
+
var display = process.platform === 'linux' ? workArea : bounds;
|
|
9
|
+
// mac图片太大,导致截图窗口卡顿,并且截图窗口显示延迟很严重
|
|
10
|
+
var scale = process.platform === 'darwin' ? 2 : scaleFactor;
|
|
11
|
+
scale = scale < 2 ? 2 : scale;
|
|
12
|
+
return {
|
|
13
|
+
bound: {
|
|
14
|
+
x: bounds.x,
|
|
15
|
+
y: bounds.y,
|
|
16
|
+
width: bounds.width,
|
|
17
|
+
height: bounds.height
|
|
18
|
+
},
|
|
19
|
+
display: {
|
|
20
|
+
id: id,
|
|
21
|
+
x: display.x * scale,
|
|
22
|
+
y: display.y * scale,
|
|
23
|
+
width: display.width * scale,
|
|
24
|
+
height: display.height * scale
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
});
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var electron_debug_1 = __importDefault(require("electron-debug"));
|
|
7
|
+
var electron_1 = require("electron");
|
|
8
|
+
var screenshots_1 = __importDefault(require("./screenshots"));
|
|
9
|
+
electron_1.app.on('ready', function () {
|
|
10
|
+
var screenshots = new screenshots_1.default();
|
|
11
|
+
electron_1.globalShortcut.register('ctrl+shift+a', function () { return screenshots.startCapture(); });
|
|
12
|
+
// 点击确定按钮回调事件
|
|
13
|
+
screenshots.on('ok', function (e, _a) {
|
|
14
|
+
var viewer = _a.viewer;
|
|
15
|
+
console.log('capture', viewer);
|
|
16
|
+
});
|
|
17
|
+
// 点击取消按钮回调事件
|
|
18
|
+
screenshots.on('cancel', function () {
|
|
19
|
+
console.log('capture', 'cancel1');
|
|
20
|
+
});
|
|
21
|
+
screenshots.on('cancel', function (e) {
|
|
22
|
+
// 执行了preventDefault
|
|
23
|
+
// 点击取消不会关闭截图窗口
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
console.log('capture', 'cancel2');
|
|
26
|
+
});
|
|
27
|
+
// 点击保存按钮回调事件
|
|
28
|
+
screenshots.on('save', function (e, _a) {
|
|
29
|
+
var viewer = _a.viewer;
|
|
30
|
+
console.log('capture', viewer);
|
|
31
|
+
});
|
|
32
|
+
electron_debug_1.default({ showDevTools: true, devToolsMode: 'undocked' });
|
|
33
|
+
});
|
|
34
|
+
electron_1.app.on('window-all-closed', function () {
|
|
35
|
+
if (process.platform !== 'darwin') {
|
|
36
|
+
electron_1.app.quit();
|
|
37
|
+
}
|
|
38
|
+
});
|
package/lib/padStart0.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* 如果string字符串长度小于 length 则在左侧填充字符
|
|
5
|
+
* 如果超出length长度则截断超出的部分。
|
|
6
|
+
* @param {number} num
|
|
7
|
+
* @param {number} len
|
|
8
|
+
*/
|
|
9
|
+
exports.default = (function (num, len) {
|
|
10
|
+
if (len === void 0) { len = 2; }
|
|
11
|
+
var str = String(num);
|
|
12
|
+
while (str.length < len) {
|
|
13
|
+
str = "0" + str;
|
|
14
|
+
}
|
|
15
|
+
return str;
|
|
16
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { BrowserWindow } from 'electron';
|
|
3
|
+
import Events from 'events';
|
|
4
|
+
export default class Screenshots extends Events {
|
|
5
|
+
$win: BrowserWindow | null;
|
|
6
|
+
constructor();
|
|
7
|
+
/**
|
|
8
|
+
* 开始截图
|
|
9
|
+
*/
|
|
10
|
+
startCapture(): void;
|
|
11
|
+
/**
|
|
12
|
+
* 结束截图
|
|
13
|
+
*/
|
|
14
|
+
endCapture(): void;
|
|
15
|
+
/**
|
|
16
|
+
* 初始化窗口
|
|
17
|
+
*/
|
|
18
|
+
private createWindow;
|
|
19
|
+
/**
|
|
20
|
+
* 绑定ipc时间处理
|
|
21
|
+
*/
|
|
22
|
+
private listenIpc;
|
|
23
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
var electron_1 = require("electron");
|
|
22
|
+
var fs_1 = __importDefault(require("fs"));
|
|
23
|
+
var event_1 = __importDefault(require("./event"));
|
|
24
|
+
var events_1 = __importDefault(require("events"));
|
|
25
|
+
var padStart0_1 = __importDefault(require("./padStart0"));
|
|
26
|
+
var getBoundAndDisplay_1 = __importDefault(require("./getBoundAndDisplay"));
|
|
27
|
+
var Screenshots = /** @class */ (function (_super) {
|
|
28
|
+
__extends(Screenshots, _super);
|
|
29
|
+
function Screenshots() {
|
|
30
|
+
var _this = _super.call(this) || this;
|
|
31
|
+
// 截图窗口对象
|
|
32
|
+
_this.$win = null;
|
|
33
|
+
_this.listenIpc();
|
|
34
|
+
return _this;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 开始截图
|
|
38
|
+
*/
|
|
39
|
+
Screenshots.prototype.startCapture = function () {
|
|
40
|
+
var _this = this;
|
|
41
|
+
if (this.$win && !this.$win.isDestroyed())
|
|
42
|
+
this.$win.close();
|
|
43
|
+
var _a = getBoundAndDisplay_1.default(), bound = _a.bound, display = _a.display;
|
|
44
|
+
this.$win = this.createWindow(bound);
|
|
45
|
+
electron_1.ipcMain.once('SCREENSHOTS::DOM-READY', function () {
|
|
46
|
+
if (!_this.$win)
|
|
47
|
+
return;
|
|
48
|
+
_this.$win.webContents.send('SCREENSHOTS::SEND-DISPLAY-DATA', display);
|
|
49
|
+
});
|
|
50
|
+
// 捕捉桌面之后显示窗口
|
|
51
|
+
// 避免截图窗口自己被截图
|
|
52
|
+
electron_1.ipcMain.once('SCREENSHOTS::CAPTURED', function () {
|
|
53
|
+
if (!_this.$win)
|
|
54
|
+
return;
|
|
55
|
+
// linux截图存在黑屏,这里设置为false就不会出现这个问题
|
|
56
|
+
_this.$win.setFullScreen(true);
|
|
57
|
+
_this.$win.show();
|
|
58
|
+
_this.$win.focus();
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* 结束截图
|
|
63
|
+
*/
|
|
64
|
+
Screenshots.prototype.endCapture = function () {
|
|
65
|
+
if (!this.$win)
|
|
66
|
+
return;
|
|
67
|
+
this.$win.setSimpleFullScreen(false);
|
|
68
|
+
this.$win.close();
|
|
69
|
+
this.$win = null;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* 初始化窗口
|
|
73
|
+
*/
|
|
74
|
+
Screenshots.prototype.createWindow = function (_a) {
|
|
75
|
+
var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
|
76
|
+
var $win = new electron_1.BrowserWindow({
|
|
77
|
+
title: 'screenshots',
|
|
78
|
+
x: x,
|
|
79
|
+
y: y,
|
|
80
|
+
width: width,
|
|
81
|
+
height: height,
|
|
82
|
+
useContentSize: true,
|
|
83
|
+
frame: false,
|
|
84
|
+
show: false,
|
|
85
|
+
autoHideMenuBar: true,
|
|
86
|
+
transparent: true,
|
|
87
|
+
resizable: false,
|
|
88
|
+
movable: false,
|
|
89
|
+
focusable: true,
|
|
90
|
+
// 为true,截屏显示为黑屏
|
|
91
|
+
// 所以在截屏图像生成后再设置为true
|
|
92
|
+
// 参考48-49行
|
|
93
|
+
fullscreen: false,
|
|
94
|
+
// 设为true mac全屏窗口没有桌面滚动效果
|
|
95
|
+
simpleFullscreen: true,
|
|
96
|
+
backgroundColor: '#00000000',
|
|
97
|
+
titleBarStyle: 'hidden',
|
|
98
|
+
alwaysOnTop: true,
|
|
99
|
+
enableLargerThanScreen: true,
|
|
100
|
+
skipTaskbar: true,
|
|
101
|
+
minimizable: false,
|
|
102
|
+
maximizable: false,
|
|
103
|
+
webPreferences: {
|
|
104
|
+
nodeIntegration: true,
|
|
105
|
+
contextIsolation: false
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
$win.loadURL("file://" + require.resolve('react-screenshots/dist/index.html'));
|
|
109
|
+
return $win;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* 绑定ipc时间处理
|
|
113
|
+
*/
|
|
114
|
+
Screenshots.prototype.listenIpc = function () {
|
|
115
|
+
var _this = this;
|
|
116
|
+
/**
|
|
117
|
+
* OK事件
|
|
118
|
+
*/
|
|
119
|
+
electron_1.ipcMain.on('SCREENSHOTS::OK', function (e, data) {
|
|
120
|
+
var event = new event_1.default();
|
|
121
|
+
_this.emit('ok', event, data);
|
|
122
|
+
if (!event.defaultPrevented) {
|
|
123
|
+
electron_1.clipboard.writeImage(electron_1.nativeImage.createFromDataURL(data.dataURL));
|
|
124
|
+
_this.endCapture();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
/**
|
|
128
|
+
* CANCEL事件
|
|
129
|
+
*/
|
|
130
|
+
electron_1.ipcMain.on('SCREENSHOTS::CANCEL', function () {
|
|
131
|
+
var event = new event_1.default();
|
|
132
|
+
_this.emit('cancel', event);
|
|
133
|
+
if (!event.defaultPrevented) {
|
|
134
|
+
_this.endCapture();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
/**
|
|
138
|
+
* SAVE事件
|
|
139
|
+
*/
|
|
140
|
+
electron_1.ipcMain.on('SCREENSHOTS::SAVE', function (e, data) {
|
|
141
|
+
var event = new event_1.default();
|
|
142
|
+
_this.emit('save', event, data);
|
|
143
|
+
if (!event.defaultPrevented) {
|
|
144
|
+
if (!_this.$win)
|
|
145
|
+
return;
|
|
146
|
+
var time = new Date();
|
|
147
|
+
var year = time.getFullYear();
|
|
148
|
+
var month = padStart0_1.default(time.getMonth() + 1);
|
|
149
|
+
var date = padStart0_1.default(time.getDate());
|
|
150
|
+
var hours = padStart0_1.default(time.getHours());
|
|
151
|
+
var minutes = padStart0_1.default(time.getMinutes());
|
|
152
|
+
var seconds = padStart0_1.default(time.getSeconds());
|
|
153
|
+
var milliseconds = padStart0_1.default(time.getMilliseconds(), 3);
|
|
154
|
+
_this.$win.setAlwaysOnTop(false);
|
|
155
|
+
electron_1.dialog
|
|
156
|
+
.showSaveDialog(_this.$win, {
|
|
157
|
+
title: '保存图片',
|
|
158
|
+
defaultPath: "" + year + month + date + hours + minutes + seconds + milliseconds + ".png"
|
|
159
|
+
})
|
|
160
|
+
.then(function (_a) {
|
|
161
|
+
var canceled = _a.canceled, filePath = _a.filePath;
|
|
162
|
+
if (!_this.$win)
|
|
163
|
+
return;
|
|
164
|
+
_this.$win.setAlwaysOnTop(true);
|
|
165
|
+
if (canceled || !filePath)
|
|
166
|
+
return;
|
|
167
|
+
fs_1.default.writeFile(filePath, Buffer.from(data.dataURL.replace(/^data:image\/\w+;base64,/, ''), 'base64'), function (err) {
|
|
168
|
+
if (err)
|
|
169
|
+
return;
|
|
170
|
+
_this.endCapture();
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
return Screenshots;
|
|
177
|
+
}(events_1.default));
|
|
178
|
+
exports.default = Screenshots;
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "electron-screenshots",
|
|
3
|
+
"version": "0.0.17",
|
|
4
|
+
"description": "electron 截图插件",
|
|
5
|
+
"types": "lib/screenshots.d.ts",
|
|
6
|
+
"main": "lib/screenshots.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/**"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"prepublishOnly": "npm run build",
|
|
12
|
+
"start": "electron lib/index.js",
|
|
13
|
+
"dev": "tsc --sourceMap --watch",
|
|
14
|
+
"build": "npm run lint && npm run clean && tsc",
|
|
15
|
+
"lint": "eslint . --ext .js,.ts --fix",
|
|
16
|
+
"clean": "rimraf lib"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/nashaofu/screenshots.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"electron",
|
|
24
|
+
"shortcut",
|
|
25
|
+
"capture",
|
|
26
|
+
"plugin"
|
|
27
|
+
],
|
|
28
|
+
"author": "nashaofu",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/nashaofu/screenshots/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/nashaofu/screenshots/tree/master/packages/electron-screenshots#readme",
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"registry": "https://registry.npmjs.org/"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"react-screenshots": "^0.0.17"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"electron": ">=8"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^4.23.0",
|
|
45
|
+
"@typescript-eslint/parser": "^4.23.0",
|
|
46
|
+
"electron": "^14.0.1",
|
|
47
|
+
"electron-debug": "^3.2.0",
|
|
48
|
+
"eslint": "^7.26.0",
|
|
49
|
+
"eslint-config-standard": "^16.0.2",
|
|
50
|
+
"eslint-plugin-import": "^2.22.1",
|
|
51
|
+
"eslint-plugin-node": "^11.1.0",
|
|
52
|
+
"eslint-plugin-promise": "^5.1.0",
|
|
53
|
+
"eslint-plugin-standard": "^5.0.0",
|
|
54
|
+
"rimraf": "^3.0.2",
|
|
55
|
+
"typescript": "^4.2.4"
|
|
56
|
+
},
|
|
57
|
+
"gitHead": "b3f62f6f404aa52ab0fd12509e0ecba492171218"
|
|
58
|
+
}
|