Skip to content

Commit 0cc4631

Browse files
committed
fix: the leader key cannot be disabled
1 parent fce5ea3 commit 0cc4631

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

web/src/i18n/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const en = {
136136
desc2: 'Requires more steps, but completely avoids system conflicts.'
137137
},
138138
enable: 'Enable Leader Key',
139+
tip: 'When assigned as a Leader Key, this key functions exclusively as a shortcut trigger and loses its default behavior.',
139140
placeholder: 'Please press the Leader Key',
140141
shiftRight: 'Right Shift',
141142
ctrlRight: 'Right Ctrl',

web/src/i18n/locales/zh.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ const zh = {
120120
desc2: '步骤较多,但能完美避开系统键位冲突。'
121121
},
122122
enable: '启用引导键',
123+
tip: '设为引导键后,该按键将仅用于触发快捷键,不再作为普通按键使用。',
123124
placeholder: '请按下引导键',
124125
shiftRight: '右 Shift',
125126
ctrlRight: '右 Ctrl',

web/src/pages/desktop/menu/keyboard/leader-key.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,12 @@ export const LeaderKey = () => {
7979
function submit() {
8080
if (isLoading) return;
8181

82-
if (tempLeaderKey === leaderKey || (!isLeaderKeyEnable && !leaderKey)) {
82+
const key = isLeaderKeyEnable ? tempLeaderKey : '';
83+
if (key === leaderKey) {
8384
closeModal();
8485
return;
8586
}
8687

87-
const key = isLeaderKeyEnable ? tempLeaderKey : '';
88-
8988
setIsLoading(true);
9089

9190
api
@@ -111,7 +110,7 @@ export const LeaderKey = () => {
111110
<span>{t('keyboard.leaderKey.title')}</span>
112111
</div>
113112

114-
<Modal width={500} keyboard={false} footer={null} open={isModalOpen} onCancel={closeModal}>
113+
<Modal width={510} keyboard={false} footer={null} open={isModalOpen} onCancel={closeModal}>
115114
<div className="my-3 flex flex-col space-y-3">
116115
{/* title */}
117116
<div className="flex flex-col space-y-1">
@@ -163,7 +162,8 @@ export const LeaderKey = () => {
163162

164163
{/* Keyboard recorder */}
165164
{isLeaderKeyEnable && (
166-
<div className="mt-5 flex flex-col space-y-5 rounded-lg bg-neutral-800 px-5 py-10">
165+
<div className="flex flex-col space-y-5 rounded-lg bg-neutral-800 px-5 py-5">
166+
<span className="text-sm text-neutral-400">{t('keyboard.leaderKey.tip')}</span>
167167
<Input
168168
value={tempLeaderKey}
169169
className="flex-1"
@@ -178,8 +178,10 @@ export const LeaderKey = () => {
178178
<div
179179
key={key.value}
180180
className={clsx(
181-
'flex w-28 cursor-pointer items-center justify-center space-x-1 rounded py-1 shadow-lg shadow-neutral-800 outline hover:shadow-xl',
182-
key.value === tempLeaderKey ? 'outline-blue-500' : 'outline-neutral-700'
181+
'flex w-28 cursor-pointer items-center justify-center space-x-1 rounded py-1 shadow-lg shadow-neutral-800 outline',
182+
key.value === tempLeaderKey
183+
? 'text-neutral-300 outline-blue-500'
184+
: 'text-neutral-500 outline-neutral-700 hover:shadow-xl hover:outline-neutral-600'
183185
)}
184186
onClick={() => setTempLeaderKey((k) => (k === key.value ? '' : key.value))}
185187
>
@@ -193,9 +195,8 @@ export const LeaderKey = () => {
193195

194196
<div className="flex w-full justify-center pt-5">
195197
<Button
196-
className="w-28"
198+
className="w-24"
197199
type="primary"
198-
size="large"
199200
loading={isLoading}
200201
onClick={submit}
201202
>

0 commit comments

Comments
 (0)