mirror of
https://github.com/infinilabs/coco-app.git
synced 2025-12-16 11:37:47 +01:00
* feat: voice input support for search and chat * chore: add mic-recorder plugin * refactor: check microphone permission before recording * feat: realize sound wave effects * chore: remove mic-recorder plugin
29 lines
740 B
TypeScript
29 lines
740 B
TypeScript
import { useEffect } from "react";
|
|
|
|
import { useAppStore } from "@/stores/appStore";
|
|
import platformAdapter from "@/utils/platformAdapter";
|
|
|
|
export function useWindowEvents() {
|
|
const isPinned = useAppStore((state) => state.isPinned);
|
|
const visible = useAppStore((state) => state.visible);
|
|
|
|
useEffect(() => {
|
|
const handleBlur = async () => {
|
|
console.log("Window blurred");
|
|
if (isPinned || visible) {
|
|
return;
|
|
}
|
|
|
|
await platformAdapter.hideWindow();
|
|
console.log("Hide Coco");
|
|
};
|
|
|
|
window.addEventListener("blur", handleBlur);
|
|
|
|
// Clean up event listeners on component unmount
|
|
return () => {
|
|
window.removeEventListener("blur", handleBlur);
|
|
};
|
|
}, [isPinned, visible]);
|
|
}
|