复制&粘贴快捷键

This commit is contained in:
zhandouxiaojiji committed 2020-11-11 11:26:26 +08:00
1 parent f0b785a168
commit 1d25e6c22e
4 files changed
+57 -4

No files matched your search

+5 -2
View File
@@ -44,6 +44,7 @@ export default class AppMenu {
submenu: [
{
label: "新建",
accelerator: 'ctrl+n',
click: () => {
(async () => {
const res = await dialog.showSaveDialog({
@@ -92,12 +93,14 @@ export default class AppMenu {
{ type: 'separator' },
{
label: "保存",
accelerator: 'ctrl+s',
click: () => {
this.webContents.send(MainEventType.SAVE);
},
},
{
label: "全部保存",
accelerator: 'ctrl+shift+s',
click: () => {
this.webContents.send(MainEventType.SAVE_ALL);
},
@@ -120,7 +123,7 @@ export default class AppMenu {
{ type: 'separator' },
{
label: '复制节点',
accelerator: 'ctrl+shift+c',
accelerator: 'ctrl+c',
role: 'copy',
click: () => {
this.webContents.send(MainEventType.COPY_NODE);
@@ -128,7 +131,7 @@ export default class AppMenu {
},
{
label: '粘贴节点',
accelerator: 'ctrl+shift+v',
accelerator: 'ctrl+v',
click: () => {
this.webContents.send(MainEventType.PASTE_NODE);
}
+9 -1
View File
@@ -3,6 +3,8 @@ import AppMenu from './AppMenu'
import Settings from './Settings';
import MainEventType from '../common/MainEventType';
const electronLocalshortcut = require('electron-localshortcut');
// 一些暴露给render-process的全局变量
export interface Global {
settings: Settings
@@ -17,6 +19,12 @@ export class MainProcess {
nativeTheme.themeSource = 'dark';
app.on('ready', () => {
this.createWindow();
electronLocalshortcut.register(this.mainWindow, 'Ctrl+C', () => {
this.mainWindow.webContents.send(MainEventType.COPY_NODE);
});
electronLocalshortcut.register(this.mainWindow, 'Ctrl+V', () => {
this.mainWindow.webContents.send(MainEventType.PASTE_NODE);
});
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
@@ -33,7 +41,7 @@ export class MainProcess {
createWindow() {
this.settings = new Settings();
global.settings = this.settings;
this.mainWindow = new BrowserWindow({
width: 1280,
height: 800,