index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div >
  3. <!-- 主要内容区域 -->
  4. <div style="width: 100%; display: flex">
  5. <div class="sidebar-menu" style="width: 15%; background: white">
  6. <ul>
  7. <li
  8. v-for="item in menuItems"
  9. :class="{ active: activeKey === item.key }"
  10. :key="item.key"
  11. @click="handleClick(item)"
  12. >
  13. <component :is="item.icon" />
  14. <!-- <AliwangwangOutlined /> -->
  15. {{ item.label }}
  16. </li>
  17. </ul>
  18. </div>
  19. <div style="width: 88%">
  20. <component :is="currentComponent"></component>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script setup>
  26. import Header from '@/views/portal/components/Header.vue'
  27. import Footer from '@/views/portal/components/Footer.vue'
  28. import myResources from '../myResources.vue'
  29. import { ref, reactive, computed, onMounted, defineAsyncComponent } from 'vue'
  30. import { useRouter, useRoute } from 'vue-router'
  31. import {
  32. HomeOutlined,
  33. FolderOutlined,
  34. StarOutlined,
  35. BookOutlined,
  36. QuestionCircleOutlined,
  37. BankOutlined,
  38. SolutionOutlined,
  39. ScheduleOutlined
  40. } from '@ant-design/icons-vue'
  41. const router = useRouter()
  42. const route = useRoute()
  43. const indexType = ref('resources') // 默认选中“我的主页”
  44. const activeKey = ref('resources') // 当前选中项
  45. const itemData = ref({})
  46. const VideoDetailsRef = ref(null)
  47. const selectedKeys = ref(['resources'])
  48. const openKeys = ref(['resources'])
  49. const menuItems = ref([
  50. // {
  51. // key: 'home',
  52. // icon: HomeOutlined,
  53. // label: '我的主页',
  54. // title: '我的主页'
  55. // },
  56. {
  57. key: 'resources',
  58. icon: FolderOutlined,
  59. label: '我的资源',
  60. title: '我的资源'
  61. },
  62. {
  63. key: 'favorites',
  64. icon: StarOutlined,
  65. label: '我的收藏',
  66. title: '我的收藏'
  67. }
  68. // {
  69. // key: 'albums',
  70. // icon: BookOutlined,
  71. // label: '我的课程专辑',
  72. // title: '我的课程专辑'
  73. // },
  74. // {
  75. // key: 'questionBank',
  76. // icon: QuestionCircleOutlined,
  77. // label: '我的题库',
  78. // title: '我的题库'
  79. // },
  80. // {
  81. // key: 'classroom',
  82. // icon: BankOutlined,
  83. // label: '我的教室',
  84. // title: '我的教室'
  85. // },
  86. // {
  87. // key: 'courses',
  88. // label: '我的课程',
  89. // icon: SolutionOutlined,
  90. // title: '我的课程'
  91. // },
  92. // {
  93. // key: 'tasks',
  94. // label: '我的任务',
  95. // icon: ScheduleOutlined,
  96. // title: '我的任务'
  97. // }
  98. ])
  99. const handleClick = (e) => {
  100. selectedKeys.value = [e.key]
  101. activeKey.value = e.key
  102. indexType.value = e.key
  103. }
  104. const currentComponent = computed(() => {
  105. // if (indexType.value !== 'resources') {
  106. // return false
  107. // }
  108. switch (indexType.value) {
  109. // case 'home':
  110. // return defineAsyncComponent(() => import('@/views/myResources/personalResources/Home.vue'))
  111. case 'resources':
  112. return myResources
  113. case 'favorites':
  114. return defineAsyncComponent(() => import('@/views/myFavorites/index.vue'))
  115. // case 'albums':
  116. // return defineAsyncComponent(() => import('@/views/myResources/personalResources/Albums.vue'))
  117. // case 'questionBank':
  118. // return defineAsyncComponent(() => import('@/views/myResources/personalResources/QuestionBank.vue'))
  119. // case 'classroom':
  120. // return defineAsyncComponent(() => import('@/views/myResources/personalResources/Classroom.vue'))
  121. // case 'courses':
  122. // return defineAsyncComponent(() => import('@/views/myResources/personalResources/Courses.vue'))
  123. // case 'tasks':
  124. // return defineAsyncComponent(() => import('@/views/myResources/personalResources/Tasks.vue'))
  125. default:
  126. return myResources
  127. }
  128. })
  129. const handlerItemSidebar = (item) => {
  130. // emit('handlerItemSidebar', item)
  131. }
  132. const onChangeCurrent = (current) => {
  133. indexType.value = current
  134. router.push({
  135. path: '/' + current
  136. })
  137. }
  138. const setData = (item) => {
  139. getData(item)
  140. }
  141. const getData = (item) => {
  142. detail({ id: item.id })
  143. .then((res) => {
  144. if (res.code == 200) {
  145. itemData.value = res.data
  146. }
  147. })
  148. .catch((err) => {})
  149. }
  150. onMounted(() => {
  151. const id = route.query.id
  152. if (id != undefined && id != '') {
  153. addViewCount({ id: id })
  154. getData({ id: id })
  155. }
  156. })
  157. defineExpose({
  158. setData
  159. })
  160. </script>
  161. <style lang="less" scoped>
  162. .a-menu {
  163. width: 256px;
  164. height: 600px;
  165. background-color: #fff;
  166. border-right: 1px solid #e8e8e8;
  167. }
  168. .content {
  169. border: 1px solid #00000011;
  170. /* 灰色细边框 */
  171. }
  172. .scroll-container {
  173. height: 100vh;
  174. overflow-y: auto;
  175. }
  176. .sidebar-menu {
  177. flex: 1;
  178. //background-color: #ffff;
  179. color: #0000007c;
  180. }
  181. .sidebar-menu ul {
  182. list-style-type: none;
  183. padding: 0;
  184. }
  185. .sidebar-menu li {
  186. padding: 10px;
  187. cursor: pointer;
  188. }
  189. .sidebar-menu li:hover {
  190. background-color: #e6f7ff;
  191. color: #ccc;
  192. }
  193. .active {
  194. color: #ffff;
  195. background-color: #1073cff7;
  196. }
  197. </style>