Commit 39b078db authored by 纪泽龙's avatar 纪泽龙

首页根据传值隐藏

parent fc952a7f
<template> <template>
<el-breadcrumb class="app-breadcrumb" separator="/"> <el-breadcrumb class="app-breadcrumb" separator="/">
<transition-group name="breadcrumb"> <transition-group name="breadcrumb">
<el-breadcrumb-item v-for="(item,index) in levelList" :key="item.path"> <el-breadcrumb-item v-for="(item, index) in levelList" :key="item.path">
<span v-if="item.redirect==='noRedirect'||index==levelList.length-1" class="no-redirect">{{ item.meta.title }}</span> <span
v-if="item.redirect === 'noRedirect' || index == levelList.length - 1"
class="no-redirect"
>{{ item.meta.title }}</span
>
<a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a> <a v-else @click.prevent="handleLink(item)">{{ item.meta.title }}</a>
</el-breadcrumb-item> </el-breadcrumb-item>
</transition-group> </transition-group>
...@@ -10,53 +14,61 @@ ...@@ -10,53 +14,61 @@
</template> </template>
<script> <script>
import store from "@/store";
export default { export default {
data() { data() {
return { return {
levelList: null levelList: null,
} };
}, },
watch: { watch: {
$route(route) { $route(route) {
// if you go to the redirect page, do not update the breadcrumbs // if you go to the redirect page, do not update the breadcrumbs
if (route.path.startsWith('/redirect/')) { if (route.path.startsWith("/redirect/")) {
return return;
} }
this.getBreadcrumb() this.getBreadcrumb();
} },
}, },
created() { created() {
this.getBreadcrumb() this.getBreadcrumb();
}, },
methods: { methods: {
getBreadcrumb() { getBreadcrumb() {
// only show routes with meta.title // only show routes with meta.title
let matched = this.$route.matched.filter(item => item.meta && item.meta.title) let matched = this.$route.matched.filter(
const first = matched[0] (item) => item.meta && item.meta.title
);
const first = matched[0];
if (!this.isDashboard(first)) { if (
matched = [{ path: '/index', meta: { title: '首页' }}].concat(matched) !this.isDashboard(first) && store.getters.systemSetting.show_index === "1"
) {
matched = [{ path: "/index", meta: { title: "首页" } }].concat(matched);
} }
this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false) this.levelList = matched.filter(
(item) => item.meta && item.meta.title && item.meta.breadcrumb !== false
);
}, },
isDashboard(route) { isDashboard(route) {
const name = route && route.name const name = route && route.name;
if (!name) { if (!name) {
return false return false;
} }
return name.trim() === '首页' return name.trim() === "首页";
}, },
handleLink(item) { handleLink(item) {
const { redirect, path } = item const { redirect, path } = item;
if (redirect) { if (redirect) {
this.$router.push(redirect) this.$router.push(redirect);
return return;
} }
this.$router.push(path) this.$router.push(path);
} },
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
import router from './router' import router from "./router";
import store from './store' import store from "./store";
import { Message } from 'element-ui' import { Message } from "element-ui";
import NProgress from 'nprogress' import NProgress from "nprogress";
import 'nprogress/nprogress.css' import "nprogress/nprogress.css";
import { getToken } from '@/utils/auth' import { getToken } from "@/utils/auth";
NProgress.configure({ showSpinner: false }) NProgress.configure({ showSpinner: false });
const whiteList = ['/login', '/auth-redirect', '/bind', '/register'] const whiteList = ["/login", "/auth-redirect", "/bind", "/register"];
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start();
if (getToken()) { if (getToken()) {
/* has token*/ /* has token*/
if (to.path === '/login') { if (to.path === "/login") {
next({ path: '/' }) next({ path: "/" });
NProgress.done() NProgress.done();
} else { } else {
if (store.getters.roles.length === 0) { if (store.getters.roles.length === 0) {
// 判断当前用户是否已拉取完user_info信息 // 判断当前用户是否已拉取完user_info信息
store.dispatch('GetInfo').then(() => { store
store.dispatch('GenerateRoutes').then(accessRoutes => { .dispatch("GetInfo")
// 根据roles权限生成可访问的路由表 .then(() => {
router.addRoutes(accessRoutes) // 动态添加可访问路由表 store.dispatch("GenerateRoutes").then((accessRoutes) => {
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 // 根据roles权限生成可访问的路由表
}) router.addRoutes(accessRoutes); // 动态添加可访问路由表
}).catch(err => { // 让首页隐藏
store.dispatch('LogOut').then(() => { console.log(accessRoutes);
Message.error(err) // 如果这个值是0,就不展示首页,展示最近的页面
next({ path: '/' }) if (store.getters.systemSetting.show_index === "0") {
}) router.options.routes[4].children[0].hidden = true;
if (accessRoutes[0].children) {
next({ ...accessRoutes[0].children[0] });
}
} else {
next({ ...to, replace: true }); // hack方法 确保addRoutes已完成
}
// console.log("accessRoutes",accessRoutes)
// console.log("to",to)
});
}) })
.catch((err) => {
store.dispatch("LogOut").then(() => {
Message.error(err);
next({ path: "/" });
});
});
} else { } else {
next() next();
} }
} }
} else { } else {
// 没有token // 没有token
if (whiteList.indexOf(to.path) !== -1) { if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入 // 在免登录白名单,直接进入
next() next();
} else { } else {
next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 next(`/login?redirect=${to.fullPath}`); // 否则全部重定向到登录页
NProgress.done() NProgress.done();
} }
} }
}) });
router.afterEach(() => { router.afterEach(() => {
NProgress.done() NProgress.done();
}) });
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 纪泽龙 jizelong@qq.com * @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-14 12:25:28 * @Date: 2022-09-14 12:25:28
* @LastEditors: 纪泽龙 jizelong@qq.com * @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-09-26 16:03:27 * @LastEditTime: 2022-09-30 14:57:49
* @FilePath: /danger-manage-web/src/store/getters.js * @FilePath: /danger-manage-web/src/store/getters.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -19,6 +19,7 @@ const getters = { ...@@ -19,6 +19,7 @@ const getters = {
roles: state => state.user.roles, roles: state => state.user.roles,
permissions: state => state.user.permissions, permissions: state => state.user.permissions,
permission_routes: state => state.permission.routes, permission_routes: state => state.permission.routes,
systemSetting: state => state.user.systemSetting,
topbarRouters:state => state.permission.topbarRouters, topbarRouters:state => state.permission.topbarRouters,
defaultRoutes:state => state.permission.defaultRoutes, defaultRoutes:state => state.permission.defaultRoutes,
sidebarRouters:state => state.permission.sidebarRouters, sidebarRouters:state => state.permission.sidebarRouters,
......
...@@ -35,6 +35,7 @@ const user = { ...@@ -35,6 +35,7 @@ const user = {
}, },
SET_SYSTEMSETTING: (state, systemSetting) => { SET_SYSTEMSETTING: (state, systemSetting) => {
state.systemSetting = systemSetting state.systemSetting = systemSetting
console.log("systemSetting",systemSetting)
} }
}, },
......
/* /*
* @Author: your name * @Author: your name
* @Date: 2021-12-07 14:19:18 * @Date: 2021-12-07 14:19:18
* @LastEditTime: 2022-09-29 20:08:54 * @LastEditTime: 2022-09-30 13:32:44
* @LastEditors: 纪泽龙 jizelong@qq.com * @LastEditors: 纪泽龙 jizelong@qq.com
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath: /cesium-vue/src/utils/seieumClass.js * @FilePath: /cesium-vue/src/utils/seieumClass.js
...@@ -835,6 +835,7 @@ export default class CreateCesium { ...@@ -835,6 +835,7 @@ export default class CreateCesium {
// alignedAxis: Cesium.Cartesian3.ZERO, // default // alignedAxis: Cesium.Cartesian3.ZERO, // default
// width: 20, // default: undefined // width: 20, // default: undefined
// height: 20, // default: undefined // height: 20, // default: undefined
// sizeInMeters: true, //是否开启屋里大小
}, },
label: { label: {
text: `${title}`, text: `${title}`,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 纪泽龙 jizelong@qq.com * @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-06-16 15:03:40 * @Date: 2022-06-16 15:03:40
* @LastEditors: 纪泽龙 jizelong@qq.com * @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2022-09-29 20:47:06 * @LastEditTime: 2022-09-30 11:22:07
* @FilePath: /danger-manage-web/src/views/bigwindow/index.vue * @FilePath: /danger-manage-web/src/views/bigwindow/index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
--> -->
...@@ -53,8 +53,8 @@ export default { ...@@ -53,8 +53,8 @@ export default {
}, },
{ {
deviceType: 1, deviceType: 1,
longitude: 114.14649648472712, longitude: 114.08582661394571,
latitude: 38.39869677916153, latitude: 38.249478441102596,
shortNum: 16, shortNum: 16,
title: "视频2", title: "视频2",
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment