mobeicanyue 8 месяцев назад
Родитель
Сommit
c9cd986cdf

+ 0 - 1
modules/web/src/components/ToolBar.vue

@@ -69,7 +69,6 @@ import API from '@api'
 import { CircleCheckFilled, Edit } from '@element-plus/icons-vue'
 import hotkeys from 'hotkeys-js'
 import { getSourceName, isInvaildSource, normalizeSource } from '../utils/souce'
-import { getSourceName, isInvaildSource } from '../utils/souce'
 
 const store = useSourceStore()
 const pull = () => {

+ 10 - 3
modules/web/src/utils/xboxGamepad.ts

@@ -34,7 +34,7 @@ interface GlobalState {
 const CONFIG: GamepadConfig = {
   DEBUG: false,              // 日志总开关
   AXIS_THRESHOLD: 0.7,      // 摇杆触发阈值
-  AXIS_COOLDOWN: 200,       // 摇杆触发冷却时间 (ms)
+  AXIS_COOLDOWN: 300,       // 摇杆触发冷却时间 (ms)
   DPAD_INDEX: {             // Xbox 标准映射
     UP: 12,
     DOWN: 13,
@@ -76,7 +76,7 @@ const state: GlobalState = {
  * @param direction 1 = 向下, -1 = 向上
  */
 function scrollPage(direction: number): void {
-  const offset = window.innerHeight - 80;
+  const offset = window.innerHeight - 110;
   const distance = direction === 1 ? offset : -offset;
 
   log(direction === 1 ? "🎮 翻页:向下" : "🎮 翻页:向上");
@@ -211,4 +211,11 @@ window.addEventListener("gamepadconnected", (e: GamepadEvent) => {
 
 window.addEventListener("gamepaddisconnected", (e: GamepadEvent) => {
   log("🎮 手柄已断开:", e.gamepad.id);
-});
+});
+
+export function initXboxGamepad(): void {
+  if (!running) {
+    running = true;
+    requestAnimationFrame(gamepadLoop);
+  }
+}

+ 2 - 1
modules/web/src/views/BookChapter.vue

@@ -113,7 +113,7 @@ import API from '@api'
 import { useLoading } from '@/hooks/loading'
 import { useThrottleFn } from '@vueuse/shared'
 import { isNullOrBlank } from '@/utils/utils'
-import '@/utils/xboxGamepad'
+import { initXboxGamepad } from '@/utils/xboxGamepad'
 
 const content = ref()
 // loading spinner
@@ -520,6 +520,7 @@ onMounted(async () => {
       document.title = (name as string) + ' | ' + chapters[chapterIndex].title
     }),
   )
+  initXboxGamepad()
 })
 
 onUnmounted(() => {