Home.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div id="app">
  3. <Slider @select-nav="selectNav" :index="navIndex" v-show="!closeOthers"></Slider>
  4. <div class="main">
  5. <div :class="{ 'history-wrap': true, 'history-wrap-open': !closeOthers && navIndex > -1 }">
  6. <History
  7. @set-new="
  8. () => {
  9. showDialog = false;
  10. }
  11. "
  12. @handle-click="selectHistory"
  13. />
  14. </div>
  15. <div class="wrap">
  16. <Index :number="swiperNumber" v-if="navIndex === -1" @select-nav="selectNav" />
  17. <div class="border-wrap" v-else>
  18. <div>
  19. <header>
  20. <div>
  21. <img src="@/assets/other/robot.gif" width="52" />
  22. <p>
  23. 信通小数<span>{{ slider[navIndex].title }}</span>
  24. </p>
  25. <span>{{ slider[navIndex].dialog }}</span>
  26. </div>
  27. </header>
  28. <section :class="{ 'section-padding': showDialog }">
  29. <Answer v-if="navIndex === 0 && !showDialog" />
  30. <Document v-if="navIndex === 1 && !showDialog" />
  31. <GenPic v-if="navIndex === 2 && !showDialog" />
  32. <GenDocument v-if="navIndex === 3 && !showDialog" />
  33. <DocumentAnswer v-if="navIndex === 4 && !showDialog" />
  34. <DocumentQuestion v-if="navIndex === 5 && !showDialog" />
  35. <PicArticle v-if="navIndex === 6 && !showDialog" />
  36. <Analysis v-if="navIndex === 7 && !showDialog" />
  37. <dialog-wrap
  38. v-if="showDialog"
  39. :agentInfo="data"
  40. :userInfo="userInfo"
  41. :isSetting="false"
  42. :readonly="readonly"
  43. @setReadonly="setReadonly"
  44. />
  45. </section>
  46. <footer>
  47. <message-input :readonly="readonly" eventName="open-dialog" />
  48. </footer>
  49. <a-tooltip :content="closeOthers ? '收起' : '展开'">
  50. <div @click="openAll">
  51. <img src="@/assets/other/open.svg" width="20" v-if="closeOthers" />
  52. <img src="@/assets/other/close.svg" width="20" v-else />
  53. </div>
  54. </a-tooltip>
  55. </div>
  56. </div>
  57. </div>
  58. <right v-if="navIndex === 0 || navIndex === 2" />
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. import Right from "../components/Right.vue";
  64. import DialogWrap from "../components/DialogWrap.vue";
  65. import Slider from "../components/Slider.vue";
  66. import History from "../components/History.vue";
  67. import MessageInput from "../components/MessageInput.vue";
  68. import Index from "./Index.vue";
  69. import Answer from "./Answer.vue";
  70. import Document from "./Document.vue";
  71. import GenPic from "./GenPic.vue";
  72. import GenDocument from "./GenDocument.vue";
  73. import PicArticle from "./PicArticle.vue";
  74. import DocumentAnswer from "./DocumentAnswer.vue";
  75. import DocumentQuestion from "./DocumentQuestion.vue";
  76. import Analysis from "./Analysis.vue";
  77. import { defineComponent, ref, onMounted, inject, onBeforeUnmount } from "vue";
  78. export default defineComponent({
  79. components: {
  80. Right,
  81. Slider,
  82. History,
  83. Index,
  84. Answer,
  85. MessageInput,
  86. DialogWrap,
  87. Document,
  88. GenPic,
  89. GenDocument,
  90. PicArticle,
  91. DocumentAnswer,
  92. DocumentQuestion,
  93. Analysis
  94. },
  95. setup() {
  96. const { config, helper } = inject("$global");
  97. const closeOthers = ref(false);
  98. const swiperNumber = ref(5);
  99. const navIndex = ref(-1);
  100. const readonly = ref(false);
  101. const showDialog = ref(false);
  102. const userInfo = {
  103. name: "奇橙",
  104. avatar: "https://s21.ax1x.com/2024/04/18/pFzyA0O.png"
  105. };
  106. const data = {
  107. avatar: "https://s21.ax1x.com/2024/04/18/pFzyA0O.png",
  108. title: "论文解读助手",
  109. name: "@奇橙",
  110. content: "你好,我是一名专业的论文检索助手,可以帮你查找并详细解读你需要的学术论文。",
  111. hot: 345,
  112. star: 34,
  113. id: "111"
  114. };
  115. const openAll = () => {
  116. closeOthers.value = !closeOthers.value;
  117. };
  118. const selectNav = (index) => {
  119. navIndex.value = index;
  120. if (index === -1) {
  121. swiperNumber.value = 5;
  122. } else {
  123. swiperNumber.value = 4;
  124. }
  125. helper.$bus.emit("stop-writing");
  126. showDialog.value = false;
  127. };
  128. const setReadonly = (status) => {
  129. readonly.value = status;
  130. };
  131. const selectHistory = (id) => {
  132. console.log(id);
  133. };
  134. onMounted(() => {
  135. helper.$bus.on("open-dialog", (value) => {
  136. showDialog.value = true;
  137. setTimeout(() => {
  138. helper.$bus.emit("send-message", value);
  139. }, 300);
  140. });
  141. });
  142. onBeforeUnmount(() => {
  143. helper.$bus.off("open-dialog");
  144. });
  145. return {
  146. navIndex,
  147. selectNav,
  148. swiperNumber,
  149. slider: config.slider,
  150. readonly,
  151. userInfo,
  152. setReadonly,
  153. data,
  154. showDialog,
  155. selectHistory,
  156. closeOthers,
  157. openAll
  158. };
  159. }
  160. });
  161. </script>
  162. <style lang="scss" scoped>
  163. .main {
  164. flex: 1;
  165. position: relative;
  166. display: flex;
  167. .history-wrap {
  168. width: 0px;
  169. opacity: 0;
  170. overflow: hidden;
  171. transition-duration: 0.3s;
  172. transition-property: width;
  173. &-open {
  174. opacity: 1;
  175. width: 260px;
  176. }
  177. }
  178. .wrap {
  179. flex: 1;
  180. }
  181. .border-wrap {
  182. position: relative;
  183. padding: 30px 16px 30px 40px;
  184. flex: 1;
  185. height: 100%;
  186. > div {
  187. width: 100%;
  188. height: 100%;
  189. background: #fff;
  190. box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.03);
  191. border-radius: 14px;
  192. display: flex;
  193. flex-direction: column;
  194. padding: 0 32px;
  195. position: relative;
  196. > div {
  197. position: absolute;
  198. bottom: -10px;
  199. left: -10px;
  200. z-index: 10;
  201. width: 38px;
  202. height: 38px;
  203. border-radius: 20px;
  204. background: #fff;
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. cursor: pointer;
  209. }
  210. > header {
  211. > div {
  212. display: inline-block;
  213. margin-top: 20px;
  214. > img {
  215. transform: translateX(-12px);
  216. }
  217. > p {
  218. font-size: 36px;
  219. font-weight: bold;
  220. color: #000;
  221. > span {
  222. font-weight: bold;
  223. background: linear-gradient(180deg, #41d98c, #31c4c9);
  224. -webkit-background-clip: text;
  225. -webkit-text-fill-color: transparent;
  226. }
  227. }
  228. > span {
  229. display: block;
  230. color: #000;
  231. font-size: 15px;
  232. margin: 5px 0 32px;
  233. }
  234. }
  235. }
  236. > section {
  237. flex: 1;
  238. overflow: hidden;
  239. &.section-padding {
  240. padding-bottom: 50px;
  241. }
  242. }
  243. > footer {
  244. }
  245. }
  246. }
  247. }
  248. </style>