From 777a1f58545c495521264feb1048b3a0cbfa0dc4 Mon Sep 17 00:00:00 2001 From: awehook Date: Tue, 31 Mar 2020 16:24:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dwindows=20=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E9=94=AE=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/window/main-menu.ts | 35 +++++++++++++++++++------------ src/renderer/pages/files-page.tsx | 1 + yarn.lock | 7 +------ 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/main/window/main-menu.ts b/src/main/window/main-menu.ts index bb84e2d..acc5f67 100644 --- a/src/main/window/main-menu.ts +++ b/src/main/window/main-menu.ts @@ -1,10 +1,18 @@ import { Menu, shell } from 'electron'; -import {I18nTextKey, IpcChannelName, IpcType, PasteType, ProductName} from '../../common'; +import { + I18nTextKey, + IpcChannelName, + IpcType, + PasteType, + ProductName +} from '../../common'; import { isMacOS, isWindows, IsDev } from '../utils'; import { openFile, redo, save, saveAs, undo } from './menu-event-handler'; import { subscribeMgr } from '../subscribe'; import BrowserWindow = Electron.BrowserWindow; +const log = require('debug')('bmd:menu'); + function getMenu(i18n, windowMgr) { const t = key => i18n.t(key); const preferencesMenu = { @@ -43,7 +51,7 @@ function getMenu(i18n, windowMgr) { { id: I18nTextKey.SAVE, label: t(I18nTextKey.SAVE), - accelerator: 'CommandOrControl+S', + accelerator: 'CmdOrCtrl+S', click() { save(windowMgr); } @@ -51,7 +59,7 @@ function getMenu(i18n, windowMgr) { { id: I18nTextKey.SAVE_AS, label: t(I18nTextKey.SAVE_AS), - accelerator: 'Shift+CommandOrControl+S', + accelerator: 'CmdOrCtrl+Shift+S', click() { saveAs(windowMgr); } @@ -64,14 +72,14 @@ function getMenu(i18n, windowMgr) { submenu: [ { label: t(I18nTextKey.UNDO), - accelerator: 'CommandOrControl+Z', + accelerator: 'CmdOrCtrl+Z', click() { undo(); } }, { label: t(I18nTextKey.REDO), - accelerator: 'Shift+CommandOrControl+Z', + accelerator: 'CmdOrCtrl+Shift+Z', click() { redo(); } @@ -92,23 +100,24 @@ function getMenu(i18n, windowMgr) { { label: t(I18nTextKey.PASTE_AS_PLAIN_TEXT), // role: 'paste as plaintext', - accelerator: 'CommandOrControl+V', - click(menuItem,browserWindow:BrowserWindow) { - browserWindow.webContents.send(IpcChannelName.MR_FILE_WINDOW,{ + accelerator: 'CmdOrCtrl+V', + click(menuItem, browserWindow: BrowserWindow) { + log('PASTE_AS_PLAIN_TEXT'); + browserWindow.webContents.send(IpcChannelName.MR_FILE_WINDOW, { type: IpcType.MR_PASTE, pasteType: PasteType.PASTE_PLAIN_TEXT - }) + }); } }, { label: t(I18nTextKey.PASTE_WITH_STYLE), // role: 'paste as plaintext', - accelerator: 'CommandOrControl+Shift+V', - click(menuItem,browserWindow:BrowserWindow) { - browserWindow.webContents.send(IpcChannelName.MR_FILE_WINDOW,{ + accelerator: 'CmdOrCtrl+Shift+V', + click(menuItem, browserWindow: BrowserWindow) { + browserWindow.webContents.send(IpcChannelName.MR_FILE_WINDOW, { type: IpcType.MR_PASTE, pasteType: PasteType.PASTE_WITH_STYLE - }) + }); } } ] diff --git a/src/renderer/pages/files-page.tsx b/src/renderer/pages/files-page.tsx index cf370d2..2aa0aeb 100644 --- a/src/renderer/pages/files-page.tsx +++ b/src/renderer/pages/files-page.tsx @@ -105,6 +105,7 @@ export class FilesPageInternal extends Component { log('onIpcMRFileWindow', type); switch (type) { case IpcType.MR_PASTE: + console.log('Type.MR_PASTE'); this.getActiveFileModel().controller.run('setPasteType', { pasteType: arg.pasteType }); diff --git a/yarn.lock b/yarn.lock index 94ffd20..e6fcc45 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7466,16 +7466,11 @@ is-typedarray@^1.0.0, is-typedarray@~1.0.0: resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= -is-url@^1.2.2: +is-url@^1.2.2, is-url@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52" integrity sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww== -is-url@^1.2.4: - version "1.2.4" - resolved "https://registry.npm.taobao.org/is-url/download/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52" - integrity sha1-BKTfRtKMTP89c9Af8Gq+sxihqlI= - is-utf8@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"