Commit 265405b7 by 周海峰

Merge branch 'master' of https://code.palacesun.com/wuchao/nse-ui

parents de8b37c0 072a1325
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<template v-if="hasOneShowingChild(item.children, item) && (!onlyOneChild.children || onlyOneChild.noShowingChildren) && !item.alwaysShow"> <template v-if="hasOneShowingChild(item.children, item) && (!onlyOneChild.children || onlyOneChild.noShowingChildren) && !item.alwaysShow">
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path, onlyOneChild.query)"> <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path, onlyOneChild.query)">
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{ 'submenu-title-noDropdown': !isNest }" @click="pageLuyou(onlyOneChild)"> <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{ 'submenu-title-noDropdown': !isNest }" @click="pageLuyou(onlyOneChild)">
<!-- <svg-icon :icon-class="onlyOneChild.meta.icon || (item.meta && item.meta.icon)"/> -->
<template #title><span class="menu-title" :title="hasTitle(onlyOneChild.meta.title)" >{{ onlyOneChild.meta.title }}</span></template> <template #title><span class="menu-title" :title="hasTitle(onlyOneChild.meta.title)" >{{ onlyOneChild.meta.title }}</span></template>
</el-menu-item> </el-menu-item>
</app-link> </app-link>
......
...@@ -334,10 +334,10 @@ const router = useRouter() ...@@ -334,10 +334,10 @@ const router = useRouter()
sessionStorage.setItem('navList', JSON.stringify(data)) sessionStorage.setItem('navList', JSON.stringify(data))
}, },
setallNav(data) { setallNav(data) {
this.allnavList = data this.allnavList = deepCloneRoutes(data)
sessionStorage.setItem('allnavList', JSON.stringify(data)) sessionStorage.setItem('allnavList', JSON.stringify(data))
}, },
setNavOpen(data) { setNavOpen(data) {
this.navOpen = data this.navOpen = data
}, },
...@@ -376,7 +376,15 @@ const router = useRouter() ...@@ -376,7 +376,15 @@ const router = useRouter()
}) })
} }
} }
} },
}) // 安全的深拷贝方法(保留组件引用)
})
function deepCloneRoutes(routes) {
return routes.map(route => ({
...route,
component: route.component, // 直接保留引用
children: route.children ? deepCloneRoutes(route.children) : []
}))
}
export default useAppStore export default useAppStore
\ No newline at end of file
import useAppStore from '@/store/modules/app'
import usePermissionStore from '@/store/modules/permission'
const appStore = useAppStore()
const permissionStore = usePermissionStore()
export function changeRoute() {
let menus = appStore.allnavList
console.log('allnavList',menus)
let type = appStore.navStatus.type === 'manage' ? 'project' : 'manage'
let filterMenus = type === 'manage' ? menus.filter(item => item.type === '1') : menus.filter(item => item.type === '2')
console.log('filterMenus',filterMenus)
appStore.setallNav(menus)
appStore.setNavStatus({type: type})
permissionStore.setSidebarRouters(filterMenus)
}
\ No newline at end of file
...@@ -8,6 +8,7 @@ import TableInfoTab from './modules/TableInfoTab.vue' ...@@ -8,6 +8,7 @@ import TableInfoTab from './modules/TableInfoTab.vue'
import StructureTab from './modules/StructureTab.vue' import StructureTab from './modules/StructureTab.vue'
import EncryptionTab from './modules/EncryptionTab.vue' import EncryptionTab from './modules/EncryptionTab.vue'
import { changeRoute } from '@/utils/switchRoute'
import { useDict } from '@/utils/dict' import { useDict } from '@/utils/dict'
...@@ -138,18 +139,10 @@ const openDecrypt = ref(false) ...@@ -138,18 +139,10 @@ const openDecrypt = ref(false)
function pageProjectManage() { function pageProjectManage() {
let filterMenus = appStore.navStatus.type === 'manage' ? appStore.allnavList.filter(item => item.type === '1') : appStore.allnavList.filter(item => item.type === '2') changeRoute()
// 设置导航菜单
appStore.setNav(filterMenus)
permissionStore.setSidebarRouters(filterMenus)
let type = appStore.navStatus.type === 'manage' ? 'project' : 'manage'
appStore.setNavStatus({type: type})
router.push({ router.push({
path: '/projectManage' path: '/project/Project'
}) })
} }
defineExpose({ defineExpose({
......
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
import { getCurrentInstance, reactive, ref, toRefs } from 'vue' import { getCurrentInstance, reactive, ref, toRefs } from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import QueryForm from './QueryForm.vue' import QueryForm from './QueryForm.vue'
// import ProjectEditDialog from './ProjectEditDialog.vue' import { changeRoute } from '@/utils/switchRoute'
// import DownloadPluginDialog from './DownloadPluginDialog.vue'
// import ExportDialog from './ExportDialog.vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import useAppStore from '@/store/modules/app' import useAppStore from '@/store/modules/app'
...@@ -83,18 +81,10 @@ const tableData = ref([ ...@@ -83,18 +81,10 @@ const tableData = ref([
]); ]);
function pageProjectManage() { function pageProjectManage() {
let filterMenus = appStore.navStatus.type === 'manage' ? appStore.allnavList.filter(item => item.type === '1') : appStore.allnavList.filter(item => item.type === '2') changeRoute()
// 设置导航菜单
appStore.setNav(filterMenus)
permissionStore.setSidebarRouters(filterMenus)
let type = appStore.navStatus.type === 'manage' ? 'project' : 'manage'
appStore.setNavStatus({type: type})
router.push({ router.push({
path: '/projectManage' path: '/project/Project'
}) })
} }
/** /**
......
...@@ -6,7 +6,7 @@ import AddStrategyDialog from './modules/AddStrategyDialog.vue' ...@@ -6,7 +6,7 @@ import AddStrategyDialog from './modules/AddStrategyDialog.vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import useAppStore from '@/store/modules/app' import useAppStore from '@/store/modules/app'
import usePermissionStore from '@/store/modules/permission' import usePermissionStore from '@/store/modules/permission'
import { changeRoute } from '@/utils/switchRoute'
const appStore = useAppStore() const appStore = useAppStore()
const permissionStore = usePermissionStore() const permissionStore = usePermissionStore()
const router = useRouter() const router = useRouter()
...@@ -54,19 +54,10 @@ function getList() { ...@@ -54,19 +54,10 @@ function getList() {
} }
function pageProjectManage() { function pageProjectManage() {
let filterMenus = appStore.navStatus.type === 'manage' ? changeRoute()
appStore.allnavList.filter(item => item.type === '1') :
appStore.allnavList.filter(item => item.type === '2')
// 设置导航菜单
appStore.setNav(filterMenus)
permissionStore.setSidebarRouters(filterMenus)
let type = appStore.navStatus.type === 'manage' ? 'project' : 'manage'
appStore.setNavStatus({type: type})
router.push({ router.push({
path: '/projectManage' path: '/project/Project'
}) })
} }
......
<script setup name="ProjectHome"> <script setup name="ProjectHome">
import { ref, toRefs, reactive, getCurrentInstance, proxyRefs, onMounted } from 'vue' import { ref, toRefs, reactive, getCurrentInstance, proxyRefs, onMounted } from 'vue'
import { useDict } from '@/utils/dict' import { useDict } from '@/utils/dict'
import { changeRoute } from '@/utils/switchRoute'
import biao from '@/assets/images/project/biao.png' import biao from '@/assets/images/project/biao.png'
import jiamibiao from '@/assets/images/project/jiamibiao.png' import jiamibiao from '@/assets/images/project/jiamibiao.png'
import jiamiziduan from '@/assets/images/project/jiamiziduan.png' import jiamiziduan from '@/assets/images/project/jiamiziduan.png'
...@@ -83,18 +83,9 @@ getInfo() ...@@ -83,18 +83,9 @@ getInfo()
function pageProjectManage() { function pageProjectManage() {
let filterMenus = appStore.navStatus.type === 'manage' ? appStore.allnavList.filter(item => item.type === '1') : appStore.allnavList.filter(item => item.type === '2') changeRoute()
// 设置导航菜单
appStore.setNav(filterMenus)
permissionStore.setSidebarRouters(filterMenus)
let type = appStore.navStatus.type === 'manage' ? 'project' : 'manage'
appStore.setNavStatus({type: type})
router.push({ router.push({
path: '/projectManage' path: '/project/Project'
}) })
} }
......
...@@ -143,7 +143,7 @@ function handleLogin() { ...@@ -143,7 +143,7 @@ function handleLogin() {
appStore.setNav(filterMenus) appStore.setNav(filterMenus)
appStore.setallNav(menus) appStore.setallNav(menus)
console.log('appStore.nav',appStore.allnavList)
// console.log('menus',filterMenus) // console.log('menus',filterMenus)
// permissionStore.allsidebarRouters(menus) // permissionStore.allsidebarRouters(menus)
...@@ -205,6 +205,7 @@ function handleLogin() { ...@@ -205,6 +205,7 @@ function handleLogin() {
} }
function transformRoutes(originalRoutes) { function transformRoutes(originalRoutes) {
return originalRoutes.map(route => { return originalRoutes.map(route => {
const hasChildren = route.submenu && route.submenu.length > 0
// 基础转换 - 所有路由都使用Layout作为父组件 // 基础转换 - 所有路由都使用Layout作为父组件
const transformedRoute = { const transformedRoute = {
path: route.url, path: route.url,
...@@ -217,13 +218,15 @@ function transformRoutes(originalRoutes) { ...@@ -217,13 +218,15 @@ function transformRoutes(originalRoutes) {
title: route.menuname, title: route.menuname,
icon: route.icon, icon: route.icon,
noCache: false, noCache: false,
link: null link: null,
singleLevel: !hasChildren
}, },
children: [] // 初始化children数组 children: [] // 初始化children数组
}; };
// 处理有子路由的情况 // 处理有子路由的情况
if (route.submenu && route.submenu.length > 0) { if (hasChildren) {
transformedRoute.alwaysShow = true
transformedRoute.children = route.submenu.map(child => ({ transformedRoute.children = route.submenu.map(child => ({
path: child.url.startsWith('/') ? child.url.substring(1) : child.url, path: child.url.startsWith('/') ? child.url.substring(1) : child.url,
name: child.menuname.replace(/\s+/g, ''), name: child.menuname.replace(/\s+/g, ''),
...@@ -255,9 +258,9 @@ function transformRoutes(originalRoutes) { ...@@ -255,9 +258,9 @@ function transformRoutes(originalRoutes) {
} }
// 添加alwaysShow属性给有子路由的项 // 添加alwaysShow属性给有子路由的项
if (transformedRoute.children && transformedRoute.children.length > 0) { // if (transformedRoute.children && transformedRoute.children.length > 0) {
transformedRoute.alwaysShow = true; // transformedRoute.alwaysShow = true;
} // }
// console.log('transformedRoute',transformedRoute) // console.log('transformedRoute',transformedRoute)
return transformedRoute; return transformedRoute;
......
...@@ -6,6 +6,7 @@ import ProjectEditDialog from './ProjectEditDialog.vue' ...@@ -6,6 +6,7 @@ import ProjectEditDialog from './ProjectEditDialog.vue'
import DownloadPluginDialog from './DownloadPluginDialog.vue' import DownloadPluginDialog from './DownloadPluginDialog.vue'
import ExportDialog from './ExportDialog.vue' import ExportDialog from './ExportDialog.vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import {changeRoute} from '@/utils/switchRoute'
const router = useRouter() const router = useRouter()
const emit = defineEmits(['page']) const emit = defineEmits(['page'])
const { proxy } = getCurrentInstance() const { proxy } = getCurrentInstance()
...@@ -115,9 +116,8 @@ const handleCommandProject = (command, project) => { ...@@ -115,9 +116,8 @@ const handleCommandProject = (command, project) => {
// 具体操作方法 // 具体操作方法
const handleEnterProject = (project) => { const handleEnterProject = (project) => {
console.log('进入项目:', project) console.log('进入项目:', project)
// // ElMessage.success(`进入项目 ${project.projectName}`) changeRoute()
// emit('page', 'detail', { projectId: project.id}) router.push({ path:'/indexManage/ItemManage',query: { projectId: project.id } })
router.push({ path:'/projectHome',query: { projectId: project.id } })
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论