VersionSwitcher.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import _React from "react";
  2. import { Button, Space, Tooltip } from "antd";
  3. import { LeftOutlined, RightOutlined } from "@ant-design/icons";
  4. import type { VersionSwitcherProps } from "../../types/chat"
  5. export function VersionSwitcher({
  6. versions,
  7. currentVersion,
  8. onSwitch,
  9. }: VersionSwitcherProps) {
  10. if (versions.length <= 1) return null;
  11. const canGoPrev = currentVersion > 0;
  12. const canGoNext = currentVersion < versions.length - 1;
  13. const currentVersionInfo = versions[currentVersion];
  14. return (
  15. <div className="version-switcher">
  16. <Space align="center">
  17. <Button
  18. size="small"
  19. type="text"
  20. icon={<LeftOutlined />}
  21. disabled={!canGoPrev}
  22. onClick={() => canGoPrev && onSwitch(currentVersion - 1)}
  23. />
  24. <Tooltip
  25. title={
  26. <div>
  27. <div>
  28. 版本 {currentVersion + 1} / {versions.length}
  29. </div>
  30. <div>模型: {currentVersionInfo.model_id || "未知"}</div>
  31. </div>
  32. }
  33. >
  34. <span className="version-info">
  35. {currentVersion + 1} / {versions.length}
  36. </span>
  37. </Tooltip>
  38. <Button
  39. size="small"
  40. type="text"
  41. icon={<RightOutlined />}
  42. disabled={!canGoNext}
  43. onClick={() => canGoNext && onSwitch(currentVersion + 1)}
  44. />
  45. </Space>
  46. </div>
  47. );
  48. }