diff --git a/src/components/home/HomeHeader.vue b/src/components/home/HomeHeader.vue index a4a4fc5..932b7e1 100644 --- a/src/components/home/HomeHeader.vue +++ b/src/components/home/HomeHeader.vue @@ -21,7 +21,7 @@ -
+
@@ -303,10 +303,12 @@ export default { repassword: [{required: true, message: "请输入确认密码", trigger: "blur"}], activeCode: [{required: true, message: "请输入验证码", trigger: "blur"}], }, - userToken: '' + userToken: '', + isLogin:true, } }, mounted() { + this.isLogin = !localStorage.getItem("Authorization"); this.toggleActive(); this.reacherBarFun(); this.changeImg(); @@ -390,7 +392,6 @@ export default { type: 'success', offset: 0 }); - _this.$store.state.isLogin='1'; // _this.userToken = 'Bearer ' + res.data.token; _this.userToken = res.data.token; _this.changeLogin({ Authorization: _this.userToken }); @@ -398,6 +399,7 @@ export default { setTimeout(()=>{ window.location.reload(); },2000) + } }).catch((error)=>{ diff --git a/src/components/home/LeftSide.vue b/src/components/home/LeftSide.vue index c40be6e..a72831a 100644 --- a/src/components/home/LeftSide.vue +++ b/src/components/home/LeftSide.vue @@ -22,108 +22,21 @@ -
-
Categories
-
- - - - - - Photography - - - - - - - Graphic Design - - - - - - Video - - - - - - Illustrations - - - - - - - UI/UX - - - - - - 3D/AR - -
-
-
-
Fonts
-
- - - - - Manage Fonts - -
-
-
-
Resource Links
-
- - - - - Stock - - - - - - - Tutorials - - - - - - - Portfolio - - - - - - - Behance - - - - - - - Social Forum - -
-
+ diff --git a/src/router/index.js b/src/router/index.js index 408bd6a..aa6cd78 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -59,13 +59,13 @@ const routes = [ redirect: '/admin', name: '/settings', component: settings, - meta:{Authorization:true}, + children: [ { path: '/admin', name: '/admin', component: personalHomePage, - meta:{Authorization:true}, + }, { @@ -73,28 +73,28 @@ const routes = [ name: '/system', redirect: '/appearance', component: systemSettings, - meta:{Authorization:true}, + children:[ { path: '/appearance', name: '/appearance', component: appearanceSettings, - meta:{Authorization:true}, + }, { path: '/information', name: '/information', component: informationSettings, - meta:{Authorization:true}, + }, { path: '/function', name: '/function', component: functionSettings, - meta:{Authorization:true}, + } ] @@ -103,7 +103,7 @@ const routes = [ path: '/website', name: '/website', component: websiteManage, - meta:{Authorization:true}, + }, @@ -112,21 +112,21 @@ const routes = [ name: '/onSite', redirect:'/baseSettings', component: onSiteSetting, - meta:{Authorization:true}, + children:[ { path: '/baseSettings', name: '/baseSettings', component: baseSettings, - meta:{Authorization:true}, + }, { path: '/importExport', name: '/importExport', component: importExport, - meta:{Authorization:true}, + }, ] @@ -148,7 +148,8 @@ const routes = [ path: '/:pathMatch(.*)', redirect: '/404', hidden: true - } + }, + ] @@ -158,39 +159,22 @@ const router = new VueRouter({ routes }) // // 导航守卫:使用 router.beforeEach 注册一个全局前置守卫,判断用户是否登陆 -// router.beforeEach((to, from, next) => { -// if (to.path === '/home') { -// next(); -// } else { -// let token = localStorage.getItem('Authorization'); -// if (token === null || token === '') { -// next('/home'); -// } else { -// next(); -// } -// } -// }); -// 全局路由构造函数,判断是否登录和要跳转到页面 router.beforeEach((to, from, next) => { - if (to.matched.some(m => m.meta.requiresAuth)) { // 需要登录 - if(window.localStorage.Authorization && window.localStorage.isLogin === '1'){ - next() - } else if (to.path !== '/home') { - let token = localStorage.getItem('Authorization'); - if (token === 'null' || token === '' || token === undefined){ - next({path: '/home'}) - // Toast({ message: '检测到您还未登录,请登录后操作!', duration: 1500 }) - Vue.prototype.$notify.error({ + if (to.path === '/home') { + next(); + } else { + let token = localStorage.getItem('Authorization'); + if (token === null || token === '' || token === undefined) { + next('/home'); + Vue.prototype.$notify.error({ title: '权限不够', message: "请先登录!", offset: 0 }); - } } else { - next() + next(); } - } else { // 不需要登录 - next() } -}) +}); + export default router diff --git a/src/store/index.js b/src/store/index.js index a7b0b4a..7b2379c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -8,15 +8,8 @@ export default new Vuex.Store({ theme:'dark', // 存储token Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization') : '', - isLogin:'0', }, getters: { - getStorage(state){ // 获取本地存储的登录信息 - if(!state.Authorization){ - state.Authorization =JSON.parse(localStorage.getItem(key)) - } - return state.Authorization - } }, mutations: { SET_THEME:(state,data)=>{ diff --git a/src/views/Index.vue b/src/views/Index.vue index 8efcae6..1818c5b 100644 --- a/src/views/Index.vue +++ b/src/views/Index.vue @@ -19,7 +19,7 @@
- +
@@ -31,6 +31,8 @@ // @ is an alias to /src import HomeHeader from "@/components/home/HomeHeader.vue"; import LeftSide from "@/components/home/LeftSide.vue"; +import axios from "axios"; +import Vue from "vue"; export default { @@ -42,10 +44,15 @@ export default { data() { return { isLight:false, - darkMode:window.sessionStorage.getItem('theme') + darkMode:window.sessionStorage.getItem('theme'), + folderTrue:[], + folderFalse:[], + category:[], } }, mounted() { + + this.getCategories(); let nowDate=new Date() let hour=nowDate.getHours() //黑夜时 @@ -85,6 +92,38 @@ export default { // document.body.classList.toggle('light-mode'); // }); // } + getCategories(){ + let _this=this; + axios({ + method: 'post', + url: '/api//UrlAndCate/disposeBookmarkExhibitedToJson', + }).then(function (res) { + console.log(res); + _this.category=res.data.data; + _this.extractData(res.data.data,_this.folderTrue,_this.folderFalse); + console.log(_this.folderTrue); + console.log(_this.folderFalse); + }).catch((error)=>{ + Vue.prototype.$notify.error({ + title: '错误', + message: error, + offset: 0 + }); + }) + }, + + extractData(data, trueArray,falseArray) { + data.forEach((item) => { + if (item.floder === 'true') { + trueArray.push(item); + if (item.childUC && item.childUC.length > 0) { + this.extractData(item.childUC, trueArray,falseArray); + } + } else if (item.floder === 'false') { + falseArray.push(item); + } + }); + }, } }