ChatAsideMenu.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <div class="chat-aside-container no-select">
  3. <div class="chat-aside-menu" :class="current_theme_klass">
  4. <div class="menu-content">
  5. <div class="menu-actions-top">
  6. <img class="header-logo-img" src="../../assets/logo.png" />
  7. </div>
  8. <div class="aside-menu-h-line"></div>
  9. <ChatAsideBtn
  10. :label="$t('conversation.chat_new')"
  11. img_name="chat-new-1"
  12. @active="handleMenuClick('/chat/qa')"
  13. />
  14. <ChatAsideBtn
  15. :label="$t('conversation.chat_history')"
  16. img_name="chat-history-1"
  17. @active="handleMenuClick('/chat/history')"
  18. />
  19. <ChatAsideBtn
  20. :label="$t('conversation.chat_smart')"
  21. img_name="chat-smart-1"
  22. @active="handleMenuClick('/chat/board')"
  23. />
  24. <div class="aside-menu-h-line"></div>
  25. <ChatAsideAgent
  26. v-for="item of agents_list"
  27. :label="item.name"
  28. :img="item.icon"
  29. :id="item.id"
  30. :key="item.id"
  31. @active="handleAgentClick(item.id)"
  32. @delete="handleAgentDelete(item.id)"
  33. />
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script setup>
  39. import { computed } from 'vue';
  40. import { useRouter } from 'vue-router';
  41. import { useThemeStore } from '../../base/store/use-theme';
  42. import { useRecentAgentStore } from '../../base/store/use-recent-agents';
  43. import { useAllAgentStore } from '../../base/store/use-all-agents';
  44. import { getIconIntelligent } from '../../modules/common/icon-map';
  45. import ChatAsideBtn from './ChatAsideBtn.vue';
  46. import ChatAsideAgent from './ChatAsideAgent.vue';
  47. const router = useRouter();
  48. const themeStore = useThemeStore();
  49. const recentAgents = useRecentAgentStore();
  50. const current_theme_klass = computed(() => {
  51. const theme = themeStore.value;
  52. return {
  53. 'chat-theme-light': theme === 'light',
  54. 'chat-theme-dark': theme === 'dark'
  55. };
  56. });
  57. // 最近使用的 智能体 列表
  58. const agents_list = computed(() => {
  59. const arr = [];
  60. const list = recentAgents.getList();
  61. const len = list.length;
  62. for (let i = 0; i < len; i++) {
  63. if (i >= 3) {
  64. break;
  65. }
  66. const item = list[i];
  67. arr.push({
  68. id: item.id,
  69. icon: getIconIntelligent(item.icon),
  70. name: item.name
  71. });
  72. }
  73. return arr;
  74. });
  75. const handleMenuClick = (path) => {
  76. router.push(path);
  77. };
  78. /**
  79. * 点击最近使用的Agent
  80. * @param agent_id
  81. */
  82. const handleAgentClick = (agent_id) => {
  83. router.push({
  84. path: '/chat/qa',
  85. query: {
  86. agent: agent_id
  87. }
  88. });
  89. };
  90. /**
  91. * 移除某个近期使用的Agent
  92. * @param agent_id
  93. */
  94. const handleAgentDelete = (agent_id) => {
  95. recentAgents.removeItem(agent_id);
  96. };
  97. </script>
  98. <style lang="css" scoped>
  99. .chat-aside-container {
  100. width: 74px;
  101. height: calc(100vh - 60px);
  102. display: flex;
  103. justify-content: flex-start;
  104. align-items: center;
  105. position: fixed;
  106. left: 0;
  107. top: 60px;
  108. z-index: 999;
  109. }
  110. .chat-aside-menu {
  111. width: 74px;
  112. padding-top: 90px;
  113. padding-bottom: 90px;
  114. display: flex;
  115. justify-content: center;
  116. align-items: center;
  117. flex-direction: column;
  118. background-repeat: no-repeat, no-repeat;
  119. background-size: contain, contain;
  120. background-position: top left, bottom left;
  121. }
  122. .chat-theme-light {
  123. background-image: url(../../assets/chat-aside/aside-menu-bg-wt-top.png),
  124. url(../../assets/chat-aside/aside-menu-bg-wt-bottom.png);
  125. }
  126. .chat-theme-dark {
  127. background-image: url(../../assets/chat-aside/aside-menu-bg-blk-top.png),
  128. url(../../assets/chat-aside/aside-menu-bg-blk-bottom.png);
  129. }
  130. .menu-content {
  131. width: 40px;
  132. }
  133. .menu-actions-top {
  134. margin-bottom: 10px;
  135. display: flex;
  136. justify-content: center;
  137. }
  138. .menu-content .menu-actions-top .header-logo-img {
  139. width: 30px;
  140. }
  141. .aside-menu-h-line {
  142. width: 28px;
  143. height: 2px;
  144. background-color: var(--color-border-2);
  145. margin-top: 10px;
  146. margin-bottom: 10px;
  147. margin-left: auto;
  148. margin-right: auto;
  149. }
  150. </style>