Sidebar.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <script setup lang="ts">
  2. import { ref } from 'vue';
  3. import { type Conversation, type Plugin } from '../../api/dto';
  4. import PluginPanel from './PluginPanel.vue';
  5. import ConversationList from './ConversationList.vue';
  6. interface Props {
  7. conversations: Conversation[];
  8. currentConversation: Conversation;
  9. plugins: Plugin[];
  10. }
  11. interface Emits {
  12. (e: 'new-conversation'): void;
  13. (e: 'toggle-plugin-panel'): void;
  14. (e: 'toggle-plugin', pluginId: string): void;
  15. (e: 'select-conversation', conv: Conversation): void;
  16. }
  17. const props = defineProps<Props>();
  18. const emit = defineEmits<Emits>();
  19. const showPluginPanel = ref(false);
  20. function handleTogglePluginPanel() {
  21. showPluginPanel.value = !showPluginPanel.value;
  22. emit('toggle-plugin-panel');
  23. }
  24. </script>
  25. <template>
  26. <aside class="sidebar">
  27. <!-- 顶部操作区 -->
  28. <div class="sidebar-top">
  29. <button class="action-btn" @click="$emit('new-conversation')">
  30. <svg width="16" height="16" viewBox="0 0 16 16" fill="none">
  31. <path d="M8 1V15M1 8H15" stroke="currentColor" stroke-width="2" stroke-linecap="round" />
  32. </svg>
  33. <span>新建对话</span>
  34. </button>
  35. <!-- <button class="plugin-btn" :class="{ active: showPluginPanel }" @click="handleTogglePluginPanel">
  36. <svg width="16" height="16" viewBox="0 0 16 16" fill="none">
  37. <path
  38. d="M8 2L10 6H6L8 2Z"
  39. stroke="currentColor"
  40. stroke-width="1.5"
  41. stroke-linecap="round"
  42. stroke-linejoin="round"
  43. />
  44. <path
  45. d="M2 8L6 10L6 6L2 8Z"
  46. stroke="currentColor"
  47. stroke-width="1.5"
  48. stroke-linecap="round"
  49. stroke-linejoin="round"
  50. />
  51. <path
  52. d="M14 8L10 6L10 10L14 8Z"
  53. stroke="currentColor"
  54. stroke-width="1.5"
  55. stroke-linecap="round"
  56. stroke-linejoin="round"
  57. />
  58. <path
  59. d="M8 14L6 10H10L8 14Z"
  60. stroke="currentColor"
  61. stroke-width="1.5"
  62. stroke-linecap="round"
  63. stroke-linejoin="round"
  64. />
  65. </svg>
  66. <span>插件管理</span>
  67. </button> -->
  68. </div>
  69. <!-- 插件面板 -->
  70. <!-- <PluginPanel :plugins="plugins" :show="showPluginPanel" @toggle="emit('toggle-plugin', $event)" /> -->
  71. <!-- 会话列表 -->
  72. <ConversationList
  73. :conversations="props.conversations"
  74. :current-id="props.currentConversation.id"
  75. @select="emit('select-conversation', $event)"
  76. />
  77. </aside>
  78. </template>
  79. <style scoped lang="less">
  80. .jeesite-page-wrapper .ant-layout .sidebar {
  81. background-color: #fff;
  82. }
  83. .sidebar {
  84. width: 280px;
  85. height: 100%;
  86. display: flex;
  87. flex-direction: column;
  88. flex-shrink: 0;
  89. transition:
  90. background-color 0.3s,
  91. border-color 0.3s;
  92. }
  93. /* 顶部操作区 */
  94. .sidebar-top {
  95. padding: 12px;
  96. border-bottom: 1px solid @cb-vscode-panel-border;
  97. display: flex;
  98. gap: 8px;
  99. }
  100. .action-btn,
  101. .plugin-btn {
  102. display: flex;
  103. align-items: center;
  104. justify-content: center;
  105. gap: 8px;
  106. flex: 1;
  107. padding: 10px 12px;
  108. background-color: @cb-vscode-input-background;
  109. color: @cb-text-primary;
  110. border: 1px solid @cb-vscode-widget-border;
  111. border-radius: 6px;
  112. font-size: 13px;
  113. font-weight: 500;
  114. cursor: pointer;
  115. transition: all 0.2s;
  116. }
  117. .action-btn:hover,
  118. .plugin-btn:hover {
  119. background-color: @cb-vscode-list-hoverBackground;
  120. border-color: @cb-accent;
  121. }
  122. .plugin-btn.active {
  123. background-color: @cb-accent;
  124. color: white;
  125. border-color: @cb-accent-light;
  126. }
  127. .action-btn svg,
  128. .plugin-btn svg {
  129. flex-shrink: 0;
  130. }
  131. </style>