Header.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use client'
  2. import { BsCaretDownFill } from "react-icons/bs";
  3. import { useSession, signIn, signOut } from "next-auth/react"
  4. import { createRef, useEffect, useState } from "react";
  5. import { trpc } from "@/lib/trpc";
  6. import Cookies from 'js-cookie';
  7. import { useAtomValue } from "jotai";
  8. import { instantDataAtom, stepsNodesAtom } from "../store";
  9. import { exportFlowToDocx } from "../export";
  10. import { BsCloudDownload } from "react-icons/bs";
  11. export default function Header() {
  12. const { data: session, status } = useSession()
  13. const logOut = async () => {
  14. const res = await fetch("https://beta.api.cocorobo.cn/api/logout", {
  15. method: "POST", credentials: 'include'
  16. });
  17. const res1 = await signOut({ redirect: false })
  18. debugger
  19. }
  20. return (
  21. <div className="navbar shrink-0 bg-base-100 shadow-xl rounded-box justify-center relative">
  22. {/* <div className="dropdown">
  23. <div tabIndex={0} role="button" className="btn btn-sm btn-wide btn-ghost">选择对话<BsCaretDownFill /></div>
  24. <ul tabIndex={0} className="dropdown-content menu bg-base-100 rounded-box z-[2] w-52 p-2 shadow">
  25. <li><a>Item 1</a></li>
  26. <li><a>Item 2</a></li>
  27. </ul>
  28. </div> */}
  29. <div className="absolute right-4 flex items-center">
  30. {status === 'authenticated'
  31. ? (
  32. <div className="flex gap-2 items-center">
  33. <p>Hi, </p>
  34. <div className="dropdown dropdown-bottom dropdown-end">
  35. <label tabIndex={0} className="btn btn-sm m-1">{session.user?.name}</label>
  36. <ul tabIndex={0} className="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52">
  37. <li><a onClick={logOut}>退出登录</a></li>
  38. </ul>
  39. </div>
  40. </div>
  41. ) : null
  42. }
  43. </div>
  44. </div >
  45. )
  46. }