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: { layout: {
title: "Fes.js", title: "Fes.js",
footer: 'Created by MumbleFE', footer: 'Created by MumbleFE',
multiTabs: true, multiTabs: false,
navigation: 'mixin', navigation: 'mixin',
menus: [{ menus: [{
name: 'index', name: 'index',

View File

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

View File

@ -2,11 +2,11 @@ import { defaultHistoryType } from '../constants';
function getMicroApp(options) { function getMicroApp(options) {
const { const {
key, microAppName, masterHistoryType, base, namespace, ...normalizedRouteProps key, microAppName, entry, masterHistoryType, base, namespace, ...normalizedRouteProps
} = options; } = options;
return `(() => { return `(() => {
const { getMicroAppRouteComponent } = require('@@/${namespace}/getMicroAppRouteComponent'); 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) { if (route.meta && route.meta.microApp) {
route.component = getMicroApp({ route.component = getMicroApp({
key: route.path, key: route.path,
entry: route.meta.entry ?? route.path,
microAppName: route.meta.microApp, microAppName: route.meta.microApp,
masterHistoryType, masterHistoryType,
base, base,

View File

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

View File

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

View File

@ -3,10 +3,11 @@ import { MicroApp } from './MicroApp';
export function getMicroAppRouteComponent({ export function getMicroAppRouteComponent({
key, key,
appName, appName,
entry,
base, base,
masterHistoryType, masterHistoryType,
routeProps 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} />;
} }