mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-29 01:02:47 +08:00
Merge branch 'feat/v2.2.1'
This commit is contained in:
commit
6e30f330d3
@ -24,7 +24,6 @@
|
|||||||
"axios": "^1.3.4",
|
"axios": "^1.3.4",
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.6.5",
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
"electron-screenshots": "^0.5.19",
|
|
||||||
"extract-file-icon": "^0.3.2",
|
"extract-file-icon": "^0.3.2",
|
||||||
"fix-path": "^3.0.0",
|
"fix-path": "^3.0.0",
|
||||||
"get-mac-apps": "^1.0.2",
|
"get-mac-apps": "^1.0.2",
|
||||||
|
BIN
public/PrScrn.dll
Normal file
BIN
public/PrScrn.dll
Normal file
Binary file not shown.
BIN
public/PrintScr.exe
Normal file
BIN
public/PrintScr.exe
Normal file
Binary file not shown.
@ -1,4 +1,5 @@
|
|||||||
import PluginHandler from "@/core/plugin-handler";
|
import PluginHandler from '@/core/plugin-handler';
|
||||||
import LocalDb from "@/core/db";
|
import LocalDb from '@/core/db';
|
||||||
|
import screenCapture from '@/core/screen-capture';
|
||||||
|
|
||||||
export { PluginHandler, LocalDb };
|
export { PluginHandler, LocalDb, screenCapture };
|
||||||
|
40
src/core/screen-capture/index.ts
Normal file
40
src/core/screen-capture/index.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { clipboard, Notification } from 'electron';
|
||||||
|
import { execFile, exec } from 'child_process';
|
||||||
|
import platform from '@/common/utils/commonConst';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
// 截图方法windows
|
||||||
|
export const screenWindow = (cb) => {
|
||||||
|
const url = path.resolve(__static, 'PrintScr.exe');
|
||||||
|
const screen_window = execFile(url);
|
||||||
|
screen_window.on('exit', (code) => {
|
||||||
|
if (code) {
|
||||||
|
const image = clipboard.readImage();
|
||||||
|
cb && cb(image.isEmpty() ? '' : image.toDataURL());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 截图方法mac
|
||||||
|
export const handleScreenShots = (cb) => {
|
||||||
|
exec('screencapture -i -r -c', () => {
|
||||||
|
const image = clipboard.readImage();
|
||||||
|
cb && cb(image.isEmpty() ? '' : image.toDataURL());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default (mainWindow, cb) => {
|
||||||
|
// 接收到截图后的执行程序
|
||||||
|
mainWindow.hide();
|
||||||
|
clipboard.writeText('');
|
||||||
|
if (platform.macOS()) {
|
||||||
|
handleScreenShots(cb);
|
||||||
|
} else if (platform.windows()) {
|
||||||
|
screenWindow(cb);
|
||||||
|
} else {
|
||||||
|
new Notification({
|
||||||
|
title: '兼容性支持度不够',
|
||||||
|
body: 'Linux 系统截图暂不支持,我们将会尽快更新!',
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
};
|
@ -11,11 +11,10 @@ import {
|
|||||||
} from 'electron';
|
} from 'electron';
|
||||||
import { runner, detach } from '../browsers';
|
import { runner, detach } from '../browsers';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { LocalDb } from '@/core';
|
import { LocalDb, screenCapture } from '@/core';
|
||||||
import plist from 'plist';
|
import plist from 'plist';
|
||||||
import { DECODE_KEY } from '@/common/constans/main';
|
import { DECODE_KEY } from '@/common/constans/main';
|
||||||
import mainInstance from '../index';
|
import mainInstance from '../index';
|
||||||
import { screenshots } from './registerScreenshots';
|
|
||||||
const runnerInstance = runner();
|
const runnerInstance = runner();
|
||||||
const detachInstance = detach();
|
const detachInstance = detach();
|
||||||
const dbInstance = new LocalDb(app.getPath('userData'));
|
const dbInstance = new LocalDb(app.getPath('userData'));
|
||||||
@ -34,14 +33,6 @@ class API {
|
|||||||
event.returnValue = data;
|
event.returnValue = data;
|
||||||
// event.sender.send(`msg-back-${arg.type}`, 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) => {
|
public getCurrentWindow = (window, e) => {
|
||||||
@ -323,8 +314,12 @@ class API {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public screenCapture() {
|
public screenCapture(arg, window) {
|
||||||
screenshots.startCapture();
|
screenCapture(window, (img) => {
|
||||||
|
runnerInstance.executeHooks('ScreenCapture', {
|
||||||
|
data: img,
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,9 @@ import {
|
|||||||
screen,
|
screen,
|
||||||
ipcMain,
|
ipcMain,
|
||||||
app,
|
app,
|
||||||
|
Notification,
|
||||||
} from 'electron';
|
} from 'electron';
|
||||||
import { screenshots } from './registerScreenshots';
|
import screenCapture from '@/core/screen-capture';
|
||||||
|
|
||||||
const registerHotKey = (mainWindow: BrowserWindow): void => {
|
const registerHotKey = (mainWindow: BrowserWindow): void => {
|
||||||
// 设置开机启动
|
// 设置开机启动
|
||||||
@ -79,7 +80,13 @@ const registerHotKey = (mainWindow: BrowserWindow): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
globalShortcut.register(config.perf.shortCut.capture, () => {
|
globalShortcut.register(config.perf.shortCut.capture, () => {
|
||||||
screenshots.startCapture();
|
screenCapture(mainWindow, (data) => {
|
||||||
|
data &&
|
||||||
|
new Notification({
|
||||||
|
title: '截图完成',
|
||||||
|
body: '截图以存储到系统剪贴板中',
|
||||||
|
}).show();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// globalShortcut.register(config.perf.shortCut.separate, () => {
|
// globalShortcut.register(config.perf.shortCut.separate, () => {
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
import Screenshots from 'electron-screenshots';
|
|
||||||
let screenshots;
|
|
||||||
|
|
||||||
const initScreenShots = () => {
|
|
||||||
screenshots = new Screenshots();
|
|
||||||
};
|
|
||||||
|
|
||||||
export { initScreenShots, screenshots };
|
|
@ -17,7 +17,6 @@ import '../common/utils/localPlugin';
|
|||||||
import '../common/utils/localConfig';
|
import '../common/utils/localConfig';
|
||||||
|
|
||||||
import registerySystemPlugin from './common/registerySystemPlugin';
|
import registerySystemPlugin from './common/registerySystemPlugin';
|
||||||
import { initScreenShots } from './common/registerScreenshots';
|
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
public windowCreator: { init: () => void; getWindow: () => BrowserWindow };
|
public windowCreator: { init: () => void; getWindow: () => BrowserWindow };
|
||||||
@ -59,7 +58,6 @@ class App {
|
|||||||
const readyFunction = () => {
|
const readyFunction = () => {
|
||||||
this.createWindow();
|
this.createWindow();
|
||||||
const mainWindow = this.windowCreator.getWindow();
|
const mainWindow = this.windowCreator.getWindow();
|
||||||
initScreenShots();
|
|
||||||
API.init(mainWindow);
|
API.init(mainWindow);
|
||||||
createTray(this.windowCreator.getWindow());
|
createTray(this.windowCreator.getWindow());
|
||||||
registerHotKey(this.windowCreator.getWindow());
|
registerHotKey(this.windowCreator.getWindow());
|
||||||
|
74
yarn.lock
74
yarn.lock
@ -4130,7 +4130,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9:
|
|||||||
dependencies:
|
dependencies:
|
||||||
ms "2.0.0"
|
ms "2.0.0"
|
||||||
|
|
||||||
debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.4:
|
debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2:
|
||||||
version "4.3.4"
|
version "4.3.4"
|
||||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
|
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
|
||||||
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
|
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
|
||||||
@ -4680,16 +4680,6 @@ electron-publish@22.14.13:
|
|||||||
lazy-val "^1.0.5"
|
lazy-val "^1.0.5"
|
||||||
mime "^2.5.2"
|
mime "^2.5.2"
|
||||||
|
|
||||||
electron-screenshots@^0.5.19:
|
|
||||||
version "0.5.19"
|
|
||||||
resolved "https://registry.yarnpkg.com/electron-screenshots/-/electron-screenshots-0.5.19.tgz#2cef4bf2af4cc92d999a5a9e07cada99bccdcf59"
|
|
||||||
integrity sha512-+3Ia7f8D4oRmoVoTxvUkS/U288zA21W4TERX8Cy3A7OUXkoIqfRF48Caz5Q8I5tRoWy+QIqfXOupEv9M4fcwlQ==
|
|
||||||
dependencies:
|
|
||||||
debug "^4.3.4"
|
|
||||||
fs-extra "^11.1.1"
|
|
||||||
node-screenshots "^0.1.2"
|
|
||||||
react-screenshots "^0.5.19"
|
|
||||||
|
|
||||||
electron-to-chromium@^1.4.202:
|
electron-to-chromium@^1.4.202:
|
||||||
version "1.4.211"
|
version "1.4.211"
|
||||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.211.tgz#afaa8b58313807501312d598d99b953568d60f91"
|
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.211.tgz#afaa8b58313807501312d598d99b953568d60f91"
|
||||||
@ -5616,15 +5606,6 @@ fs-extra@^10.0.0:
|
|||||||
jsonfile "^6.0.1"
|
jsonfile "^6.0.1"
|
||||||
universalify "^2.0.0"
|
universalify "^2.0.0"
|
||||||
|
|
||||||
fs-extra@^11.1.1:
|
|
||||||
version "11.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.1.tgz#da69f7c39f3b002378b0954bb6ae7efdc0876e2d"
|
|
||||||
integrity sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==
|
|
||||||
dependencies:
|
|
||||||
graceful-fs "^4.2.0"
|
|
||||||
jsonfile "^6.0.1"
|
|
||||||
universalify "^2.0.0"
|
|
||||||
|
|
||||||
fs-extra@^7.0.1:
|
fs-extra@^7.0.1:
|
||||||
version "7.0.1"
|
version "7.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
|
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
|
||||||
@ -8033,54 +8014,6 @@ node-releases@^2.0.6:
|
|||||||
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503"
|
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503"
|
||||||
integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==
|
integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==
|
||||||
|
|
||||||
node-screenshots-darwin-arm64@0.1.2:
|
|
||||||
version "0.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/node-screenshots-darwin-arm64/-/node-screenshots-darwin-arm64-0.1.2.tgz#6662d6c5ff43c0f0a423d6c93d3572dfd459ebb1"
|
|
||||||
integrity sha512-K7Gz1HxYBdchAzFtDFei1sOJf6DosBZw4MWTDfybuBhGPlJWHdqdgBu01qBb6IrTLFl6soC1tpLEGzNmJ4sDxA==
|
|
||||||
|
|
||||||
node-screenshots-darwin-x64@0.1.2:
|
|
||||||
version "0.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/node-screenshots-darwin-x64/-/node-screenshots-darwin-x64-0.1.2.tgz#6926c3714337bed7c21fcb0a6b4f351d675ed04c"
|
|
||||||
integrity sha512-4zVzuVPveFivpTBEx9cGw0nz8NayqIrtyoclTuEcTrnS1iUCkSL8/G9FUMgqy8HgzE2j534sQQmRt1KOV8RkCA==
|
|
||||||
|
|
||||||
node-screenshots-linux-x64-gnu@0.1.2:
|
|
||||||
version "0.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/node-screenshots-linux-x64-gnu/-/node-screenshots-linux-x64-gnu-0.1.2.tgz#0a1d34ef49fb0342e3dfe05de2729940716034f4"
|
|
||||||
integrity sha512-0hK1EK8UdH5i9lt4kEUAVcCm2lYtYBM9smWGosiSoxcz0hzjSTMIKTNzK+VY6qspNYMNM71Q14jbiQfSsXg5iQ==
|
|
||||||
|
|
||||||
node-screenshots-linux-x64-musl@0.1.2:
|
|
||||||
version "0.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/node-screenshots-linux-x64-musl/-/node-screenshots-linux-x64-musl-0.1.2.tgz#23db04426a3bbaed8802e84d5f9fbb089375f480"
|
|
||||||
integrity sha512-DLjKKexhrq5gM8SoAB5AhExfJ9ftnJqTcxBx2sX17aTyCnLJ8VAl0ID4PbweU/zkEmLSN5YM7rTAgfIOvWBC0Q==
|
|
||||||
|
|
||||||
node-screenshots-win32-arm64-msvc@0.1.2:
|
|
||||||
version "0.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/node-screenshots-win32-arm64-msvc/-/node-screenshots-win32-arm64-msvc-0.1.2.tgz#e3096a4e597898fbef5be9e92fa4529f9c03eb34"
|
|
||||||
integrity sha512-BTZHxHy3Z0hjdC2mDTHbKYrDGIFqloe0Dr7FXCIkDyQua4X2SB+vz2Q2NBUe/yDynzNvZHLLKBwZjFJ7cuf9gg==
|
|
||||||
|
|
||||||
node-screenshots-win32-ia32-msvc@0.1.2:
|
|
||||||
version "0.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/node-screenshots-win32-ia32-msvc/-/node-screenshots-win32-ia32-msvc-0.1.2.tgz#89b9c78fedf285a93e0e492726afc33f25dba3cc"
|
|
||||||
integrity sha512-5QREHYvq3BXAO40+gWHnVc8xu6BRfN55DmjCKg9NA/LSH21xLALA6tjh24hoa3Ng5Hv09ARNafVic7EwPr0Iwg==
|
|
||||||
|
|
||||||
node-screenshots-win32-x64-msvc@0.1.2:
|
|
||||||
version "0.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/node-screenshots-win32-x64-msvc/-/node-screenshots-win32-x64-msvc-0.1.2.tgz#546fce36009c0e05653d2d18d8a5a72046690809"
|
|
||||||
integrity sha512-yoByNKjL0oRTmkkLs22HmcsaijbblfPGyPiRtajkbQWAmambWWbvoKHFkx/ZMFfIbxjTKHdFMmlhuwO+GaiAmw==
|
|
||||||
|
|
||||||
node-screenshots@^0.1.2:
|
|
||||||
version "0.1.2"
|
|
||||||
resolved "https://registry.yarnpkg.com/node-screenshots/-/node-screenshots-0.1.2.tgz#3a4997e9f839e977fcd3bf1fde75caecd1ae214a"
|
|
||||||
integrity sha512-+DHuQsiqyNj5TDQZKt2pICfIOYmeeyfhOgvGy0Q7RWXFesiFASOyDz6/G3urMp1gtMn3snrrFHLXvO6aFdcQBw==
|
|
||||||
optionalDependencies:
|
|
||||||
node-screenshots-darwin-arm64 "0.1.2"
|
|
||||||
node-screenshots-darwin-x64 "0.1.2"
|
|
||||||
node-screenshots-linux-x64-gnu "0.1.2"
|
|
||||||
node-screenshots-linux-x64-musl "0.1.2"
|
|
||||||
node-screenshots-win32-arm64-msvc "0.1.2"
|
|
||||||
node-screenshots-win32-ia32-msvc "0.1.2"
|
|
||||||
node-screenshots-win32-x64-msvc "0.1.2"
|
|
||||||
|
|
||||||
normalize-package-data@^2.5.0:
|
normalize-package-data@^2.5.0:
|
||||||
version "2.5.0"
|
version "2.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8"
|
resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8"
|
||||||
@ -9326,11 +9259,6 @@ rc@1.2.8, rc@^1.2.8:
|
|||||||
minimist "^1.2.0"
|
minimist "^1.2.0"
|
||||||
strip-json-comments "~2.0.1"
|
strip-json-comments "~2.0.1"
|
||||||
|
|
||||||
react-screenshots@^0.5.19:
|
|
||||||
version "0.5.19"
|
|
||||||
resolved "https://registry.yarnpkg.com/react-screenshots/-/react-screenshots-0.5.19.tgz#6cda8a9bf29d3a9e0baff2102916371b2be977aa"
|
|
||||||
integrity sha512-n1ovKoiwJJ04DWSWX1ko1hjSf+B9IqnMz+M4tr9VgKb67nQ1IeByqOjs52vwsSDJc5SrlXDtIvRjBcq7bO/raA==
|
|
||||||
|
|
||||||
read-config-file@6.2.0:
|
read-config-file@6.2.0:
|
||||||
version "6.2.0"
|
version "6.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/read-config-file/-/read-config-file-6.2.0.tgz#71536072330bcd62ba814f91458b12add9fc7ade"
|
resolved "https://registry.yarnpkg.com/read-config-file/-/read-config-file-6.2.0.tgz#71536072330bcd62ba814f91458b12add9fc7ade"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user