Skip to content

Commit d94cad2

Browse files
authored
feat: 新增「猫咪设置 > 模型设置 > 忽略鼠标事件」配置项 (#936)
1 parent fe41f58 commit d94cad2

8 files changed

Lines changed: 28 additions & 3 deletions

File tree

src/composables/useDevice.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { PhysicalPosition } from '@tauri-apps/api/dpi'
33
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow'
44
import { isNil } from 'es-toolkit'
55
import { Ticker } from 'pixi.js'
6-
import { onMounted, onUnmounted, ref } from 'vue'
6+
import { onMounted, onUnmounted, ref, watch } from 'vue'
77

88
import { useAppStore } from '@/stores/app'
99
import { useCatStore } from '@/stores/cat'
@@ -83,14 +83,20 @@ export function useDevice() {
8383

8484
scaleFactor.value = payload.scaleFactor
8585
})
86-
87-
Ticker.shared.add(tickerCallback)
8886
})
8987

9088
onUnmounted(() => {
9189
Ticker.shared.remove(tickerCallback)
9290
})
9391

92+
watch(() => catStore.model.ignoreMouse, (value) => {
93+
if (value) {
94+
return Ticker.shared.remove(tickerCallback)
95+
}
96+
97+
return Ticker.shared.add(tickerCallback)
98+
}, { immediate: true })
99+
94100
const startListening = () => {
95101
invoke(INVOKE_KEY.START_DEVICE_LISTENING)
96102
}

