Knowledge.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div id="app">
  3. <Slider>
  4. <Directory />
  5. </Slider>
  6. <div class="main">
  7. <header>
  8. <top-bar @choose-nav="chooseNav" />
  9. </header>
  10. <section>
  11. <dialog-wrap
  12. :suggestions="suggestions"
  13. :isSetting="false"
  14. :readonly="readonly"
  15. @setReadonly="setReadonly"
  16. />
  17. </section>
  18. <footer>
  19. <message-input :readonly="readonly" />
  20. </footer>
  21. </div>
  22. <record-list :data="recordList" :open="isOpenRecord" @closeRecord="closeRecord" @handleSelect="handleSelect" />
  23. </div>
  24. </template>
  25. <script>
  26. import Slider from "../components/Slider.vue";
  27. import DialogWrap from "../components/DialogWrap.vue";
  28. import MessageInput from "../components/MessageInput.vue";
  29. import TopBar from "../components/TopBar.vue";
  30. import Directory from "../components/Directory.vue";
  31. import RecordList from "../components/RecordList.vue";
  32. import { defineComponent, ref, inject } from "vue";
  33. export default defineComponent({
  34. components: {
  35. Slider,
  36. DialogWrap,
  37. MessageInput,
  38. TopBar,
  39. Directory,
  40. RecordList
  41. },
  42. setup() {
  43. const { helper } = inject("$global");
  44. const suggestions = ["有没有关于AI agent的论文"];
  45. const readonly = ref(false);
  46. const isOpenRecord = ref(false);
  47. const recordList = ref([
  48. {
  49. name: "今天",
  50. list: [
  51. "你必须知道的8种产品设计能力提升技巧",
  52. "干货|学会写简历,轻松拿offer",
  53. "探索了5种改善移动用户体验的绝佳做",
  54. "通知必读,再不看就晚啦",
  55. "最佳产品管理书籍在此,获取职场上升上"
  56. ]
  57. },
  58. {
  59. name: "昨天",
  60. list: ["探索了5种改善移动用户体验的绝佳做", "面试攻略:超级加分的10个面试满分小技"]
  61. },
  62. {
  63. name: "过去7天",
  64. list: [
  65. "你必须知道的8种产品设计能力提升技巧",
  66. "干货|学会写简历,轻松拿offer",
  67. "探索了5种改善移动用户体验的绝佳做",
  68. "通知必读,再不看就晚啦",
  69. "最佳产品管理书籍在此,获取职场上升上"
  70. ]
  71. },
  72. {
  73. name: "过去半年",
  74. list: ["探索了5种改善移动用户体验的绝佳做", "面试攻略:超级加分的10个面试满分小技"]
  75. },
  76. {
  77. name: "更久以前",
  78. list: [
  79. "你必须知道的8种产品设计能力提升技巧",
  80. "干货|学会写简历,轻松拿offer",
  81. "探索了5种改善移动用户体验的绝佳做",
  82. "通知必读,再不看就晚啦",
  83. "最佳产品管理书籍在此,获取职场上升上"
  84. ]
  85. }
  86. ]);
  87. const handleSelect = (value, index, key, e) => {
  88. switch (value) {
  89. case "delete":
  90. recordList.value[index].list.splice(key, 1);
  91. break;
  92. case "edit":
  93. const div = document.getElementById(`recod-item-${index}-${key}`);
  94. const wrapDiv = div.cloneNode();
  95. const { width, height, top, left } = div.getBoundingClientRect();
  96. wrapDiv.style.width = `${width}px`;
  97. wrapDiv.style.height = `${height}px`;
  98. wrapDiv.style.top = `${top}px`;
  99. wrapDiv.style.left = `${left}px`;
  100. wrapDiv.style.position = "absolute";
  101. const inputNode = document.createElement("input");
  102. inputNode.value = recordList.value[index].list[key];
  103. inputNode.style = "width: 100%;height: 100%";
  104. wrapDiv.append(inputNode);
  105. helper.setDialog(
  106. true,
  107. wrapDiv,
  108. () => {
  109. inputNode.focus();
  110. },
  111. () => {
  112. recordList.value[index].list[key] = inputNode.value;
  113. }
  114. );
  115. break;
  116. }
  117. };
  118. const openRecord = () => (isOpenRecord.value = true);
  119. const chooseNav = (index) => {
  120. switch (index) {
  121. case 2:
  122. openRecord();
  123. break;
  124. }
  125. };
  126. const closeRecord = () => (isOpenRecord.value = false);
  127. const setReadonly = (status) => {
  128. readonly.value = status;
  129. };
  130. return {
  131. recordList,
  132. isOpenRecord,
  133. readonly,
  134. setReadonly,
  135. suggestions,
  136. handleSelect,
  137. openRecord,
  138. closeRecord,
  139. chooseNav
  140. };
  141. }
  142. });
  143. </script>
  144. <style>
  145. .arco-message-list-top {
  146. top: 350px !important;
  147. }
  148. </style>
  149. <style scoped>
  150. .main {
  151. flex: 1;
  152. display: flex;
  153. flex-direction: column;
  154. background: #fbfbfb;
  155. overflow-y: auto;
  156. > header {
  157. display: flex;
  158. align-items: center;
  159. justify-content: right;
  160. padding: 0 20px;
  161. height: 50px;
  162. border-bottom: 1px solid rgba(229, 229, 229, 1);
  163. }
  164. > section {
  165. padding: 0 80px;
  166. flex: 1;
  167. }
  168. > footer {
  169. padding: 0 80px;
  170. margin-top: 80px;
  171. }
  172. }
  173. </style>