import { addDialog } from "@/components/ReDialog";
// import { ref, h } from "vue";
import OurPlayer from "@/components/VideoPlayer/OurPlayer.vue";
// import { http } from "@/utils/http";

export function welcomeUtil() {
  // const currentPlayingIndex = ref(-1);
  function openDialog(title = "视频", row) {
    const highlights = [
      // 进度条时间点高亮
      {
        text: row.event_type,
        time: row.relative_time
      }
    ];
    sessionStorage.setItem("video_url", row.video_dir);
    sessionStorage.setItem("highlights", JSON.stringify(highlights));
    console.log(row.video_dir, "row.video_dir");
    addDialog({
      title: `${title}用户`,
      width: "40%",
      draggable: true,
      fullscreenIcon: true,
      closeOnClickModal: false,
      contentRenderer: () => <OurPlayer></OurPlayer>
      // return h(
      //   "video",
      //   {
      //     controls: true,
      //     id: "video-" + index,
      //     onPlay: () => playVideo(row, index)
      //   },
      //   [h("source", { src: row.video_dir, type: "video/mp4" })]
      // );
    });
  }
  // function playVideo(row, index) {
  //   if (currentPlayingIndex.value !== -1) {
  //     const videoElement = document.getElementById(
  //       "video-" + currentPlayingIndex.value
  //     );
  //     videoElement.pause(); // 暂停当前正在播放的视频
  //   }
  //   currentPlayingIndex.value = index;
  // }

  return {
    openDialog
  };
}
