App.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div id="app">
  3. <router-view></router-view>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'app',
  9. data(){
  10. return {
  11. isLogin: false,
  12. userInfo: { //保存用户信息
  13. nick: null,
  14. ulevel: null,
  15. uid: null,
  16. portrait: null
  17. }
  18. }
  19. },
  20. created() {
  21. if(!this.$cookies.get("session")){
  22. //如果没有登录状态则跳转到登录页
  23. this.$router.push('/login');
  24. }
  25. },
  26. //监听路由检查登录
  27. watch:{
  28. "$route" : 'checkLogin'
  29. },
  30. mounted(){
  31. //组件开始挂载时获取用户信息
  32. // this.getUserInfo();
  33. },
  34. methods: {
  35. //请求用户的一些信息
  36. getUserInfo(){
  37. var userinfo = this.$cookies.get("session");
  38. },
  39. checkLogin(){
  40. //检查是否存在session
  41. //cookie操作方法在源码里有或者参考网上的即可
  42. if(!this.$cookies.get("session")){
  43. //如果没有登录状态则跳转到登录页
  44. this.$router.push('/login');
  45. }
  46. },
  47. getCookie: function (cname) {
  48. var name = cname + "=";
  49. var ca = document.cookie.split(';');
  50. for (var i = 0; i < ca.length; i++) {
  51. var c = ca[i];
  52. while (c.charAt(0) == ' ') c = c.substring(1);
  53. if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
  54. }
  55. return "";
  56. }
  57. },
  58. components: {}
  59. };
  60. </script>
  61. <style>
  62. html,
  63. body,
  64. #app {
  65. margin: 0 0;
  66. background-color: #e9eef3;
  67. height: 100%;
  68. }
  69. .el-header,
  70. .el-footer {
  71. /* background-color: #b3c0d1; */
  72. color: #333;
  73. text-align: center;
  74. line-height: 60px;
  75. }
  76. .el-main {
  77. background-color: #f0f2f5;
  78. color: #333;
  79. text-align: center;
  80. padding-top: 0px !important;
  81. }
  82. /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/
  83. ::-webkit-scrollbar {
  84. width: 8px;
  85. height: 8px;
  86. }
  87. /*定义滚动条轨道 内阴影+圆角*/
  88. ::-webkit-scrollbar-track {
  89. border-radius: 4px;
  90. background-color: #F5F5F5;
  91. }
  92. /*定义滑块 内阴影+圆角*/
  93. ::-webkit-scrollbar-thumb {
  94. border-radius: 4px;
  95. background-color: #c8c8c8;
  96. box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
  97. -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .1);
  98. }
  99. .table-header {
  100. color: #727272;
  101. font-weight: 600;
  102. }
  103. </style>