Browse Source

iframe 嵌套缓存处理 暂缓

dev_web_online
陈薪名 2 years ago
parent
commit
a8fd7f483e
  1. 66
      fe/PC/src/layout/components/AppMain.vue
  2. 6
      fe/PC/src/store/modules/permission.js

66
fe/PC/src/layout/components/AppMain.vue

@ -8,22 +8,58 @@
<!-- 不要缓存即切换tab页就刷新 --> <!-- 不要缓存即切换tab页就刷新 -->
<router-view v-if="$route.meta.keepAlive" :key="key" /> <router-view v-if="$route.meta.keepAlive" :key="key" />
</transition> </transition>
<!--iframe页-->
<!-- <component
v-for="item in hasOpenComponentsArr"
:key="item.path"
:is="item.name"
v-show="$route.path.indexOf(item.path) > -1"
></component> -->
</section> </section>
</template> </template>
<script> <script>
// import Vue from 'vue'
import Bus from '../Bus.js'; import Bus from '../Bus.js';
export default { export default {
name: "AppMain", name: "AppMain",
// data() {
// return {
// componentsArr: []
// }
// },
computed: { computed: {
cachedViews() { cachedViews() {
return this.$store.state.tagsView.cachedViews; return this.$store.state.tagsView.cachedViews;
}, },
key() { key() {
return this.$route.fullPath; return this.$route.fullPath;
}
}, },
// hasOpen:trueiframe
// hasOpenComponentsArr() {
// return this.componentsArr.filter(item => {
// return item.hasOpen
// });
// }
},
// watch: {
// $route() {
// // iframe
// this.isOpenIframePage();
// }
// },
mounted() { mounted() {
// iframe
// setTimeout(() => {
// const componentsArr = this.getComponentsArr();
// componentsArr.forEach((item) => {
// Vue.component(item.name, item.component);
// });
// this.componentsArr = componentsArr;
// // iframe
// this.isOpenIframePage();
// }, 1000)
// //
Bus.$on('removeCache', (name, view) => { Bus.$on('removeCache', (name, view) => {
this.removeCache(name, view); this.removeCache(name, view);
@ -38,6 +74,33 @@ export default {
Bus.$off('removeRedirect'); Bus.$off('removeRedirect');
}, },
methods: { methods: {
// iframe -----------------start
// hasOpen
// isOpenIframePage() {
// const target = this.componentsArr.find(item => {
// return this.$route.path.indexOf(item.path) > -1
// });
// if (target && !target.hasOpen) {
// target.hasOpen = true;
// }
// },
// // iframeComponent
// getComponentsArr() {
// const activeReportManage = this.$store.getters.permission_routes.find(item => item.path == '/activeReportManage')
// console.log('permission_routes', this.$store.getters.permission_routes)
// console.log('activeReportManage', activeReportManage)
// const reportForm = activeReportManage.children.find(item => item.path == 'reportForm').children
// console.log('reportForm', reportForm)
// // const reportForm = this.$store.getters.permission_routes.find(item => item.path == '/activeReportManage').children.find(item => item.path == 'reportForm').children
// const iframeArr = []
// reportForm.forEach(item => {
// item.component = item.iframeComponent
// iframeArr.push(item)
// })
// return iframeArr
// },
// iframe -----------------end
// keep-aliveVnode // keep-aliveVnode
getVnode() { getVnode() {
// //
@ -69,7 +132,6 @@ export default {
let keyStart = vnode.key.split('/')[0]; let keyStart = vnode.key.split('/')[0];
let thisKey = `${keyStart}${view.fullPath}`; let thisKey = `${keyStart}${view.fullPath}`;
let regKey = `${keyStart}${view.path}`; let regKey = `${keyStart}${view.path}`;
this[name]({ componentInstance, thisKey, regKey }); this[name]({ componentInstance, thisKey, regKey });
}, },
// //

6
fe/PC/src/store/modules/permission.js

@ -46,6 +46,12 @@ export function generaMenu(routes, data) {
} else { } else {
menu.level = 3 menu.level = 3
} }
// iframe页面处理
// if (item.permission.indexOf('Report') > -1) {
// // delete menu.component
// menu.iframeComponent = item.component === '@/layout' ? Layout : loadView(item.component)
// menu.hasOpen = false // 是否打开过,默认false
// }
if (item.children && item.children.length > 0) { if (item.children && item.children.length > 0) {
generaMenu(menu.children, item.children) generaMenu(menu.children, item.children)
} }

Loading…
Cancel
Save