Browse Source

Fix 731 (#750)

* fix:#731 (#749)
* 代码生成器样式调整
Co-authored-by: songkang1993 <38366752+songkang1993@users.noreply.github.com>
main
奇淼(piexlmax 3 years ago
committed by GitHub
parent
commit
4d66ffcd95
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      web/src/store/module/router.js
  2. 1
      web/src/view/dashboard/index.vue
  3. 9
      web/src/view/example/index.vue
  4. 10
      web/src/view/layout/index.vue
  5. 9
      web/src/view/routerHolder.vue
  6. 9
      web/src/view/superAdmin/index.vue
  7. 6
      web/src/view/systemTools/autoCode/index.vue
  8. 9
      web/src/view/systemTools/index.vue

23
web/src/store/module/router.js

@ -3,6 +3,7 @@ import { asyncRouterHandle } from '@/utils/asyncRouter'
import { asyncMenu } from '@/api/menu' import { asyncMenu } from '@/api/menu'
const routerList = [] const routerList = []
const keepAliveRouters = []
const formatRouter = (routes) => { const formatRouter = (routes) => {
routes && routes.forEach(item => { routes && routes.forEach(item => {
@ -16,11 +17,24 @@ const formatRouter = (routes) => {
}) })
} }
const KeepAliveFilter = (routes) => {
routes && routes.forEach(item => {
// 子菜单中有 keep-alive 的,父菜单也必须 keep-alive,否则无效。这里将子菜单中有 keep-alive 的父菜单也加入。
if ((item.children && item.children.some(ch => ch.meta.keepAlive) || item.meta.keepAlive)) {
item.component().then(val => { keepAliveRouters.push(val.default.name) })
}
if (item.children && item.children.length > 0) {
KeepAliveFilter(item.children)
}
})
}
export const router = { export const router = {
namespaced: true, namespaced: true,
state: { state: {
asyncRouters: [], asyncRouters: [],
routerList: routerList, routerList: routerList,
keepAliveRouters: keepAliveRouters
}, },
mutations: { mutations: {
setRouterList(state, routerList) { setRouterList(state, routerList) {
@ -29,6 +43,10 @@ export const router = {
// 设置动态路由 // 设置动态路由
setAsyncRouter(state, asyncRouters) { setAsyncRouter(state, asyncRouters) {
state.asyncRouters = asyncRouters state.asyncRouters = asyncRouters
},
// 设置需要缓存的路由
setKeepAliveRouters(state, keepAliveRouters) {
state.keepAliveRouters = keepAliveRouters
} }
}, },
actions: { actions: {
@ -62,8 +80,10 @@ export const router = {
}) })
asyncRouterHandle(baseRouter) asyncRouterHandle(baseRouter)
KeepAliveFilter(asyncRouter)
commit('setAsyncRouter', baseRouter) commit('setAsyncRouter', baseRouter)
commit('setRouterList', routerList) commit('setRouterList', routerList)
commit('setKeepAliveRouters', keepAliveRouters)
return true return true
} }
}, },
@ -74,6 +94,9 @@ export const router = {
}, },
routerList(state) { routerList(state) {
return state.routerList return state.routerList
},
keepAliveRouters(state) {
return state.keepAliveRouters
} }
} }
} }

1
web/src/view/dashboard/index.vue

