Skip to content

Commit 01b13a1

Browse files
committed
fix: 切换章节后热键失效
1 parent 8a6d4b9 commit 01b13a1

5 files changed

Lines changed: 13 additions & 3 deletions

File tree

packages/web/src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Category from './Category/index.vue';
44
import Tabs from './Tabs/index.vue';
55
import RuleEmpty from './RuleEmpty/index.vue';
66

7-
export function useComponent(app: App<Element>) {
7+
export default function useComponent(app: App<Element>) {
88
app.component('ARCover', Cover);
99
app.component('ARCategory', Category);
1010
app.component('ARTabs', Tabs);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { App } from 'vue';
2+
3+
export default function useDirective(app: App) {
4+
app.directive('focus', {
5+
mounted: (el) => el.focus()
6+
});
7+
}

packages/web/src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { createApp } from 'vue';
22
import App from './App.vue';
33
import router from './router';
4-
import { useComponent } from './components';
4+
import useComponent from './components';
5+
import useDirective from './directive';
56
import './assets';
67
import './plugins/vsc-ui';
78
import './plugins/antd';
@@ -17,6 +18,7 @@ const app = createApp(App);
1718
app.use(router);
1819
app.use(createPinia());
1920
useComponent(app);
21+
useDirective(app);
2022

2123
router.beforeEach((to, _from, next) => {
2224
const { query, path } = to;

packages/web/src/pages/pc/content/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<!-- 加载 -->
1212
<a-spin v-if="loading" :spinning="loading" class="h-full w-full items-center justify-center !flex" />
1313
<!-- 阅读区域 -->
14-
<div ref="contentRef" tabindex="0" class="relative h-full flex flex-1 flex-col overflow-y-auto indent-2em outline-none sm:px-60">
14+
<div ref="contentRef" v-focus tabindex="0" class="relative h-full flex flex-1 flex-col overflow-y-auto indent-2em outline-none sm:px-60">
1515
<!-- 漫画 -->
1616
<template v-if="contentType === ContentType.MANGA">
1717
<img v-for="(row, idx) in content" :key="idx" :src="row" />

packages/web/src/pages/vscode/content/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<div
77
id="text-container"
88
ref="contentRef"
9+
v-focus
910
tabindex="0"
1011
class="flex-1 overflow-y-auto whitespace-pre-wrap break-words p-10 indent-2em lh-1.5em outline-none"
1112
:style="{

0 commit comments

Comments
 (0)