:spark: 支持系统截屏功能

This commit is contained in:
muwoo
2023-04-04 11:13:38 +08:00
parent 9ee8d78b1b
commit 2cd70bd386
12 changed files with 197 additions and 66 deletions

View File

@@ -15,6 +15,7 @@ import { LocalDb } from '@/core';
import plist from 'plist';
import { DECODE_KEY } from '@/common/constans/main';
import mainInstance from '../index';
import { screenshots } from './registerScreenshots';
const runnerInstance = runner();
const detachInstance = detach();
const dbInstance = new LocalDb(app.getPath('userData'));
@@ -33,6 +34,14 @@ class API {
event.returnValue = data;
// event.sender.send(`msg-back-${arg.type}`, data);
});
// 注册截屏成功回调事件
screenshots.on('ok', (e, buffer) => {
const image = nativeImage.createFromBuffer(buffer);
runnerInstance.executeHooks('ScreenCapture', {
data: image.toDataURL(),
});
});
}
public getCurrentWindow = (window, e) => {
@@ -313,6 +322,10 @@ class API {
shell.beep();
return true;
}
public screenCapture() {
screenshots.startCapture();
}
}
export default new API();