菜单修复

prod
许宏杰 10 months ago
parent 0fddf64d10
commit f0ae5c391e

@ -5,7 +5,7 @@ VUE_APP_TITLE = 金鸡湖现代服务业品牌管理系统
ENV = 'development'
# 金鸡湖现代服务业品牌管理系统/开发环境
VUE_APP_BASE_API = 'https://vue.ruoyi.vip/prod-api'
VUE_APP_BASE_API = 'http://192.168.0.114:9040'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true

@ -45,7 +45,6 @@ export default {
// matched = [{ path: "/index", meta: { title: "" } }].concat(matched);
// }
console.log(this.levelList, "aaa111");
this.levelList = matched.filter(
(item) => item.meta && item.meta.title && item.meta.breadcrumb !== false
);

@ -1,57 +0,0 @@
<template>
<section class="menu-item-container">
<div
class="menu-item"
v-for="(item, routerIndex) in topMenus"
:key="routerIndex"
>
<item :router="item"></item>
</div>
</section>
</template>
<script>
import item from "./item.vue";
export default {
data() {
return {};
},
components: {
item,
},
methods: {
handleActive(path) {
return this.$route.path.includes(path);
},
},
computed: {
//
topMenus() {
let topMenus = [];
this.routers.map((menu) => {
if (menu.hidden !== true) {
//
if (menu.path === "/") {
topMenus.push(menu.children[0]);
} else {
topMenus.push(menu);
}
}
});
console.log(topMenus, "aa");
return topMenus;
},
//
routers() {
return this.$store.state.permission.topbarRouters;
},
},
};
</script>
<style lang="scss" scoped>
.menu-item-container {
display: flex;
align-items: center;
}
</style>

@ -0,0 +1,71 @@
<template>
<el-dropdown trigger="hover">
<div class="menu-item">
{{ item.meta.title }}
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
@click.native="handlePath(secondRoute, secondIndex)"
v-for="(secondRoute, secondIndex) in item.children"
:key="secondIndex"
>
<section v-if="!secondRoute.children">
<svg-icon
v-if="
secondRoute.meta &&
secondRoute.meta.icon &&
secondRoute.meta.icon !== '#'
"
:icon-class="secondRoute.meta.icon"
/>
{{ secondRoute.meta.title }}
</section>
<section v-else>
<menu-item
:item="secondRoute"
:base-path="secondRoute.path"
></menu-item>
</section>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
<script>
export default {
name: "MenuItem",
props: {
item: {
type: Object,
required: true,
},
basePath: {
type: String,
default: "",
},
},
data() {
return {};
},
mounted() {},
methods: {
handlePath(item, index) {
console.log(item, "aaa");
// this.$router.push(item.path);
},
},
};
</script>
<style lang="scss" scoped>
.menu-item {
font-size: 18px;
color: #ffffff;
font-weight: 500;
font-style: normal;
text-transform: none;
margin: 0 10px;
padding: 3px 12px;
cursor: pointer;
}
</style>

@ -0,0 +1,133 @@
<template>
<div class="men-main">
<div
v-for="(item, index) in topMenus"
:key="index"
:class="isCurrentRoute(item.path) ? 'activeMenu' : ''"
@click="handlerRouter(item.path)"
>
<div class="menu-item" v-if="!item.children">
{{ item.meta.title }}
</div>
<menu-item v-else :item="item" :base-path="item.path"></menu-item>
</div>
</div>
</template>
<script>
import { mapGetters } from "vuex";
import MenuItem from "../MenuItem";
import { constantRoutes } from "@/router";
//
export default {
data() {
return {};
},
components: {
MenuItem,
},
mounted() {
this.childrenMenus();
},
methods: {
//
childrenMenus() {
var childrenMenus = [];
this.routers.map((router) => {
for (var item in router.children) {
if (router.children[item].parentPath === undefined) {
if (router.path === "/") {
router.children[item].path = "/" + router.children[item].path;
} else {
if (!this.ishttp(router.children[item].path)) {
router.children[item].path =
router.path + "/" + router.children[item].path;
}
}
router.children[item].parentPath = router.path;
}
childrenMenus.push(router.children[item]);
}
});
return constantRoutes.concat(childrenMenus);
},
//
isCurrentRoute(key) {
return this.$route.path === key;
},
handlerRouter(key) {
console.log(key);
const route = this.routers.find((item) => item.path === key);
if (this.ishttp(key)) {
//
window.open(key, "_blank");
} else if (!route || !route.children) {
//
const routeMenu = this.childrenMenus().find(
(item) => item.path === key
);
if (routeMenu && routeMenu.query) {
let query = JSON.parse(routeMenu.query);
this.$router.push({ path: key, query: query });
} else {
this.$router.push({ path: key });
}
}
},
ishttp(url) {
return url.indexOf("http://") !== -1 || url.indexOf("https://") !== -1;
},
},
computed: {
...mapGetters(["sidebarRouters"]),
theme() {
return this.$store.state.settings.theme;
},
//
topMenus() {
let topMenus = [];
this.sidebarRouters.map((menu) => {
if (menu.hidden !== true && menu.redirect !== "index") {
//
if (menu.path === "/") {
topMenus.push(menu.children[0]);
} else {
topMenus.push(menu);
}
}
});
return topMenus;
},
//
routers() {
return this.$store.state.permission.topbarRouters;
},
},
};
</script>
<style lang="scss" scoped>
.men-main {
display: flex;
align-items: center;
.menu-item {
font-size: 18px;
color: #ffffff;
font-weight: 500;
font-style: normal;
text-transform: none;
margin: 0 10px;
padding: 3px 12px;
cursor: pointer;
}
.activeMenu {
background: #3b4aa2;
border-radius: 32px 32px 32px 32px;
border: 1px solid #ffffff;
}
}
</style>

@ -1,138 +0,0 @@
<template>
<div>
<el-dropdown v-if="router.children" class="menu-item-box" trigger="hover">
<div
class="item-title"
:class="handleActive(router.path) ? 'dropdownActive' : ''"
>
{{ router.meta.title }}
</div>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="(item, itemIndex) in router.children"
:key="itemIndex"
>
<div
v-if="!item.children"
@click="handelePath(router.path, item.path)"
:class="handleActive(item.path) ? 'avtiveRouter' : ''"
>
<svg-icon
v-if="item.meta && item.meta.icon && item.meta.icon !== '#'"
:icon-class="item.meta.icon"
/>
<span style="margin-left: 6px">{{ item.meta.title }} </span>
</div>
<div v-else>
<svg-icon
v-if="item.meta && item.meta.icon && item.meta.icon !== '#'"
:icon-class="item.meta.icon"
/>
<span style="margin-left: 6px">{{ item.meta.title }} </span>
<div
class="recursion"
v-for="(item2, item2Index) in item.children"
:key="item2Index"
>
<item
:router="item2"
:parentRouter="router.path + '/' + item.path"
></item>
</div>
</div>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<div
v-else
class="item-title"
@click="handelePath(parentRouter, router.path)"
:class="handleActive(router.path) ? 'avtiveRouter' : ''"
>
<span>{{ router.meta.title }} </span>
</div>
</div>
</template>
<script>
import item from "./item.vue";
export default {
name: "item",
props: {
parentLevel: {
type: String,
default: "",
},
mainStyle: {
type: Object,
default: () => {},
},
parentRouter: {
type: "",
},
router: {
type: Object,
default: () => {},
},
},
components: {
item,
},
data() {
return {
maxRouter: "",
};
},
mounted() {},
methods: {
handelePath(parent, children) {
console.log(parent, children);
this.$router.push(`${parent}/${children}`);
},
handleActive(path) {
return this.$route.path.includes(path);
},
},
};
</script>
<style lang="scss" scoped>
@import "~@/assets/styles/element-variables.scss";
.item-title {
padding: 3px 10px;
font-size: 18px;
cursor: pointer;
border-radius: 24px;
margin: 0 5px;
color: #fff;
border: 1px solid transparent;
}
.dropdownActive {
border-color: #fff !important;
background: hsla(0, 0%, 100%, 0.15);
}
.recursion {
.item-title {
list-style: none;
padding: 0 20px;
margin: 0;
font-size: 14px;
color: #606266;
cursor: pointer;
outline: none;
border-radius: 0;
}
.item-title:hover {
// background-color: #ecf5ff;
color: $--color-primary !important;
}
}
.avtiveRouter {
color: $--color-primary !important;
// background: $--color-primary !important;
}
</style>

@ -8,7 +8,7 @@
<img class="system-logo" src="@/assets/images/logo.png" />
<div class="system-title">{{ systemTitle }}</div>
<div class="sysyem-menu">
<menu-item></menu-item>
<menu-main></menu-main>
</div>
</div>
<div class="right-menu">
@ -43,17 +43,17 @@
import Breadcrumb from "@/components/Breadcrumb";
import { mapGetters } from "vuex";
import variables from "@/assets/styles/variables.scss";
import MenuItem from "./components/MenuItem.vue";
import MenuMain from "./components/MenuMain";
export default {
components: {
Breadcrumb,
MenuMain,
},
data() {
return {
systemTitle: process.env.VUE_APP_TITLE,
};
},
components: {
MenuItem,
Breadcrumb,
},
computed: {
...mapGetters(["avatar", "name", "sidebarRouters"]),
variables() {
@ -98,7 +98,7 @@ export default {
margin-right: 10px;
}
.system-title {
margin-right: 20px;
margin-right: 30px;
cursor: pointer;
font-size: 22px;
}

@ -1,10 +1,10 @@
import Vue from 'vue'
import Router from 'vue-router'
import Vue from "vue";
import Router from "vue-router";
Vue.use(Router)
Vue.use(Router);
/* Layout */
import Layout from '@/layout'
import Layout from "@/layout";
/**
* Note: 路由配置项
@ -31,153 +31,153 @@ import Layout from '@/layout'
// 公共路由
export const constantRoutes = [
{
path: '/redirect',
path: "/redirect",
component: Layout,
hidden: true,
children: [
{
path: '/redirect/:path(.*)',
component: () => import('@/views/redirect')
}
]
path: "/redirect/:path(.*)",
component: () => import("@/views/redirect"),
},
],
},
{
path: '/login',
component: () => import('@/views/login'),
hidden: true
path: "/login",
component: () => import("@/views/login"),
hidden: true,
},
{
path: '/register',
component: () => import('@/views/register'),
hidden: true
path: "/register",
component: () => import("@/views/register"),
hidden: true,
},
{
path: '/404',
component: () => import('@/views/error/404'),
hidden: true
path: "/404",
component: () => import("@/views/error/404"),
hidden: true,
},
{
path: '/401',
component: () => import('@/views/error/401'),
hidden: true
path: "/401",
component: () => import("@/views/error/401"),
hidden: true,
},
{
path: '',
path: "",
component: Layout,
redirect: 'index',
redirect: "index",
children: [
{
path: 'index',
component: () => import('@/views/index'),
name: 'Index',
meta: { title: '首页', icon: 'dashboard', affix: true }
}
]
path: "index",
component: () => import("@/views/index"),
name: "Index",
meta: { title: "首页", icon: "dashboard", affix: true },
},
],
},
{
path: '/user',
path: "/user",
component: Layout,
hidden: true,
redirect: 'noredirect',
redirect: "noredirect",
children: [
{
path: 'profile',
component: () => import('@/views/system/user/profile/index'),
name: 'Profile',
meta: { title: '个人中心', icon: 'user' }
}
]
}
]
path: "profile",
component: () => import("@/views/system/user/profile/index"),
name: "Profile",
meta: { title: "个人中心", icon: "user" },
},
],
},
];
// 动态路由,基于用户权限动态去加载
export const dynamicRoutes = [
{
path: '/system/user-auth',
path: "/system/user-auth",
component: Layout,
hidden: true,
permissions: ['system:user:edit'],
permissions: ["system:user:edit"],
children: [
{
path: 'role/:userId(\\d+)',
component: () => import('@/views/system/user/authRole'),
name: 'AuthRole',
meta: { title: '分配角色', activeMenu: '/system/user' }
}
]
path: "role/:userId(\\d+)",
component: () => import("@/views/system/user/authRole"),
name: "AuthRole",
meta: { title: "分配角色", activeMenu: "/system/user" },
},
],
},
{
path: '/system/role-auth',
path: "/system/role-auth",
component: Layout,
hidden: true,
permissions: ['system:role:edit'],
permissions: ["system:role:edit"],
children: [
{
path: 'user/:roleId(\\d+)',
component: () => import('@/views/system/role/authUser'),
name: 'AuthUser',
meta: { title: '分配用户', activeMenu: '/system/role' }
}
]
path: "user/:roleId(\\d+)",
component: () => import("@/views/system/role/authUser"),
name: "AuthUser",
meta: { title: "分配用户", activeMenu: "/system/role" },
},
],
},
{
path: '/system/dict-data',
path: "/system/dict-data",
component: Layout,
hidden: true,
permissions: ['system:dict:list'],
permissions: ["system:dict:list"],
children: [
{
path: 'index/:dictId(\\d+)',
component: () => import('@/views/system/dict/data'),
name: 'Data',
meta: { title: '字典数据', activeMenu: '/system/dict' }
}
]
path: "index/:dictId(\\d+)",
component: () => import("@/views/system/dict/data"),
name: "Data",
meta: { title: "字典数据", activeMenu: "/system/dict" },
},
],
},
{
path: '/monitor/job-log',
path: "/monitor/job-log",
component: Layout,
hidden: true,
permissions: ['monitor:job:list'],
permissions: ["monitor:job:list"],
children: [
{
path: 'index/:jobId(\\d+)',
component: () => import('@/views/monitor/job/log'),
name: 'JobLog',
meta: { title: '调度日志', activeMenu: '/monitor/job' }
}
]
path: "index/:jobId(\\d+)",
component: () => import("@/views/monitor/job/log"),
name: "JobLog",
meta: { title: "调度日志", activeMenu: "/monitor/job" },
},
],
},
{
path: '/tool/gen-edit',
path: "/tool/gen-edit",
component: Layout,
hidden: true,
permissions: ['tool:gen:edit'],
permissions: ["tool:gen:edit"],
children: [
{
path: 'index/:tableId(\\d+)',
component: () => import('@/views/tool/gen/editTable'),
name: 'GenEdit',
meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
}
]
}
]
path: "index/:tableId(\\d+)",
component: () => import("@/views/tool/gen/editTable"),
name: "GenEdit",
meta: { title: "修改生成配置", activeMenu: "/tool/gen" },
},
],
},
];
// 防止连续点击多次路由报错
let routerPush = Router.prototype.push;
let routerReplace = Router.prototype.replace;
// push
Router.prototype.push = function push(location) {
return routerPush.call(this, location).catch(err => err)
}
return routerPush.call(this, location).catch((err) => err);
};
// replace
Router.prototype.replace = function push(location) {
return routerReplace.call(this, location).catch(err => err)
}
return routerReplace.call(this, location).catch((err) => err);
};
export default new Router({
mode: 'history', // 去掉url中的#
mode: "history", // 去掉url中的#
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes
})
routes: constantRoutes,
});

@ -0,0 +1,9 @@
<template>
<h1>数据云图</h1>
</template>
<script>
export default {};
</script>
<style></style>

@ -0,0 +1,9 @@
<template>
<h1>在线申报</h1>
</template>
<script>
export default {};
</script>
<style></style>

@ -0,0 +1,13 @@
<template>
<h1>项目库</h1>
</template>
<script>
export default {
data() {
return {};
},
};
</script>
<style></style>

@ -12,7 +12,7 @@ const name = process.env.VUE_APP_TITLE || "金鸡湖现代服务业品牌管理
const port = process.env.port || process.env.npm_config_port || 80; // 端口
// vue.config.js 配置说明
//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
// 官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
// 这里只列一部分,具体配置参考文档
module.exports = {
// 部署生产环境和开发环境下的URL。
@ -35,7 +35,7 @@ module.exports = {
proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: {
target: `http://localhost:8080`,
target: `http://localhost:9040`,
changeOrigin: true,
pathRewrite: {
["^" + process.env.VUE_APP_BASE_API]: "",

Loading…
Cancel
Save