admin.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <div class="page">
  3. <el-menu class="menu-box" :default-active="active" @select="select">
  4. <el-menu-item index="info">
  5. <i class="el-icon-document"></i>
  6. <span slot="title">个人用户信息管理</span>
  7. </el-menu-item>
  8. <el-menu-item index="blog">
  9. <i class="el-icon-document"></i>
  10. <span slot="title">撰写博客</span>
  11. </el-menu-item>
  12. <el-menu-item index="blogs">
  13. <i class="el-icon-document"></i>
  14. <span slot="title">个人博客管理</span>
  15. </el-menu-item>
  16. <el-menu-item index="tags">
  17. <i class="el-icon-document"></i>
  18. <span slot="title">标签管理</span>
  19. </el-menu-item>
  20. <el-menu-item index="comments">
  21. <i class="el-icon-document"></i>
  22. <span slot="title">评论管理</span>
  23. </el-menu-item>
  24. </el-menu>
  25. <div class="sub-page-box">
  26. <router-view :userInfo="userInfo"></router-view>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. export default {
  32. name: "admin",
  33. data() {
  34. return {
  35. active: "info",
  36. userInfo: {},
  37. };
  38. },
  39. watch: {
  40. $route(to, from) {},
  41. },
  42. created() {
  43. let userInfo = localStorage.getItem("userInfo");
  44. if (userInfo) {
  45. if (typeof userInfo === "string") {
  46. userInfo = JSON.parse(userInfo);
  47. }
  48. this.userInfo = userInfo;
  49. }
  50. },
  51. mounted() {
  52. this.$nextTick(() => {
  53. console.log(this.$route);
  54. this.active = this.$route.name;
  55. });
  56. },
  57. methods: {
  58. select(name) {
  59. if (this.$route.name !== name) {
  60. this.$router.push({
  61. name: name,
  62. });
  63. }
  64. },
  65. },
  66. };
  67. </script>
  68. <style lang="less" scoped>
  69. .page {
  70. //margin-left: 0;
  71. //width: 100vw;
  72. background-color: #f8f9fb;
  73. margin-top: 350px;
  74. display: flex;
  75. .menu-box {
  76. text-align: left;
  77. width: 250px;
  78. }
  79. .sub-page-box {
  80. flex: 1;
  81. height: calc(100vh - 65px);
  82. overflow-y: scroll;
  83. }
  84. }
  85. </style>