electron-screenshots 0.5.1 → 0.5.4
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/lib/index.js +10 -0
- package/lib/screenshots.js +23 -17
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -23,6 +23,10 @@ electron_1.app.whenReady().then(function () {
|
|
|
23
23
|
electron_1.globalShortcut.register('ctrl+shift+a', function () {
|
|
24
24
|
screenshots.startCapture();
|
|
25
25
|
});
|
|
26
|
+
// 防止不能关闭截图界面
|
|
27
|
+
electron_1.globalShortcut.register('ctrl+shift+q', function () {
|
|
28
|
+
electron_1.app.quit();
|
|
29
|
+
});
|
|
26
30
|
// 点击确定按钮回调事件
|
|
27
31
|
screenshots.on('ok', function (e, buffer, bounds) {
|
|
28
32
|
console.log('capture', buffer, bounds);
|
|
@@ -39,6 +43,12 @@ electron_1.app.whenReady().then(function () {
|
|
|
39
43
|
screenshots.on('save', function (e, buffer, bounds) {
|
|
40
44
|
console.log('capture', buffer, bounds);
|
|
41
45
|
});
|
|
46
|
+
var mainWin = new electron_1.BrowserWindow({
|
|
47
|
+
fullscreen: true,
|
|
48
|
+
show: true
|
|
49
|
+
});
|
|
50
|
+
mainWin.removeMenu();
|
|
51
|
+
mainWin.loadURL('https://github.com/nashaofu');
|
|
42
52
|
});
|
|
43
53
|
electron_1.app.on('window-all-closed', function () {
|
|
44
54
|
if (process.platform !== 'darwin') {
|
package/lib/screenshots.js
CHANGED
|
@@ -127,11 +127,6 @@ var Screenshots = /** @class */ (function (_super) {
|
|
|
127
127
|
case 2:
|
|
128
128
|
_a.sent();
|
|
129
129
|
this.$view.webContents.send('SCREENSHOTS:capture', display, imageUrl);
|
|
130
|
-
if (!this.$win) {
|
|
131
|
-
return [2 /*return*/];
|
|
132
|
-
}
|
|
133
|
-
this.$win.blur();
|
|
134
|
-
this.$win.show();
|
|
135
130
|
return [2 /*return*/];
|
|
136
131
|
}
|
|
137
132
|
});
|
|
@@ -152,13 +147,14 @@ var Screenshots = /** @class */ (function (_super) {
|
|
|
152
147
|
if (!this.$win) {
|
|
153
148
|
return [2 /*return*/];
|
|
154
149
|
}
|
|
155
|
-
|
|
150
|
+
// 先清除 Kiosk 模式,然后取消全屏才有效
|
|
156
151
|
this.$win.setKiosk(false);
|
|
152
|
+
this.$win.setFullScreen(false);
|
|
153
|
+
this.$win.setSimpleFullScreen(false);
|
|
157
154
|
this.$win.blur();
|
|
158
|
-
this.$win.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this.$win.setClosable(true);
|
|
155
|
+
this.$win.blurWebView();
|
|
156
|
+
this.$win.unmaximize();
|
|
157
|
+
this.$win.removeBrowserView(this.$view);
|
|
162
158
|
if (this.singleWindow) {
|
|
163
159
|
this.$win.hide();
|
|
164
160
|
}
|
|
@@ -239,11 +235,9 @@ var Screenshots = /** @class */ (function (_super) {
|
|
|
239
235
|
show: false,
|
|
240
236
|
autoHideMenuBar: true,
|
|
241
237
|
transparent: true,
|
|
242
|
-
resizable
|
|
238
|
+
// resizable 设置为 false 会导致页面崩溃
|
|
239
|
+
// resizable: false,
|
|
243
240
|
movable: false,
|
|
244
|
-
closable: false,
|
|
245
|
-
minimizable: false,
|
|
246
|
-
maximizable: false,
|
|
247
241
|
// focusable: true, 否则窗口不能及时响应esc按键,输入框也不能输入
|
|
248
242
|
focusable: true,
|
|
249
243
|
// linux 下必须设置为false,否则不能全屏显示在最上层
|
|
@@ -268,9 +262,21 @@ var Screenshots = /** @class */ (function (_super) {
|
|
|
268
262
|
(_b = _this.$win) === null || _b === void 0 ? void 0 : _b.setKiosk(true);
|
|
269
263
|
});
|
|
270
264
|
}
|
|
271
|
-
// 设置为 false,mac 就不显示左上角关闭按钮
|
|
272
|
-
this.$win.setClosable(false);
|
|
273
265
|
this.$win.setBrowserView(this.$view);
|
|
266
|
+
// 适定平台
|
|
267
|
+
if (process.platform === 'darwin') {
|
|
268
|
+
this.$win.setWindowButtonVisibility(false);
|
|
269
|
+
}
|
|
270
|
+
if (process.platform !== 'win32') {
|
|
271
|
+
this.$win.setVisibleOnAllWorkspaces(true, {
|
|
272
|
+
visibleOnFullScreen: true,
|
|
273
|
+
skipTransformProcessType: true
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
this.$win.blur();
|
|
277
|
+
this.$win.setKiosk(false);
|
|
278
|
+
this.$win.setFullScreen(process.platform === 'darwin');
|
|
279
|
+
this.$win.setSimpleFullScreen(process.platform === 'darwin');
|
|
274
280
|
this.$win.setBounds(display);
|
|
275
281
|
this.$view.setBounds({
|
|
276
282
|
x: 0,
|
|
@@ -278,6 +284,7 @@ var Screenshots = /** @class */ (function (_super) {
|
|
|
278
284
|
width: display.width,
|
|
279
285
|
height: display.height
|
|
280
286
|
});
|
|
287
|
+
this.$win.show();
|
|
281
288
|
return [2 /*return*/];
|
|
282
289
|
}
|
|
283
290
|
});
|
|
@@ -393,7 +400,6 @@ var Screenshots = /** @class */ (function (_super) {
|
|
|
393
400
|
milliseconds = (0, padStart_1.default)(time.getMilliseconds(), 3, '0');
|
|
394
401
|
this.$win.setAlwaysOnTop(false);
|
|
395
402
|
return [4 /*yield*/, electron_1.dialog.showSaveDialog(this.$win, {
|
|
396
|
-
title: '保存图片',
|
|
397
403
|
defaultPath: "".concat(year).concat(month).concat(date).concat(hours).concat(minutes).concat(seconds).concat(milliseconds, ".png")
|
|
398
404
|
})];
|
|
399
405
|
case 1:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-screenshots",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "electron 截图插件",
|
|
5
5
|
"types": "lib/screenshots.d.ts",
|
|
6
6
|
"main": "lib/screenshots.js",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"rimraf": "^3.0.2",
|
|
59
59
|
"typescript": "^4.5.5"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "db693e7cd6fbb997a4d875b796ed1a97050e585b"
|
|
62
62
|
}
|