sd-sidebar.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import styles from "@/app/components/home.module.scss";
  2. import { IconButton } from "@/app/components/button";
  3. import GithubIcon from "@/app/icons/github.svg";
  4. import SDIcon from "@/app/icons/sd.svg";
  5. import ReturnIcon from "@/app/icons/return.svg";
  6. import Locale from "@/app/locales";
  7. import { Path, REPO_URL } from "@/app/constant";
  8. import { useNavigate } from "react-router-dom";
  9. import dynamic from "next/dynamic";
  10. import {
  11. SideBarContainer,
  12. SideBarBody,
  13. useDragSideBar,
  14. useHotKey,
  15. } from "@/app/components/sidebar";
  16. const SdPanel = dynamic(
  17. async () => (await import("@/app/components/sd/sd-panel")).SdPanel,
  18. {
  19. loading: () => null,
  20. },
  21. );
  22. export function SideBar(props: { className?: string }) {
  23. useHotKey();
  24. const { onDragStart, shouldNarrow } = useDragSideBar();
  25. const navigate = useNavigate();
  26. return (
  27. <SideBarContainer
  28. onDragStart={onDragStart}
  29. shouldNarrow={shouldNarrow}
  30. {...props}
  31. >
  32. <div className={styles["sidebar-header"]} data-tauri-drag-region>
  33. <div className={styles["sidebar-title"]} data-tauri-drag-region>
  34. <IconButton
  35. icon={<ReturnIcon />}
  36. bordered
  37. title={Locale.Chat.Actions.ChatList}
  38. onClick={() => navigate(Path.Chat)}
  39. />
  40. </div>
  41. <div className={styles["sidebar-logo"] + " no-dark"}>
  42. <SDIcon width={38} height={38} />
  43. </div>
  44. </div>
  45. <SideBarBody>
  46. <SdPanel />
  47. </SideBarBody>
  48. <div className={styles["sidebar-tail"]}>
  49. <div className={styles["sidebar-actions"]}>
  50. <div className={styles["sidebar-action"]}>
  51. <a href={REPO_URL} target="_blank" rel="noopener noreferrer">
  52. <IconButton icon={<GithubIcon />} shadow />
  53. </a>
  54. </div>
  55. </div>
  56. </div>
  57. </SideBarContainer>
  58. );
  59. }