alibaba/hooks

`useLongPress` 在 macOS 的 Tauri 应用中无法生效。

Open

#2 861 ouverte le 24 sept. 2025

Voir sur GitHub
 (4 commentaires) (1 réaction) (1 assigné)TypeScript (2 471 forks)batch import
bughelp wanted

Métriques du dépôt

Stars
 (12 849 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

https://github.com/user-attachments/assets/49616b1f-d4cf-48f8-b479-7b01e68ccbd6

import { convertFileSrc } from "@tauri-apps/api/core";
import { openPath } from "@tauri-apps/plugin-opener";
import { useLongPress } from "ahooks";
import { type FC, useRef } from "react";
import type { App as AppProps } from "@/stores/app";
import { hidePanel } from "@/utils/nsPanel";

const App: FC<AppProps> = (props) => {
  const { name, icon, path } = props;
  const containerRef = useRef<HTMLDivElement>(null);

  const handleLongPress = () => {
    console.log("handleLongPress");
  };

  const openApp = () => {
    console.log("openApp");

    openPath(path);

    hidePanel();
  };

  useLongPress(handleLongPress, containerRef, {
    onClick: openApp,
  });

  return (
    <div
      className="grid place-items-center active:opacity-70"
      ref={containerRef}
    >
      <img alt={name} className="size-24" src={convertFileSrc(icon)} />

      <span className="truncate">{name}</span>
    </div>
  );
};

export default App;

Guide contributeur