通过路由跳转至子应用
This commit is contained in:
parent
0db37fa82c
commit
60c4c39e7e
@ -1,8 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
|
||||||
<!-- <el-button v-for="item in microApps" :key="item.activeRule" type="primary" @click="gotoPage(item)">{{ item.name }}</el-button> -->
|
<!-- <el-button v-for="item in microApps" :key="item.activeRule" type="primary" @click="gotoPage(item)">{{ item.name }}</el-button> -->
|
||||||
<router-view />
|
<router-view />
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="App">
|
<script setup name="App">
|
||||||
|
@ -81,7 +81,7 @@ const meuns = ref([
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '农事服务',
|
label: '农事服务',
|
||||||
path: '/sub-admin/',
|
path: '/sub-admin/home',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '涉农金融',
|
label: '涉农金融',
|
||||||
|
@ -5,11 +5,9 @@ import router from './router';
|
|||||||
import pinia from './store';
|
import pinia from './store';
|
||||||
import ElementPlus from 'element-plus';
|
import ElementPlus from 'element-plus';
|
||||||
import 'element-plus/dist/index.css';
|
import 'element-plus/dist/index.css';
|
||||||
import { registerGlobalMicroApps } from './micro';
|
|
||||||
import { registerElIcons } from './plugins/icon';
|
import { registerElIcons } from './plugins/icon';
|
||||||
import './utils/permission';
|
import './utils/permission';
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
app.use(pinia).use(router).use(ElementPlus).mount('#root');
|
app.use(pinia).use(router).use(ElementPlus).mount('#root');
|
||||||
registerElIcons(app);
|
registerElIcons(app);
|
||||||
registerGlobalMicroApps();
|
|
||||||
|
@ -69,7 +69,7 @@ export const microApps = [...leftApps, ...rightApps];
|
|||||||
const apps = microApps.map((item) => {
|
const apps = microApps.map((item) => {
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
container: '#app',
|
container: '#sub-app',
|
||||||
props: {
|
props: {
|
||||||
routerBase: item.activeRule,
|
routerBase: item.activeRule,
|
||||||
getGlobalState: actions.getGlobalState,
|
getGlobalState: actions.getGlobalState,
|
||||||
|
@ -12,6 +12,12 @@ export const constantRoutes = [
|
|||||||
icon: 'Login',
|
icon: 'Login',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/platform',
|
||||||
|
component: () => import('@/views/index.vue'),
|
||||||
|
name: 'platform',
|
||||||
|
meta: { title: '平台入口', icon: 'House' },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'layout',
|
name: 'layout',
|
||||||
@ -20,11 +26,18 @@ export const constantRoutes = [
|
|||||||
meta: { title: '平台入口', icon: 'House' },
|
meta: { title: '平台入口', icon: 'House' },
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '/platform',
|
path: '/home',
|
||||||
component: () => import('@/views/index.vue'),
|
component: () => import('@/views/home.vue'),
|
||||||
name: 'platform',
|
name: 'home',
|
||||||
meta: { title: '平台入口', icon: 'House' },
|
meta: { title: '平台入口', icon: 'House' },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/sub-admin/:pathMatch(.*)',
|
||||||
|
component: () => import('@/views/subApp.vue'),
|
||||||
|
name: 'sub-admin',
|
||||||
|
hidden: true,
|
||||||
|
meta: { title: '子应用入口', icon: 'House' },
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
7
main/src/views/home.vue
Normal file
7
main/src/views/home.vue
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
<div>home</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup></script>
|
||||||
|
|
||||||
|
<style></style>
|
20
main/src/views/subApp.vue
Normal file
20
main/src/views/subApp.vue
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<template>
|
||||||
|
<div id="sub-app"></div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { registerGlobalMicroApps } from '@/micro';
|
||||||
|
export default {
|
||||||
|
mounted() {
|
||||||
|
if (!window.qiankunStarted) {
|
||||||
|
window.qiankunStarted = true;
|
||||||
|
registerGlobalMicroApps();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
#app {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
x
Reference in New Issue
Block a user