src/locales/en-US.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"modelSettings": "Model Settings",
1515
"mirrorMode": "Mirror Mode",
1616
"mouseMirror": "Mouse Mirror",
17+
"ignoreMouse": "Ignore Mouse Events",
1718
"windowSettings": "Window Settings",
1819
"passThrough": "Pass Through",
1920
"alwaysOnTop": "Always on Top",
@@ -30,6 +31,7 @@
3031
"hints": {
3132
"mirrorMode": "When enabled, the model will be mirrored horizontally.",
3233
"mouseMirror": "When enabled, the mouse will mirror the hand movement.",
34+
"ignoreMouse": "When enabled, the model will not respond to mouse events. Useful for keyboard mode or gamepad mode.",
3335
"motionSound": "When enabled, the model will play corresponding sound effects when performing actions (if they exist).",
3436
"behavior": "When enabled, motions and expressions can be configured and triggered.",
3537
"passThrough": "When enabled, clicks pass through the window without affecting it.",

src/locales/pt-BR.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"modelSettings": "Configurações do Modelo",
1515
"mirrorMode": "Modo Espelho",
1616
"mouseMirror": "Espelho do Mouse",
17+
"ignoreMouse": "Ignorar Eventos do Mouse",
1718
"windowSettings": "Configurações da Janela",
1819
"passThrough": "Janela Transparente",
1920
"alwaysOnTop": "Sempre no Topo",
@@ -30,6 +31,7 @@
3031
"hints": {
3132
"mirrorMode": "Quando ativado, o modelo será invertido horizontalmente.",
3233
"mouseMirror": "Quando ativado, o mouse espelhará o movimento da mão.",
34+
"ignoreMouse": "Quando ativado, o modelo não responderá a eventos do mouse. Útil para o modo teclado ou modo controle.",
3335
"motionSound": "Quando ativado, o modelo reproduzirá efeitos sonoros correspondentes ao executar ações (se existirem).",
3436
"behavior": "Quando ativado, movimentos e expressões podem ser configurados e acionados.",
3537
"passThrough": "Quando ativado, a janela não afetará operações em outros aplicativos.",

src/locales/vi-VN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"modelSettings": "Cài đặt Mô hình",
1515
"mirrorMode": "Chế độ gương",
1616
"mouseMirror": "Phản chiếu chuột",
17+
"ignoreMouse": "Bỏ qua sự kiện chuột",
1718
"windowSettings": "Cài đặt Cửa sổ",
1819
"passThrough": "Click xuyên",
1920
"alwaysOnTop": "Luôn trên cùng",
@@ -30,6 +31,7 @@
3031
"hints": {
3132
"mirrorMode": "Bật để lật ngang mô hình.",
3233
"mouseMirror": "Khi bật, chuột của mô hình sẽ phản chiếu theo chuyển động chuột thực tế.",
34+
"ignoreMouse": "Khi bật, mô hình sẽ không phản hồi sự kiện chuột. Hữu ích cho chế độ bàn phím hoặc chế độ tay cầm.",
3335
"motionSound": "Khi bật, mô hình sẽ phát các âm thanh tương ứng khi thực hiện hành động (nếu tồn tại).",
3436
"behavior": "Khi bật, các hành động và biểu cảm có thể được cấu hình và kích hoạt.",
3537
"passThrough": "Bật để cửa sổ không ảnh hưởng đến thao tác trên ứng dụng khác.",

src/locales/zh-CN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"modelSettings": "模型设置",
1515
"mirrorMode": "镜像模式",
1616
"mouseMirror": "鼠标镜像",
17+
"ignoreMouse": "忽略鼠标事件",
1718
"windowSettings": "窗口设置",
1819
"passThrough": "窗口穿透",
1920
"alwaysOnTop": "窗口置顶",
@@ -30,6 +31,7 @@
3031
"hints": {
3132
"mirrorMode": "启用后,模型将水平镜像翻转。",
3233
"mouseMirror": "启用后,鼠标将镜像跟随手部移动。",
34+
"ignoreMouse": "启用后,模型将不再响应鼠标事件,适用于键盘模式或手柄模式。",
3335
"motionSound": "启用后,模型执行动作时会播放对应音效(如果存在)。",
3436
"behavior": "启用后,可以配置和触发模型的动作与表情。",
3537
"passThrough": "启用后,窗口不影响对其他应用程序的操作。",

src/locales/zh-TW.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"modelSettings": "模型設定",
1515
"mirrorMode": "鏡像模式",
1616
"mouseMirror": "滑鼠游標鏡像",
17+
"ignoreMouse": "忽略滑鼠事件",
1718
"windowSettings": "視窗設定",
1819
"passThrough": "視窗穿透",
1920
"alwaysOnTop": "視窗置頂",
@@ -30,6 +31,7 @@
3031
"hints": {
3132
"mirrorMode": "啟用後,模型將水平鏡像翻轉。",
3233
"mouseMirror": "啟用後,滑鼠游標將鏡像跟隨手部移動。",
34+
"ignoreMouse": "啟用後,模型將不再回應滑鼠事件,適用於鍵盤模式或手柄模式。",
3335
"motionSound": "啟用後,模型執行動作時會播放對應音效(如果存在)。",
3436
"behavior": "啟用後,可以配置和觸發模型的動作與表情。",
3537
"passThrough": "啟用後,視窗不影響對其他應用程式的操作。",

src/pages/preference/components/cat/index.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ const catStore = useCatStore()
2525
<Switch v-model:checked="catStore.model.mouseMirror" />
2626
</ProListItem>
2727

28+
<ProListItem
29+
:description="$t('pages.preference.cat.hints.ignoreMouse')"
30+
:title="$t('pages.preference.cat.labels.ignoreMouse')"
31+
>
32+
<Switch v-model:checked="catStore.model.ignoreMouse" />
33+
</ProListItem>
34+
2835
<ProListItem
2936
:description="$t('pages.preference.cat.hints.motionSound')"
3037
:title="$t('pages.preference.cat.labels.motionSound')"

src/stores/cat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface CatStore {
99
behavior: boolean
1010
autoReleaseDelay: number
1111
maxFPS: number
12+
ignoreMouse: boolean
1213
}
1314
window: {
1415
visible: boolean
@@ -54,6 +55,7 @@ export const useCatStore = defineStore('cat', () => {
5455
behavior: true,
5556
autoReleaseDelay: 3,
5657
maxFPS: 60,
58+
ignoreMouse: false,
5759
})
5860

5961
const window = reactive<CatStore['window']>({

0 commit comments

Comments
 (0)