index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <script setup lang="ts">
  2. import { ref, computed, onMounted } from 'vue'
  3. import { useI18n } from 'vue-i18n'
  4. import { useRouter, useRoute } from 'vue-router'
  5. import Header from './header.vue'
  6. import Footer from './footer.vue'
  7. const { locale: language, t } = useI18n()
  8. const router = useRouter();
  9. const route = useRoute()
  10. console.log(route, 'route')
  11. const normalSettings = [
  12. {
  13. name: t('manage.information.nameArr.information'),
  14. icon: 'nav_my',
  15. to: { name: 'information' }
  16. },
  17. {
  18. name: t('manage.information.nameArr.scene'),
  19. icon: 'nav_scene',
  20. to: { name: 'scene' }
  21. },
  22. {
  23. name: t('manage.information.nameArr.device'),
  24. icon: 'nav_cam',
  25. to: { name: 'device' }
  26. },
  27. {
  28. name: t('manage.information.nameArr.order'),
  29. icon: 'nav_order',
  30. to: { name: 'order' }
  31. },
  32. {
  33. name: t('manage.information.nameArr.products'),
  34. icon: 'nav_data',
  35. to: { name: 'appProduct' }
  36. }
  37. ]
  38. const active = ref({
  39. name: 'information',
  40. to: { name: 'information' }
  41. })
  42. active.value = normalSettings.find(item => item.to.name === route.name) || normalSettings[0]
  43. function tabHandle(sub) {
  44. active.value = sub
  45. router.push(sub.to)
  46. }
  47. </script>
  48. <template>
  49. <div class="personalCenter">
  50. <Header />
  51. <div class="main_container">
  52. <div class="manage-body flex justify-center">
  53. <div class="mc-left">
  54. <div>
  55. <ul class="list-items">
  56. <li
  57. @click="tabHandle(sub)"
  58. v-for="(sub, i) in normalSettings"
  59. :key="i"
  60. :class="{
  61. active: active.to.name === sub.to.name,
  62. 'logout-span': sub.name === '退出登录' || sub.name === 'Log out'
  63. }"
  64. >
  65. <span
  66. ><h-icon class="nav-icon" v-if="sub.icon" :type="sub.icon"></h-icon
  67. >{{ sub.name }}</span
  68. >
  69. </li>
  70. </ul>
  71. </div>
  72. </div>
  73. <div class="mc-right">
  74. <router-view class="pcMianPage" />
  75. </div>
  76. </div>
  77. </div>
  78. <Footer />
  79. </div>
  80. </template>
  81. <style lang="less" scoped>
  82. .manage-body {
  83. min-height: 676px;
  84. padding: 80px 0;
  85. background-color: #f4f4f6;
  86. .container {
  87. display: flex;
  88. }
  89. .mc-left {
  90. flex-shrink: 0;
  91. margin-right: 30px;
  92. .list-items {
  93. font-size: 16px;
  94. display: inline-block;
  95. margin-bottom: 50px;
  96. width: 100%;
  97. padding: 30px 0;
  98. background: #fff;
  99. width: 274px;
  100. li {
  101. width: 100%;
  102. line-height: 48px;
  103. padding-left: 50px;
  104. color: #909090;
  105. cursor: pointer;
  106. &.active {
  107. color: #323233;
  108. background: #ebebeb;
  109. }
  110. .nav-icon {
  111. margin-right: 9px;
  112. }
  113. span {
  114. display: inline-block;
  115. position: relative;
  116. vertical-align: middle;
  117. display: flex;
  118. align-items: center;
  119. }
  120. .logout-span {
  121. &::before {
  122. display: none;
  123. }
  124. }
  125. }
  126. }
  127. }
  128. .mc-right {
  129. .mc-title {
  130. margin-left: 40px;
  131. margin-top: 34px;
  132. font-size: 28px;
  133. color: #2d2d2d;
  134. font-weight: bold;
  135. }
  136. }
  137. .pcMianPage{
  138. padding: 30px 0;
  139. width: 972px;
  140. min-height: 676px;
  141. background: #fff;
  142. }
  143. }
  144. </style>