Bläddra i källkod

使用 Container 布局容器重新调整 /admin 页面, 详细文档见 https://element.eleme.cn/#/zh-CN/component/container

reghao 2 år sedan
förälder
incheckning
1ec385953f
2 ändrade filer med 74 tillägg och 306 borttagningar
  1. 0 236
      src/components/layout/AdminBar.vue
  2. 74 70
      src/views/admin/Admin.vue

+ 0 - 236
src/components/layout/AdminBar.vue

@@ -1,236 +0,0 @@
-<template>
-  <el-row class="el-menu-demo">
-    <el-col :md="2">
-      <ul role="menubar" class="el-menu--horizontal el-menu">
-        <li role="menuitem" class="el-menu-item">
-          <a href="/my" style="color: #007bff;text-decoration-line: none">
-            <img src="@/assets/img/icon/logo.png" class="logo" alt="img">
-            my
-          </a>
-        </li>
-      </ul>
-    </el-col>
-    <el-col :md="6">
-      <ul class="el-menu--horizontal el-menu">
-        <li class="el-menu-item">
-          <el-dropdown v-if="user">
-            <img
-              :src="user.avatarUrl"
-              class="el-avatar--circle el-avatar--medium"
-              alt=""
-            >
-            <el-dropdown-menu v-if="user" slot="dropdown" class="iconsize">
-              <el-dropdown-item
-                icon="el-icon-error"
-                class="size"
-                @click.native="goToLogout"
-              >退出</el-dropdown-item>
-            </el-dropdown-menu>
-          </el-dropdown>
-        </li>
-      </ul>
-    </el-col>
-  </el-row>
-</template>
-
-<script>
-import { userMixin } from 'assets/js/mixin'
-import { keywordSuggest } from '@/api/search'
-import { getAuthedUser } from '@/utils/auth'
-
-export default {
-  name: 'AdminBar',
-  mixins: [userMixin],
-  data() {
-    return {
-      user: null,
-      activeIndex: '1',
-      restaurants: [],
-      placeholder: '想要搜点神马呢',
-      keyword: '',
-      statusCount: 0,
-      msgCount: 0
-    }
-  },
-  created() {
-    /* const userdata = Vue.$cookies.get('USERDATA')
-    const userId = userdata.split(':')[0]*/
-    const userInfo = getAuthedUser()
-    if (userInfo !== null) {
-      this.user = userInfo
-    }
-  },
-  methods: {
-    handleSelect(key, keyPath) {
-      console.log(key, keyPath)
-    },
-    // ****************************************************************************************************************
-    // 重点:当框中的改变时触发该方法,elementui自动设置了防抖,参见debounce属性
-    // queryString 为输入框中的值。cb为返回显示列表的回调函数
-    querySearchAsync(queryString, cb) {
-      if (queryString === '') {
-        return
-      }
-
-      setTimeout(() => {
-        keywordSuggest(queryString).then(res => {
-          if (res.code === 0) {
-            this.restaurants = res.data.map((item) => {
-              return {
-                value: item.keyword,
-                rank: 1
-              }
-            })
-
-            // 如果 cb 返回一个空数组, 那么模糊搜索输入建议的下拉选项会因为 length 为 0 而消失
-            // cb([])
-            cb(this.restaurants)
-            // eslint-disable-next-line no-empty
-          } else {
-          }
-        })
-      }, 500)
-    },
-    // select 事件或 enter 键事件
-    onSearch() {
-      console.log('回车事件')
-      // 正则去空格
-      if (this.keyword.replace(/\s*/g, '')) {
-        this.toSearchPage()
-      } else {
-        this.$message({
-          showClose: true,
-          message: '不能为空!',
-          type: 'warning'
-        })
-      }
-    },
-    // 跳转搜索页面,传递搜索框的参数
-    toSearchPage() {
-      const currentPath = this.$route.path
-      if (currentPath === '/search') {
-        this.$router.push({
-          path: '/search',
-          query: {
-            keyword: this.keyword,
-            pageNumber: 1
-          }
-        })
-        this.$router.go(0)
-      } else {
-        const routeUrl = this.$router.resolve({
-          path: '/search',
-          query: {
-            keyword: this.keyword,
-            pageNumber: 1
-          }
-        })
-        window.open(routeUrl.href, '_blank')
-      }
-    },
-    // ****************************************************************************************************************
-    login1() {
-      this.fetchPubkey()
-      this.dialogVisible = true
-    },
-    login() {
-      const path = '/login'
-      if (this.$route.path === path) {
-        this.$router.go(0)
-        return
-      }
-      this.$router.push(path)
-    },
-    register() {
-      window.open('//account.reghao.cn/login', '_blank')
-    },
-    // ****************************************************************************************************************
-    goToDisk() {
-      const path = '/disk'
-      if (this.$route.path === path) {
-        this.$router.go(0)
-        return
-      }
-      this.$router.push(path)
-    },
-    goToProfile() {
-      const path = '/my'
-      if (this.$route.path === path) {
-        this.$router.go(0)
-        return
-      }
-      this.$router.push(path)
-    },
-    goToTimeline() {
-      const path = '/timeline'
-      if (this.$route.path === path) {
-        this.$router.go(0)
-        return
-      }
-      this.$router.push(path)
-    },
-    goToHome() {
-      const path = '/user/' + this.user.userId
-      if (this.$route.path === path) {
-        this.$router.go(0)
-        return
-      }
-      this.$router.push(path)
-    },
-    goToPost() {
-      if (this.$route.path === '/my/post/list/video') {
-        this.$router.go(0)
-        return
-      }
-      this.$router.push('/my/post/list/video')
-    },
-    goToFavlist() {
-      if (this.$route.path === '/my/favlist/video') {
-        this.$router.go(0)
-        return
-      }
-      this.$router.push('/my/favlist/video')
-    },
-    goToHistory() {
-      if (this.$route.path === '/my/visit') {
-        this.$router.go(0)
-        return
-      }
-      this.$router.push('/my/visit')
-    },
-    goToMessage() {
-      if (this.$route.path === '/my/message/receive') {
-        this.$router.go(0)
-        return
-      }
-      this.$router.push('/my/message/receive')
-    },
-    goToPublish() {
-      if (this.$route.path === '/my/post/publish/video') {
-        this.$router.go(0)
-        return
-      }
-      this.$router.push('/my/post/publish/video')
-    }
-  }
-}
-</script>
-
-<style scoped>
-@media screen and (max-width: 768px) {
-}
-
-.logo {
-  width: 30px;
-  position: relative;
-}
-
-.size {
-  font-size: 16px;
-}
-
-.item {
-  margin-top: 10px;
-  margin-right: 10px;
-}
-</style>

