electron-screenshots 0.5.2 → 0.5.5

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 CHANGED
@@ -10,13 +10,7 @@ electron_1.app.whenReady().then(function () {
10
10
  lang: {
11
11
  operation_rectangle_title: '矩形2323'
12
12
  },
13
- logger: function () {
14
- var args = [];
15
- for (var _i = 0; _i < arguments.length; _i++) {
16
- args[_i] = arguments[_i];
17
- }
18
- return console.log(args);
19
- },
13
+ // logger: (...args: unknown[]) => console.log(args),
20
14
  singleWindow: true
21
15
  });
22
16
  screenshots.$view.webContents.openDevTools();
@@ -43,6 +37,12 @@ electron_1.app.whenReady().then(function () {
43
37
  screenshots.on('save', function (e, buffer, bounds) {
44
38
  console.log('capture', buffer, bounds);
45
39
  });
40
+ var mainWin = new electron_1.BrowserWindow({
41
+ fullscreen: true,
42
+ show: true
43
+ });
44
+ mainWin.removeMenu();
45
+ mainWin.loadURL('https://github.com/nashaofu');
46
46
  });
47
47
  electron_1.app.on('window-all-closed', function () {
48
48
  if (process.platform !== 'darwin') {
@@ -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
  });
@@ -157,10 +152,9 @@ var Screenshots = /** @class */ (function (_super) {
157
152
  this.$win.setFullScreen(false);
158
153
  this.$win.setSimpleFullScreen(false);
159
154
  this.$win.blur();
160
- this.$win.setBrowserView(null);
161
- // 必须设置为 closable 为 true
162
- // 否者不能关闭窗口
163
- this.$win.setClosable(true);
155
+ this.$win.blurWebView();
156
+ this.$win.unmaximize();
157
+ this.$win.removeBrowserView(this.$view);
164
158
  if (this.singleWindow) {
165
159
  this.$win.hide();
166
160
  }
@@ -241,11 +235,9 @@ var Screenshots = /** @class */ (function (_super) {
241
235
  show: false,
242
236
  autoHideMenuBar: true,
243
237
  transparent: true,
244
- resizable: false,
238
+ // resizable 设置为 false 会导致页面崩溃
239
+ // resizable: false,
245
240
  movable: false,
246
- closable: false,
247
- minimizable: false,
248
- maximizable: false,
249
241
  // focusable: true, 否则窗口不能及时响应esc按键,输入框也不能输入
250
242
  focusable: true,
251
243
  // linux 下必须设置为false,否则不能全屏显示在最上层
@@ -270,10 +262,21 @@ var Screenshots = /** @class */ (function (_super) {
270
262
  (_b = _this.$win) === null || _b === void 0 ? void 0 : _b.setKiosk(true);
271
263
  });
272
264
  }
273
- this.$win.setFullScreen(process.platform === 'darwin');
274
- // 设置为 false,mac 就不显示左上角关闭按钮
275
- this.$win.setClosable(false);
276
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');
277
280
  this.$win.setBounds(display);
278
281
  this.$view.setBounds({
279
282
  x: 0,
@@ -281,6 +284,7 @@ var Screenshots = /** @class */ (function (_super) {
281
284
  width: display.width,
282
285
  height: display.height
283
286
  });
287
+ this.$win.show();
284
288
  return [2 /*return*/];
285
289
  }
286
290
  });
@@ -396,7 +400,6 @@ var Screenshots = /** @class */ (function (_super) {
396
400
  milliseconds = (0, padStart_1.default)(time.getMilliseconds(), 3, '0');
397
401
  this.$win.setAlwaysOnTop(false);
398
402
  return [4 /*yield*/, electron_1.dialog.showSaveDialog(this.$win, {
399
- title: '保存图片',
400
403
  defaultPath: "".concat(year).concat(month).concat(date).concat(hours).concat(minutes).concat(seconds).concat(milliseconds, ".png")
401
404
  })];
402
405
  case 1:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electron-screenshots",
3
- "version": "0.5.2",
3
+ "version": "0.5.5",
4
4
  "description": "electron 截图插件",
5
5
  "types": "lib/screenshots.d.ts",
6
6
  "main": "lib/screenshots.js",
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "debug": "^4.3.3",
39
39
  "fs-extra": "^10.1.0",
40
- "node-screenshots": "^0.0.3",
40
+ "node-screenshots": "^0.0.6",
41
41
  "react-screenshots": "^0.5.1"
42
42
  },
43
43
  "peerDependencies": {
@@ -58,5 +58,5 @@
58
58
  "rimraf": "^3.0.2",
59
59
  "typescript": "^4.5.5"
60
60
  },
61
- "gitHead": "8cfc003a0b5159255cea5e2990515fc824982b1e"
61
+ "gitHead": "33effdd2bb39a34303895c70428f3589b15582eb"
62
62
  }