This commit is contained in:
winixt 2021-05-26 14:53:18 +08:00
commit e15a350f6c
14 changed files with 59 additions and 35 deletions

View File

@ -1,5 +1,5 @@
{ {
"version": "2.0.0-rc.25", "version": "2.0.0-rc.26",
"changelog": { "changelog": {
"repo": "WeBankFinTech/fes.js", "repo": "WeBankFinTech/fes.js",
"cacheDir": ".changelog", "cacheDir": ".changelog",

View File

@ -1,6 +1,6 @@
{ {
"name": "@fesjs/create-fes-app", "name": "@fesjs/create-fes-app",
"version": "2.0.0-rc.23", "version": "2.0.0-rc.26",
"description": "create a app base on fes.js", "description": "create a app base on fes.js",
"main": "lib/index.js", "main": "lib/index.js",
"files": [ "files": [

View File

@ -10,3 +10,22 @@ export const beforeRender = {
}); });
} }
}; };
export const qiankun = {
// 应用加载之前
async bootstrap(props) {
console.log('app1 bootstrap', props);
},
// 应用 render 之前触发
async mount(props) {
console.log('app1 mount', props);
},
// 当 props 更新时触发
async update(props) {
console.log('app1 update', props);
},
// 应用卸载之后触发
async unmount(props) {
console.log('app1 unmount', props);
}
};

View File

@ -5,8 +5,8 @@
</template> </template>
<config> <config>
{ {
"name": "index", "name": "test",
"title": "home" "title": "test"
} }
</config> </config>
<script> <script>

View File

@ -1,6 +1,6 @@
{ {
"name": "@fesjs/plugin-qiankun", "name": "@fesjs/plugin-qiankun",
"version": "2.0.0-rc.24", "version": "2.0.0-rc.26",
"description": "@fesjs/plugin-qiankun", "description": "@fesjs/plugin-qiankun",
"main": "lib/index.js", "main": "lib/index.js",
"files": [ "files": [

View File

@ -38,10 +38,12 @@ function getSlaveRuntime() {
// 子应用生命周期钩子Bootstrap // 子应用生命周期钩子Bootstrap
export function genBootstrap(oldRender, appPromise) { export function genBootstrap(oldRender, appPromise) {
return async (props) => { return async (props) => {
if (typeof props !== 'undefined') {
const slaveRuntime = getSlaveRuntime(); const slaveRuntime = getSlaveRuntime();
if (slaveRuntime.bootstrap) { if (slaveRuntime.bootstrap) {
await slaveRuntime.bootstrap(props); await slaveRuntime.bootstrap(props);
} }
}
render = oldRender; render = oldRender;
if (isPromise(appPromise)) { if (isPromise(appPromise)) {
cacheAppPromise = appPromise; cacheAppPromise = appPromise;
@ -61,8 +63,6 @@ export function genMount(mountElementId) {
if (slaveRuntime.mount) { if (slaveRuntime.mount) {
await slaveRuntime.mount(props); await slaveRuntime.mount(props);
} }
}
// 更新 clientRender 配置 // 更新 clientRender 配置
const clientRenderOpts = { const clientRenderOpts = {
// 支持通过 props 注入 container 来限定子应用 mountElementId 的查找范围 // 支持通过 props 注入 container 来限定子应用 mountElementId 的查找范围
@ -79,6 +79,7 @@ export function genMount(mountElementId) {
if(props.onRouterInit){ if(props.onRouterInit){
history.onRouterInit = props.onRouterInit; history.onRouterInit = props.onRouterInit;
} }
}
// 第一次 mount 会自动触发 render非第一次 mount 则需手动触发 // 第一次 mount 会自动触发 render非第一次 mount 则需手动触发
if (hasMountedAtLeastOnce) { if (hasMountedAtLeastOnce) {

View File

@ -1,6 +1,6 @@
{ {
"name": "@fesjs/plugin-request", "name": "@fesjs/plugin-request",
"version": "2.0.0-rc.21", "version": "2.0.0-rc.26",
"description": "@fesjs/plugin-request", "description": "@fesjs/plugin-request",
"main": "lib/index.js", "main": "lib/index.js",
"files": [ "files": [

View File

@ -1,6 +1,6 @@
{ {
"name": "@fesjs/preset-built-in", "name": "@fesjs/preset-built-in",
"version": "2.0.0-rc.24", "version": "2.0.0-rc.26",
"description": "@fesjs/preset-built-in", "description": "@fesjs/preset-built-in",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",

View File

@ -31,7 +31,7 @@ const renderClient = (opts = {}) => {
plugin.applyPlugins({ plugin.applyPlugins({
key: 'onAppCreated', key: 'onAppCreated',
type: ApplyPluginsType.event, type: ApplyPluginsType.event,
args: { app }, args: { app, routes },
}); });
if (rootElement) { if (rootElement) {

View File

@ -16,7 +16,7 @@ export function getRoutes() {
const ROUTER_BASE = '{{{ routerBase }}}'; const ROUTER_BASE = '{{{ routerBase }}}';
let router = null; let router = null;
let history = null; let history = null;
export const createRouter = () => { export const createRouter = (routes) => {
if (router) { if (router) {
return router; return router;
} }
@ -27,7 +27,7 @@ export const createRouter = () => {
}); });
router = createVueRouter({ router = createVueRouter({
history, history,
routes: getRoutes() routes
}); });
plugin.applyPlugins({ plugin.applyPlugins({

View File

@ -1,6 +1,6 @@
import { createRouter } from "./routes"; import { createRouter } from "./routes";
export function onAppCreated({ app }) { export function onAppCreated({ app, routes }) {
const router = createRouter(); const router = createRouter(routes);
app.use(router); app.use(router);
} }

View File

@ -12,3 +12,7 @@ export const request = {
} }
} }
}; };
export function patchRoutes() {
console.log('patchRoutes');
}

View File

@ -1,6 +1,6 @@
{ {
"name": "@fesjs/fes", "name": "@fesjs/fes",
"version": "2.0.0-rc.24", "version": "2.0.0-rc.26",
"description": "一个好用的前端管理台快速开发框架", "description": "一个好用的前端管理台快速开发框架",
"preferGlobal": true, "preferGlobal": true,
"scripts": { "scripts": {
@ -40,7 +40,7 @@
], ],
"dependencies": { "dependencies": {
"@fesjs/compiler": "^2.0.0-rc.5", "@fesjs/compiler": "^2.0.0-rc.5",
"@fesjs/preset-built-in": "^2.0.0-rc.24", "@fesjs/preset-built-in": "^2.0.0-rc.26",
"@fesjs/runtime": "^2.0.0-rc.5", "@fesjs/runtime": "^2.0.0-rc.5",
"@umijs/utils": "3.3.3", "@umijs/utils": "3.3.3",
"resolve-cwd": "^3.0.0" "resolve-cwd": "^3.0.0"