+ 74 - 70
src/views/admin/Admin.vue

@@ -1,92 +1,96 @@
 <template>
-  <el-container>
-    <admin-bar/>
-    <el-aside id="aside-style">
-      <el-radio-group v-model="isCollapse" style="margin-bottom: 20px;">
-        <el-radio-button :label="false">展开</el-radio-button>
-        <el-radio-button :label="true">收起</el-radio-button>
-      </el-radio-group>
-      <el-menu
-        :default-active="this.$route.path"
-        router
-        class="el-menu-vertical-demo"
-        :collapse="isCollapse"
-        @open="handleOpen"
-        @close="handleClose"
-      >
-        <el-menu-item index="/admin/site">
-          <i class="el-icon-apple" />
-          <span slot="title">站点配置</span>
-        </el-menu-item>
-        <el-menu-item index="/admin/user">
-          <i class="el-icon-user" />
-          <span slot="title">用户列表</span>
-        </el-menu-item>
-        <el-menu-item index="/admin/post">
-          <i class="el-icon-postcard" />
-          <span slot="title">稿件列表</span>
-        </el-menu-item>
-        <el-menu-item index="/admin/datasource">
-          <i class="el-icon-date" />
-          <span slot="title">数据源</span>
-        </el-menu-item>
-      </el-menu>
-    </el-aside>
-    <el-main>
-      <!--      <el-breadcrumb separator-class="el-icon-arrow-right">
-        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
-        <el-breadcrumb-item v-text="this.$router.currentRoute.name"></el-breadcrumb-item>
-      </el-breadcrumb>-->
-      <router-view />
-    </el-main>
+  <el-container style="height: 650px; border: 1px solid #eee">
+    <el-header style="text-align: right; font-size: 12px">
+      <el-col :md="2">
+        <ul class="el-menu--horizontal el-menu">
+          <li class="el-menu-item">
+            <a href="/admin" style="text-decoration-line: none">
+              <img src="@/assets/img/icon/logo.png" class="el-avatar--circle el-avatar--medium" alt="img">
+              admin
+            </a>
+          </li>
+        </ul>
+      </el-col>
+      <el-dropdown>
+        <img
+          :src="user.avatarUrl"
+          class="el-avatar--circle el-avatar--medium"
+          style="margin-right: 10px; margin-top: 15px"
+          alt=""
+        >
+        <el-dropdown-menu slot="dropdown">
+          <el-dropdown-item
+            icon="el-icon-error"
+            class="size"
+            @click.native="goToLogout"
+          >退出</el-dropdown-item>
+          <el-dropdown-item>查看</el-dropdown-item>
+          <el-dropdown-item>新增</el-dropdown-item>
+          <el-dropdown-item>删除</el-dropdown-item>
+        </el-dropdown-menu>
+      </el-dropdown>
+    </el-header>
+    <el-container>
+      <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
+        <el-menu
+          :default-active="this.$route.path"
+          router
+          class="el-menu-vertical-demo"
+          :collapse="isCollapse"
+          @open="handleOpen"
+          @close="handleClose"
+        >
+          <el-menu-item index="/admin/site">
+            <i class="el-icon-apple" />
+            <span slot="title">站点配置</span>
+          </el-menu-item>
+          <el-menu-item index="/admin/user">
+            <i class="el-icon-user" />
+            <span slot="title">用户列表</span>
+          </el-menu-item>
+          <el-menu-item index="/admin/post">
+            <i class="el-icon-postcard" />
+            <span slot="title">稿件列表</span>
+          </el-menu-item>
+          <el-menu-item index="/admin/datasource">
+            <i class="el-icon-date" />
+            <span slot="title">数据源</span>
+          </el-menu-item>
+        </el-menu>
+      </el-aside>
+      <el-main>
+        <router-view />
+      </el-main>
+    </el-container>
   </el-container>
 </template>
 
 <script>