@ -96,6 +96,7 @@
import echartsLine from '@/view/dashboard/dashbordCharts/echartsLine.vue' import echartsLine from '@/view/dashboard/dashbordCharts/echartsLine.vue'
import dashbordTable from '@/view/dashboard/dashbordTable/dashbordTable.vue' import dashbordTable from '@/view/dashboard/dashbordTable/dashbordTable.vue'
export default { export default {
name: 'Dashboard',
components: { components: {
echartsLine, echartsLine,
dashbordTable dashbordTable

9
web/src/view/example/index.vue

@ -1,17 +1,12 @@
<template> <template>
<div> <div>
<router-view v-if="$route.meta.keepAlive" v-slot="{ Component }">
<router-view v-slot="{ Component }">
<transition mode="out-in" name="el-fade-in-linear"> <transition mode="out-in" name="el-fade-in-linear">
<keep-alive>
<keep-alive :include="$store.getters['router/keepAliveRouters']">
<component :is="Component" /> <component :is="Component" />
</keep-alive> </keep-alive>
</transition> </transition>
</router-view> </router-view>
<router-view v-if="!$route.meta.keepAlive" v-slot="{ Component }">
<transition mode="out-in" name="el-fade-in-linear">
<component :is="Component" />
</transition>
</router-view>
</div> </div>
</template> </template>

10
web/src/view/layout/index.vue

@ -78,19 +78,13 @@
<HistoryComponent ref="layoutHistoryComponent" /> <HistoryComponent ref="layoutHistoryComponent" />
</div> </div>
</transition> </transition>
<router-view v-if="$route.meta.keepAlive && reloadFlag" v-slot="{ Component }" v-loading="loadingFlag" element-loading-text="正在加载中" class="admin-box">
<router-view v-if="reloadFlag" v-slot="{ Component }" v-loading="loadingFlag" element-loading-text="正在加载中" class="admin-box">
<transition mode="out-in" name="el-fade-in-linear"> <transition mode="out-in" name="el-fade-in-linear">
<keep-alive>
<keep-alive :include="$store.getters['router/keepAliveRouters']">
<component :is="Component" /> <component :is="Component" />
</keep-alive> </keep-alive>
</transition> </transition>
</router-view> </router-view>
<router-view v-if="!$route.meta.keepAlive && reloadFlag" v-slot="{ Component }" v-loading="loadingFlag" element-loading-text="正在加载中" class="admin-box">
<transition mode="out-in" name="el-fade-in-linear">
<component :is="Component" />
</transition>
</router-view>
<BottomInfo /> <BottomInfo />
<setting /> <setting />
</el-main> </el-main>

9
web/src/view/routerHolder.vue

@ -1,18 +1,13 @@
<!-- 此路由可作为父类路由通用路由页面使用 如需自定义父类路由页面 请参考 @/view/superAdmin/index.vue --> <!-- 此路由可作为父类路由通用路由页面使用 如需自定义父类路由页面 请参考 @/view/superAdmin/index.vue -->
<template> <template>
<div> <div>
<router-view v-if="$route.meta.keepAlive" v-slot="{ Component }">
<router-view v-slot="{ Component }">
<transition mode="out-in" name="el-fade-in-linear"> <transition mode="out-in" name="el-fade-in-linear">
<keep-alive>
<keep-alive :include="$store.getters['router/keepAliveRouters']">
<component :is="Component" /> <component :is="Component" />
</keep-alive> </keep-alive>
</transition> </transition>
</router-view> </router-view>
<router-view v-if="!$route.meta.keepAlive" v-slot="{ Component }">
<transition mode="out-in" name="el-fade-in-linear">
<component :is="Component" />
</transition>
</router-view>
</div> </div>
</template> </template>

9
web/src/view/superAdmin/index.vue

@ -1,17 +1,12 @@
<template> <template>
<div> <div>
<router-view v-if="$route.meta.keepAlive" v-slot="{ Component }">
<router-view v-slot="{ Component }">
<transition mode="out-in" name="el-fade-in-linear"> <transition mode="out-in" name="el-fade-in-linear">
<keep-alive>
<keep-alive :include="$store.getters['router/keepAliveRouters']">
<component :is="Component" /> <component :is="Component" />
</keep-alive> </keep-alive>
</transition> </transition>
</router-view> </router-view>
<router-view v-if="!$route.meta.keepAlive" v-slot="{ Component }">
<transition mode="out-in" name="el-fade-in-linear">
<component :is="Component" />
</transition>
</router-view>
</div> </div>
</template> </template>

6
web/src/view/systemTools/autoCode/index.vue

@ -129,9 +129,8 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-tag type="danger" style="margin:12px 0;">id , created_at , updated_at , deleted_at 会自动生成请勿重复创建</el-tag>
<!-- 组件列表 --> <!-- 组件列表 -->
<div class="gva-btn-list justify-content-flex-end">
<div class="gva-btn-list justify-content-flex-end auto-btn-list">
<el-button size="mini" type="primary" @click="enterForm(true)">预览代码</el-button> <el-button size="mini" type="primary" @click="enterForm(true)">预览代码</el-button>
<el-button size="mini" type="primary" @click="enterForm(false)">生成代码</el-button> <el-button size="mini" type="primary" @click="enterForm(false)">生成代码</el-button>
</div> </div>
@ -454,4 +453,7 @@ export default {
float: right; float: right;
} }
} }
.auto-btn-list{
margin-top: 16px;
}
</style> </style>

9
web/src/view/systemTools/index.vue

@ -1,17 +1,12 @@
<template> <template>
<div> <div>
<router-view v-if="$route.meta.keepAlive" v-slot="{ Component }">
<router-view v-slot="{ Component }">
<transition mode="out-in" name="el-fade-in-linear"> <transition mode="out-in" name="el-fade-in-linear">
<keep-alive>
<keep-alive :include="$store.getters['router/keepAliveRouters']">
<component :is="Component" /> <component :is="Component" />
</keep-alive> </keep-alive>
</transition> </transition>
</router-view> </router-view>
<router-view v-if="!$route.meta.keepAlive" v-slot="{ Component }">
<transition mode="out-in" name="el-fade-in-linear">
<component :is="Component" />
</transition>
</router-view>
</div> </div>
</template> </template>

Loading…
Cancel
Save