Skip to content

Commit

Permalink
fix: 修复windows 快捷键显示问题
Browse files Browse the repository at this point in the history
  • Loading branch information
awehook committed Mar 31, 2020
1 parent b7ab6ec commit 777a1f5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
35 changes: 22 additions & 13 deletions src/main/window/main-menu.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -43,15 +51,15 @@ function getMenu(i18n, windowMgr) {
{
id: I18nTextKey.SAVE,
label: t(I18nTextKey.SAVE),
accelerator: 'CommandOrControl+S',
accelerator: 'CmdOrCtrl+S',
click() {
save(windowMgr);
}
},
{
id: I18nTextKey.SAVE_AS,
label: t(I18nTextKey.SAVE_AS),
accelerator: 'Shift+CommandOrControl+S',
accelerator: 'CmdOrCtrl+Shift+S',
click() {
saveAs(windowMgr);
}
Expand All @@ -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();
}
Expand All @@ -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
})
});
}
}
]
Expand Down
1 change: 1 addition & 0 deletions src/renderer/pages/files-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class FilesPageInternal extends Component<Props, State> {
log('onIpcMRFileWindow', type);
switch (type) {
case IpcType.MR_PASTE:
console.log('Type.MR_PASTE');
this.getActiveFileModel().controller.run('setPasteType', {
pasteType: arg.pasteType
});
Expand Down
7 changes: 1 addition & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 777a1f5

Please sign in to comment.