From 84c64a40223091de9f482650135ffad5425dd767 Mon Sep 17 00:00:00 2001 From: Cmen <1176967590@qq.com> Date: Wed, 2 Mar 2022 09:12:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=94=AF=E6=8C=81=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=BF=AB=E6=8D=B7=E9=94=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editor/Menu/File.tsx | 29 +++++++++++++++++++++++++---- src/editor/Menu/MenuGroup.tsx | 6 ++++-- src/editor/Menu/style.less | 6 ++++++ src/store/GlobalController.ts | 3 +++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/editor/Menu/File.tsx b/src/editor/Menu/File.tsx index a68d982..601e55d 100644 --- a/src/editor/Menu/File.tsx +++ b/src/editor/Menu/File.tsx @@ -7,10 +7,31 @@ const FileMenu = () => { {...{ name: "文件", items: [ - { name: "打开GeoJSON", onClick: globalController.openGeoJSON }, - { name: "打开工程", onClick: globalController.openProject }, - { name: "保存GeoJSON", onClick: globalController.saveGeoJSON }, - { name: "保存工程", onClick: globalController.saveProject }, + { + name: "打开GeoJSON", + onClick: globalController.openGeoJSON, + hotkey: "Alt+O", + }, + { + name: "打开工程", + onClick: globalController.openProject, + hotkey: "Ctrl+O", + }, + { + name: "暂存工程", + onClick: globalController.saveTemp, + hotkey: "Alt+S", + }, + { + name: "保存GeoJSON", + onClick: globalController.saveGeoJSON, + hotkey: "Ctrl+S", + }, + { + name: "保存工程", + onClick: globalController.saveProject, + hotkey: "Ctrl+Alt+S", + }, ], }} /> diff --git a/src/editor/Menu/MenuGroup.tsx b/src/editor/Menu/MenuGroup.tsx index a2968f0..dd5c8da 100644 --- a/src/editor/Menu/MenuGroup.tsx +++ b/src/editor/Menu/MenuGroup.tsx @@ -3,6 +3,7 @@ import { Menu, Dropdown } from "antd"; export type MenuItemConfig = { name: string; onClick: () => void; + hotkey?: string; }; export type MenuConfig = { @@ -14,15 +15,16 @@ const MenuGroup = (props: MenuConfig) => { const menu = ( {props.items.map((item, index) => ( - + {item.name} + {item.hotkey} ))} ); return ( - + {props.name} ); diff --git a/src/editor/Menu/style.less b/src/editor/Menu/style.less index 0fd7580..33cb258 100644 --- a/src/editor/Menu/style.less +++ b/src/editor/Menu/style.less @@ -1,3 +1,9 @@ .menu-title{ cursor: pointer; +} +.menu-item{ + width: 240px; +} +.menu-item-hot-key{ + float: right; } \ No newline at end of file diff --git a/src/store/GlobalController.ts b/src/store/GlobalController.ts index 9f3f551..fc4e265 100644 --- a/src/store/GlobalController.ts +++ b/src/store/GlobalController.ts @@ -80,6 +80,7 @@ export class GlobelController implements IGlobalController { } private _registerHotkeys() { + // 保存 registerHotkey("s", { callback: this.saveGeoJSON, ctrl: true }); registerHotkey("s", { callback: this.saveProject, @@ -87,7 +88,9 @@ export class GlobelController implements IGlobalController { alt: true, }); registerHotkey("s", { callback: this.saveTemp, alt: true }); + // 清空 registerHotkey("c", { callback: this.clearEditor, alt: true }); + // registerHotkey("o", { callback: this.openGeoJSON, alt: true }); registerHotkey("o", { callback: this.openProject,