Skip to content

Commit

Permalink
fix: 修复Windows下无法设置win快捷键
Browse files Browse the repository at this point in the history
  • Loading branch information
Pylogmon committed May 16, 2023
1 parent 8e1a690 commit 5b98a4a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/windows/Config/pages/ShortCutConfig/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { TextField, Button, InputAdornment } from '@mui/material';
import React, { useEffect, useState } from 'react';
import { invoke } from '@tauri-apps/api/tauri';
import { useAtom } from 'jotai';
import React from 'react';
import { shortcutTranslateAtom, shortcutPersistentAtom, shortcutOcrAtom } from '../..';
import ConfigItem from '../../components/ConfigItem';
import ConfigList from '../../components/ConfigList';
Expand All @@ -10,9 +11,16 @@ export default function ShortCutConfig() {
const [shortcutTranslate, setShortcutTranslate] = useAtom(shortcutTranslateAtom);
const [shortcutPersistent, setShortcutPersistent] = useAtom(shortcutPersistentAtom);
const [shortcutOcr, setShortcutOcr] = useAtom(shortcutOcrAtom);
const [ismacos, setIsmacos] = useState(false);

const supportKey = ['Control', 'Shift', 'Alt', 'Command', 'Meta', 'Option'];

useEffect(() => {
invoke('is_macos').then((v) => {
setIsmacos(v);
});
});

function keyDown(e, value, setKey) {
if (e.key.length == 1) {
if (value) {
Expand All @@ -24,6 +32,9 @@ export default function ShortCutConfig() {
}
} else {
if (supportKey.includes(e.key)) {
if (e.key == 'Meta' && !ismacos) {
e.key = 'Super';
}
if (value) {
let values = value.split('+');
if (!value.startsWith('F') && !values.includes(e.key)) {
Expand Down

0 comments on commit 5b98a4a

Please sign in to comment.