mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-02-07 20:09:27 +08:00
设置增加按键退出
This commit is contained in:
parent
b7f3c98131
commit
9f3a54be0f
@ -92,7 +92,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, shallowRef } from 'vue';
|
import { computed, onMounted, onUnmounted, onUpdated, shallowRef } from 'vue';
|
||||||
import {
|
import {
|
||||||
mainSetting,
|
mainSetting,
|
||||||
MotaSetting,
|
MotaSetting,
|
||||||
@ -103,10 +103,12 @@ import {
|
|||||||
} from '../core/main/setting';
|
} from '../core/main/setting';
|
||||||
import settingText from '../data/settings.json';
|
import settingText from '../data/settings.json';
|
||||||
import { RightOutlined, LeftOutlined } from '@ant-design/icons-vue';
|
import { RightOutlined, LeftOutlined } from '@ant-design/icons-vue';
|
||||||
import { splitText } from '../plugin/utils';
|
import { keycode, splitText } from '../plugin/utils';
|
||||||
import Scroll from '../components/scroll.vue';
|
import Scroll from '../components/scroll.vue';
|
||||||
import { settingsOpened } from '../plugin/uiController';
|
import { settingsOpened } from '../plugin/uiController';
|
||||||
import { isMobile } from '../plugin/use';
|
import { isMobile } from '../plugin/use';
|
||||||
|
import { sleep } from 'mutate-animate';
|
||||||
|
import { KeyCode } from '../plugin/keyCodes';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
info?: MotaSetting;
|
info?: MotaSetting;
|
||||||
@ -170,6 +172,21 @@ function changeValue(value: number | boolean) {
|
|||||||
function exit() {
|
function exit() {
|
||||||
settingsOpened.value = false;
|
settingsOpened.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function key(e: KeyboardEvent) {
|
||||||
|
const c = keycode(e.keyCode);
|
||||||
|
if (c === KeyCode.Escape || c === KeyCode.KeyX) exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await sleep(50);
|
||||||
|
if (ancTe.plugin.ui.transition.value) await sleep(600);
|
||||||
|
document.addEventListener('keyup', key);
|
||||||
|
});
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
document.removeEventListener('keyup', key);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
Loading…
Reference in New Issue
Block a user