-import AdminBar from 'components/layout/AdminBar'
+import { getAuthedUser } from '@/utils/auth'
 
 export default {
-  name: 'Admin',
-  components: {
-    AdminBar
-  },
   data() {
     return {
-      isCollapse: false,
-      navList: [
-        { path: '/my/account', name: '我的帐号', icon: 'el-icon-upload' }
-      ]
+      user: null
     }
   },
-  /*  watch: {
-    // 地址栏 url 发生变化时重新加载本页面
-    $route() {
-      this.$router.go()
-    }
-  },*/
   created() {
-    document.title = '后台主页'
-  },
-  methods: {
-    handleOpen(key, keyPath) {
-      console.log(key, keyPath)
-    },
-    handleClose(key, keyPath) {
-      console.log(key, keyPath)
+    const userInfo = getAuthedUser()
+    if (userInfo !== null) {
+      this.user = userInfo
     }
   }
 }
 </script>
 
 <style>
-.el-menu-vertical-demo:not(.el-menu--collapse) {
-  width: 200px;
-  min-height: 800px;
+.el-header {
+  background-color: #B3C0D1;
+  color: #333;
+  line-height: 60px;
 }
 
-#aside-style {
-  min-width: 120px;
-  max-width: 240px;
-  width: 30%;
+.el-aside {
+  color: #333;
 }
 </style>