feat: 乾坤增加entry配置,用于区别同一name不同位置用法

This commit is contained in:
wanchun 2022-06-06 17:40:52 +08:00
parent a6b596929b
commit 5a71f2999d
6 changed files with 10 additions and 5 deletions

View File

@ -10,7 +10,7 @@ export default {
layout: {
title: "Fes.js",
footer: 'Created by MumbleFE',
multiTabs: true,
multiTabs: false,
navigation: 'mixin',
menus: [{
name: 'index',

View File

@ -1,6 +1,7 @@
<template>
<div>
main
<input />
<FTabs v-model="activeKey">
<FTabPane name="Tab 1" value="1">
<MicroAppWithMemoHistory key="1" name="app1" url="/app1" a="1" />

View File

@ -2,11 +2,11 @@ import { defaultHistoryType } from '../constants';
function getMicroApp(options) {
const {
key, microAppName, masterHistoryType, base, namespace, ...normalizedRouteProps
key, microAppName, entry, masterHistoryType, base, namespace, ...normalizedRouteProps
} = options;
return `(() => {
const { getMicroAppRouteComponent } = require('@@/${namespace}/getMicroAppRouteComponent');
return getMicroAppRouteComponent({key: '${key}', appName: '${microAppName}', base: '${base}', masterHistoryType: '${masterHistoryType}', routeProps: ${JSON.stringify(normalizedRouteProps)} })
return getMicroAppRouteComponent({key: '${key}', appName: '${microAppName}', entry: '${entry}', base: '${base}', masterHistoryType: '${masterHistoryType}', routeProps: ${JSON.stringify(normalizedRouteProps)} })
})()`;
}
@ -19,6 +19,7 @@ function modifyRoutesWithAttachMode({
if (route.meta && route.meta.microApp) {
route.component = getMicroApp({
key: route.path,
entry: route.meta.entry ?? route.path,
microAppName: route.meta.microApp,
masterHistoryType,
base,

View File

@ -28,6 +28,7 @@ export const MicroApp = defineComponent({
type: String,
required: true
},
entry: String,
settings: Object,
props: Object,
lifeCycles: Object
@ -80,7 +81,7 @@ export const MicroApp = defineComponent({
const app = loadMicroApp(
{
// 保证唯一
name: `${name}`,
name: `${name}_${props.entry || ''}`,
entry: entry,
container: containerRef.value,
props: {...propsConfigRef.value}

View File

@ -14,6 +14,7 @@ export const MicroAppWithMemoHistory = defineComponent({
type: String,
required: true
},
entry: String,
settings: Object,
props: Object,
lifeCycles: Object,

View File

@ -3,10 +3,11 @@ import { MicroApp } from './MicroApp';
export function getMicroAppRouteComponent({
key,
appName,
entry,
base,
masterHistoryType,
routeProps
}) {
return <MicroApp key={key} base={base} masterHistoryType={masterHistoryType} name={appName} {...routeProps} />;
return <MicroApp key={key} base={base} masterHistoryType={masterHistoryType} name={appName} entry={entry} {...routeProps} />;
}