Skip to content

Commit f9e92b8

Browse files
committed
新增脚本编辑器菜单快捷键显示
1 parent d31eb9c commit f9e92b8

File tree

1 file changed

+37
-22
lines changed

1 file changed

+37
-22
lines changed

src/pages/options/routes/script/ScriptEditor.tsx

+37-22
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ type EditorMenu = {
105105
title: string;
106106
tooltip?: string;
107107
hotKey?: number;
108+
hotKeyString?: string;
108109
action: (script: Script, e: editor.IStandaloneCodeEditor) => void;
109110
}[];
110111
};
@@ -275,11 +276,13 @@ function ScriptEditor() {
275276
{
276277
title: "保存",
277278
hotKey: KeyMod.CtrlCmd | KeyCode.KeyS,
279+
hotKeyString: "Ctrl+S",
278280
action: save,
279281
},
280282
{
281283
title: "另存为",
282284
hotKey: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyS,
285+
hotKeyString: "Ctrl+Shift+S",
283286
action: saveAs,
284287
},
285288
],
@@ -290,6 +293,7 @@ function ScriptEditor() {
290293
{
291294
title: "调试",
292295
hotKey: KeyMod.CtrlCmd | KeyCode.F5,
296+
hotKeyString: "Ctrl+F5",
293297
tooltip:
294298
"只有后台脚本/定时脚本才能调试, 且调试模式下不对进行权限校验(例如@connect)",
295299
action: async (script, e) => {
@@ -581,7 +585,7 @@ function ScriptEditor() {
581585
droplist={
582586
<Menu
583587
style={{
584-
backgroundColor: "var(--color-bg-2)",
588+
backgroundColor: "var(--color-secondary)",
585589
padding: "0",
586590
margin: "0",
587591
borderRadius: "0",
@@ -593,6 +597,8 @@ function ScriptEditor() {
593597
style={{
594598
width: "100%",
595599
textAlign: "left",
600+
alignSelf: "center",
601+
verticalAlign: "middle",
596602
}}
597603
key={`sm_${menuItem.title}`}
598604
size="mini"
@@ -607,29 +613,28 @@ function ScriptEditor() {
607613
});
608614
}}
609615
>
610-
{menuItem.title}
611-
</Button>
612-
);
613-
if (menuItem.tooltip) {
614-
return (
615-
<Menu.Item
616-
key={`m_${i.toString()}`}
616+
<div
617617
style={{
618-
height: "unset",
619-
padding: "0",
620-
lineHeight: "unset",
618+
minWidth: "70px",
619+
float: "left",
620+
fontSize: "14px",
621621
}}
622622
>
623-
<Tooltip
624-
key={`m${i.toString()}`}
625-
position="right"
626-
content={menuItem.tooltip}
627-
>
628-
{btn}
629-
</Tooltip>
630-
</Menu.Item>
631-
);
632-
}
623+
{menuItem.title}
624+
</div>
625+
<div
626+
style={{
627+
minWidth: "50px",
628+
float: "left",
629+
color: "rgb(165 165 165)",
630+
fontSize: "12px",
631+
lineHeight: "22px", // 不知道除此以外怎么垂直居中
632+
}}
633+
>
634+
{menuItem.hotKeyString}
635+
</div>
636+
</Button>
637+
);
633638
return (
634639
<Menu.Item
635640
key={`m_${i.toString()}`}
@@ -639,7 +644,17 @@ function ScriptEditor() {
639644
lineHeight: "unset",
640645
}}
641646
>
642-
{btn}
647+
{menuItem.tooltip ? (
648+
<Tooltip
649+
key={`m${i.toString()}`}
650+
position="right"
651+
content={menuItem.tooltip}
652+
>
653+
{btn}
654+
</Tooltip>
655+
) : (
656+
btn
657+
)}
643658
</Menu.Item>
644659
);
645660
})}

0 commit comments

Comments
 (0)