index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <v-app>
  3. <v-app-bar
  4. app
  5. color="blue"
  6. dark
  7. >
  8. <v-container class="py-0 fill-height">
  9. <v-toolbar-title
  10. class="hidden-sm-and-down ml-0 pl-4"
  11. style="width: 60px"
  12. >
  13. <p style="font-size: 20px; margin-bottom: 0;">
  14. <router-link :to="`/`" style="color: white;"> {{ this.$store.state.webInfo.name }} </router-link>
  15. </p>
  16. </v-toolbar-title>
  17. <router-link v-for="item in items" :key="item.text" :to="item.link">
  18. <v-list-item
  19. link
  20. >
  21. <!-- <v-list-item-action>
  22. <v-icon>{{ item.icon }}</v-icon>
  23. </v-list-item-action>-->
  24. <v-list-item-content>
  25. <v-list-item-title>
  26. {{ item.text }}
  27. </v-list-item-title>
  28. </v-list-item-content>
  29. </v-list-item>
  30. </router-link>
  31. <v-spacer />
  32. <SearchInput />
  33. <v-spacer />
  34. <v-tooltip bottom>
  35. <template v-slot:activator="{ on, attrs }">
  36. <v-btn
  37. icon
  38. v-bind="attrs"
  39. v-on="on"
  40. @click="goToPublish"
  41. >
  42. <v-icon>mdi-video-plus</v-icon>
  43. </v-btn>
  44. </template>
  45. <span>发布</span>
  46. </v-tooltip>
  47. <v-tooltip bottom>
  48. <template v-slot:activator="{ on, attrs }">
  49. <v-btn
  50. icon
  51. v-bind="attrs"
  52. v-on="on"
  53. @click="goToMessage"
  54. >
  55. <v-icon>mdi-bell</v-icon>
  56. </v-btn>
  57. </template>
  58. <span>通知</span>
  59. </v-tooltip>
  60. <Head v-if="this.$store.state.user.userInfo" />
  61. <!-- 未登录 -->
  62. <v-btn
  63. v-if="this.$store.state.user.userInfo == null"
  64. outlined
  65. @click="goToLoginPage"
  66. >
  67. <v-icon left dark>mdi-account</v-icon> 登录
  68. </v-btn>
  69. </v-container>
  70. </v-app-bar>
  71. <v-main>
  72. <v-container>
  73. <!--根据 router/index.js 中的路由渲染页面-->
  74. <router-view />
  75. </v-container>
  76. </v-main>
  77. <!--
  78. <v-footer app>
  79. <v-col
  80. class="text-center"
  81. cols="12"
  82. >
  83. {{ new Date().getFullYear() }} — <strong>Vuetify</strong>
  84. </v-col>
  85. </v-footer>-->
  86. </v-app>
  87. </template>
  88. <script>
  89. import Head from '@/layout/components/head.vue'
  90. import SearchInput from '@/layout/components/search-input.vue'
  91. export default {
  92. components: {
  93. Head,
  94. SearchInput
  95. },
  96. data: () => ({
  97. userInfo: {},
  98. drawer: true,
  99. keyword: '',
  100. items: [
  101. /* { icon: 'mdi-trending-up', text: '状态', link: '/mblog' },*/
  102. { text: '状态', link: '/mblog' },
  103. { text: '视频', link: '/video' },
  104. { text: '音频', link: '/audio' },
  105. { text: '图片', link: '/image' },
  106. { text: '文章', link: '/article' }
  107. ]
  108. }),
  109. created() {
  110. this.userInfo = this.$store.state.user.userInfo
  111. this.$vuetify.theme.dark = this.$store.state.darkThemOpen
  112. },
  113. methods: {
  114. logout() {
  115. // 调用 store/modules/user.js 中的 login 方法
  116. this.$store.dispatch('user/logout').then(() => {
  117. if (this.$route.path === '/') {
  118. location.reload()
  119. } else {
  120. this.$router.push('/')
  121. }
  122. }).catch(() => {
  123. console.log('用户注销失败')
  124. })
  125. },
  126. goToLoginPage() {
  127. this.$router.push('/login')
  128. },
  129. goToMessage() {
  130. this.$router.push('/message')
  131. },
  132. goToPublish() {
  133. this.$router.push('/studio/upload')
  134. }
  135. }
  136. }
  137. </script>
  138. <style scoped>
  139. a {
  140. text-decoration: none;
  141. }
  142. </style>