index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <div class="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
  5. <div class="left">
  6. <div class="left_1" @click="toHome">
  7. <el-image class="image" v-if="configInfo && configInfo.logoUrl && configInfo.logoUrl.length > 0" :src="getUrl(configInfo.logoUrl)" fit="fill" />
  8. <el-image class="image" v-else :src="siteInfo.logoUrl" fit="fill" />
  9. <div class="left_title">{{ configInfo.zhTitle || siteInfo.zhTitle }}</div>
  10. </div>
  11. <div class="left_2">
  12. <div class="menus" :class="[item.route_name == acitveKey ? 'menuTrue' : '']" v-for="item in menuList3" :key="item.id" @click="toActive(item)">
  13. <component class="icon" :is="item.icon"></component>
  14. <span class="name">{{ item.name }}</span>
  15. </div>
  16. </div>
  17. </div>
  18. <div class="right">
  19. <div class="right_1">
  20. <div class="name">{{ user.nick_name || '暂无昵称' }}</div>
  21. <div class="layout" @click="toOut">
  22. <LoginOutlined />
  23. <span>退出</span>
  24. </div>
  25. </div>
  26. <div class="right_2">
  27. <router-view></router-view>
  28. </div>
  29. </div>
  30. </el-col>
  31. </el-row>
  32. </div>
  33. </template>
  34. <script setup>
  35. import { LoginOutlined } from '@ant-design/icons-vue'
  36. import { siteInfo, menuList3 } from '@/layout/site'
  37. // 接口
  38. import { DesignStore } from '@/store/api/platform/design'
  39. const designStore = DesignStore()
  40. import { UserStore } from '@/store/user'
  41. const userStore = UserStore()
  42. const user = computed(() => userStore.user)
  43. // 加载中
  44. const loading = ref(false)
  45. // 路由
  46. const router = useRouter()
  47. const route = useRoute()
  48. const acitveKey = ref(route.name)
  49. const $checkRes = inject('$checkRes')
  50. const configInfo = ref({})
  51. // 请求
  52. onMounted(async () => {
  53. await searchOther()
  54. })
  55. const searchOther = async () => {
  56. // 基础设置
  57. const result = await designStore.query({})
  58. if ($checkRes(result)) {
  59. configInfo.value = result.data[0] || {}
  60. }
  61. }
  62. const toActive = async (item) => {
  63. acitveKey.value = item.route_name
  64. router.push({ path: item.path })
  65. }
  66. // 退出登录
  67. const toOut = () => {
  68. userStore.logOut()
  69. router.push({ path: '/login', query: { status: '1' } })
  70. }
  71. // 返回首页
  72. const toHome = () => {
  73. router.push({ path: `/` })
  74. }
  75. const getUrl = (item) => {
  76. if (item && item.length > 0) return `${import.meta.env.VITE_APP_HOST}${item[0].uri}`
  77. }
  78. watch(
  79. route,
  80. (newVal) => {
  81. if (newVal && newVal.name) acitveKey.value = newVal.name
  82. },
  83. {
  84. immediate: true //初始化立即执行
  85. }
  86. )
  87. </script>
  88. <style scoped lang="scss">
  89. .main {
  90. display: flex;
  91. background: #f1f6f9;
  92. min-height: 100vh;
  93. .left {
  94. width: 20%;
  95. background: linear-gradient(180deg, #165aa0, #4942dd);
  96. height: 100%;
  97. border-top-right-radius: 40px;
  98. border-bottom-right-radius: 40px;
  99. overflow: hidden;
  100. .left_1 {
  101. cursor: default;
  102. padding-top: 20px;
  103. padding-left: 10px;
  104. padding-right: 10px;
  105. color: #ffffff;
  106. display: flex;
  107. flex-direction: column;
  108. align-items: center;
  109. .image {
  110. height: 60px;
  111. width: 220px;
  112. }
  113. .left_title {
  114. padding: 10px 0 0 0;
  115. font-size: $global-font-size-24;
  116. font-family: 'Comic Sans MS', cursive;
  117. }
  118. }
  119. .left_2 {
  120. padding-left: 15px;
  121. padding-top: 35px;
  122. .menus {
  123. font-size: $global-font-size-20;
  124. font-weight: 500;
  125. color: #fff;
  126. height: 67px;
  127. line-height: 67px;
  128. padding-left: 80px;
  129. border-bottom-left-radius: 33px;
  130. border-top-left-radius: 33px;
  131. position: relative;
  132. cursor: pointer;
  133. .icon {
  134. display: inline-block;
  135. width: 1em;
  136. height: 1em;
  137. overflow: hidden;
  138. vertical-align: -0.15em;
  139. outline: none;
  140. margin-right: 5px;
  141. }
  142. }
  143. .menuTrue {
  144. background: #f1f6f9;
  145. color: #3961aa;
  146. }
  147. .menuTrue:after {
  148. content: url(/images/center_1.png);
  149. position: absolute;
  150. right: 0;
  151. top: -43px;
  152. }
  153. }
  154. }
  155. .right {
  156. width: 80%;
  157. padding: 0 20px;
  158. .right_1 {
  159. display: flex;
  160. justify-content: flex-end;
  161. height: 80px;
  162. line-height: 80px;
  163. font-size: $global-font-size-20;
  164. .layout {
  165. padding: 0 10px 0 20px;
  166. color: #8a8b8c;
  167. cursor: pointer;
  168. span {
  169. margin: 0 0 0 5px;
  170. }
  171. }
  172. }
  173. .right_2 {
  174. width: 100%;
  175. min-height: 90vh;
  176. background: #fff;
  177. border-radius: 10px;
  178. padding: 20px;
  179. }
  180. }
  181. }
  182. </style>