mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
fix(plugin-qiankun): 修复路由切换时自应用未正确销毁
This commit is contained in:
parent
6b7dc0324a
commit
2e893ae612
1
packages/fes-plugin-qiankun/examples/app1/.env
Normal file
1
packages/fes-plugin-qiankun/examples/app1/.env
Normal file
@ -0,0 +1 @@
|
|||||||
|
PORT=8001
|
14
packages/fes-plugin-qiankun/examples/app1/.eslintrc.js
Normal file
14
packages/fes-plugin-qiankun/examples/app1/.eslintrc.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
module.exports = {
|
||||||
|
extends: ['@webank/eslint-config-webank/vue.js'],
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: [
|
||||||
|
'**/__tests__/*.{j,t}s?(x)',
|
||||||
|
'**/tests/unit/**/*.spec.{j,t}s?(x)'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
env: {
|
||||||
|
jest: true
|
||||||
|
}
|
||||||
|
};
|
12
packages/fes-plugin-qiankun/examples/app1/.fes.js
Normal file
12
packages/fes-plugin-qiankun/examples/app1/.fes.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// .fes.js 只负责管理编译时配置,只能使用plain Object
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
qiankun: {
|
||||||
|
micro: {}
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
require.resolve('../../../fes-plugin-model/lib'),
|
||||||
|
require.resolve('../../../fes-plugin-qiankun/lib'),
|
||||||
|
]
|
||||||
|
};
|
11
packages/fes-plugin-qiankun/examples/app1/.gitignore
vendored
Normal file
11
packages/fes-plugin-qiankun/examples/app1/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# fes
|
||||||
|
/src/.fes
|
||||||
|
/src/.fes-production
|
||||||
|
/src/.fes-test
|
||||||
|
/.env.local
|
21
packages/fes-plugin-qiankun/examples/app1/LICENSE
Normal file
21
packages/fes-plugin-qiankun/examples/app1/LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020-present webank
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
54
packages/fes-plugin-qiankun/examples/app1/package.json
Normal file
54
packages/fes-plugin-qiankun/examples/app1/package.json
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"name": "app1",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"description": "fes项目模版",
|
||||||
|
"scripts": {
|
||||||
|
"build": "fes build",
|
||||||
|
"prod": "FES_ENV=prod fes build",
|
||||||
|
"analyze": "ANALYZE=1 fes build",
|
||||||
|
"dev": "fes dev",
|
||||||
|
"test": "fes test"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"管理端",
|
||||||
|
"fes",
|
||||||
|
"fast",
|
||||||
|
"easy",
|
||||||
|
"strong"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
".eslintrc.js",
|
||||||
|
".gitignore",
|
||||||
|
".fes.js",
|
||||||
|
".fes.prod.js",
|
||||||
|
"mock.js",
|
||||||
|
"package.json",
|
||||||
|
"README.md",
|
||||||
|
"tsconfig.json",
|
||||||
|
"/src",
|
||||||
|
"/config"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/WeBankFinTech/fes.js.git",
|
||||||
|
"directory": "packages/fes-template"
|
||||||
|
},
|
||||||
|
"author": "harrywan",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/WeBankFinTech/fes.js/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/WeBankFinTech/fes.js#readme",
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@webank/eslint-config-webank": "0.2.10"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fesjs/fes": "^2.0.0-rc.0",
|
||||||
|
"vue": "^3.0.5",
|
||||||
|
"ant-design-vue": "2.0.0"
|
||||||
|
},
|
||||||
|
"private": true
|
||||||
|
}
|
12
packages/fes-plugin-qiankun/examples/app1/src/app.js
Normal file
12
packages/fes-plugin-qiankun/examples/app1/src/app.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import PageLoading from '@/components/PageLoading';
|
||||||
|
|
||||||
|
export const beforeRender = {
|
||||||
|
loading: <PageLoading />,
|
||||||
|
action() {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve();
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,29 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page-loading">
|
||||||
|
<Spin size="large" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import Spin from 'ant-design-vue/lib/spin';
|
||||||
|
import 'ant-design-vue/lib/spin/style/css';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
return {
|
||||||
|
Spin
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.page-loading{
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
</style>
|
BIN
packages/fes-plugin-qiankun/examples/app1/src/images/icon.png
Normal file
BIN
packages/fes-plugin-qiankun/examples/app1/src/images/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
@ -0,0 +1,22 @@
|
|||||||
|
<template>
|
||||||
|
<div class="haizekuo">
|
||||||
|
app1 - index
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<config>
|
||||||
|
{
|
||||||
|
"name": "index",
|
||||||
|
"title": "home"
|
||||||
|
}
|
||||||
|
</config>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
return {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
@ -0,0 +1,22 @@
|
|||||||
|
<template>
|
||||||
|
<div class="haizekuo">
|
||||||
|
app1 - test
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<config>
|
||||||
|
{
|
||||||
|
"name": "index",
|
||||||
|
"title": "home"
|
||||||
|
}
|
||||||
|
</config>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
return {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
37
packages/fes-plugin-qiankun/examples/app1/tsconfig.json
Normal file
37
packages/fes-plugin-qiankun/examples/app1/tsconfig.json
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "build/dist",
|
||||||
|
"module": "esnext",
|
||||||
|
"target": "esnext",
|
||||||
|
"lib": ["esnext", "dom"],
|
||||||
|
"sourceMap": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"jsx": "preserve",
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"suppressImplicitAnyIndexErrors": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"strict": true,
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"],
|
||||||
|
"@@/*": ["./src/.fes/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*",
|
||||||
|
"tests/**/*",
|
||||||
|
"test/**/*",
|
||||||
|
"__test__/**/*",
|
||||||
|
"typings/**/*",
|
||||||
|
"config/**/*",
|
||||||
|
".eslintrc.js",
|
||||||
|
".stylelintrc.js",
|
||||||
|
".prettierrc.js"
|
||||||
|
],
|
||||||
|
"exclude": ["node_modules", "build", "dist", "scripts", "src/.fes/*", "webpack", "jest"]
|
||||||
|
}
|
1
packages/fes-plugin-qiankun/examples/main/.env
Normal file
1
packages/fes-plugin-qiankun/examples/main/.env
Normal file
@ -0,0 +1 @@
|
|||||||
|
PORT=8000
|
14
packages/fes-plugin-qiankun/examples/main/.eslintrc.js
Normal file
14
packages/fes-plugin-qiankun/examples/main/.eslintrc.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
module.exports = {
|
||||||
|
extends: ['@webank/eslint-config-webank/vue.js'],
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: [
|
||||||
|
'**/__tests__/*.{j,t}s?(x)',
|
||||||
|
'**/tests/unit/**/*.spec.{j,t}s?(x)'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
env: {
|
||||||
|
jest: true
|
||||||
|
}
|
||||||
|
};
|
45
packages/fes-plugin-qiankun/examples/main/.fes.js
Normal file
45
packages/fes-plugin-qiankun/examples/main/.fes.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// .fes.js 只负责管理编译时配置,只能使用plain Object
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
access: {
|
||||||
|
roles: {
|
||||||
|
admin: ["*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
layout: {
|
||||||
|
title: "Fes.js",
|
||||||
|
footer: 'Created by MumbelFe',
|
||||||
|
multiTabs: false,
|
||||||
|
navigation: 'mixin',
|
||||||
|
menus: [{
|
||||||
|
name: 'index',
|
||||||
|
icon: 'user'
|
||||||
|
}, {
|
||||||
|
title: "子应用1",
|
||||||
|
icon: 'user',
|
||||||
|
children: [{
|
||||||
|
name: 'app1-index'
|
||||||
|
},{
|
||||||
|
name: 'app1-test'
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
qiankun: {
|
||||||
|
main: {
|
||||||
|
apps: [
|
||||||
|
{
|
||||||
|
name: 'app1', // 唯一 id
|
||||||
|
entry: '//localhost:8001', // html entry
|
||||||
|
props: {} // 传递给子应用的数据
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
require.resolve('../../../fes-plugin-model/lib'),
|
||||||
|
require.resolve('../../../fes-plugin-layout/lib'),
|
||||||
|
require.resolve('../../../fes-plugin-access/lib'),
|
||||||
|
require.resolve('../../../fes-plugin-qiankun/lib'),
|
||||||
|
]
|
||||||
|
};
|
11
packages/fes-plugin-qiankun/examples/main/.gitignore
vendored
Normal file
11
packages/fes-plugin-qiankun/examples/main/.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# fes
|
||||||
|
/src/.fes
|
||||||
|
/src/.fes-production
|
||||||
|
/src/.fes-test
|
||||||
|
/.env.local
|
21
packages/fes-plugin-qiankun/examples/main/LICENSE
Normal file
21
packages/fes-plugin-qiankun/examples/main/LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020-present webank
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
54
packages/fes-plugin-qiankun/examples/main/package.json
Normal file
54
packages/fes-plugin-qiankun/examples/main/package.json
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"name": "main",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"description": "fes项目模版",
|
||||||
|
"scripts": {
|
||||||
|
"build": "fes build",
|
||||||
|
"prod": "FES_ENV=prod fes build",
|
||||||
|
"analyze": "ANALYZE=1 fes build",
|
||||||
|
"dev": "fes dev",
|
||||||
|
"test": "fes test"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"管理端",
|
||||||
|
"fes",
|
||||||
|
"fast",
|
||||||
|
"easy",
|
||||||
|
"strong"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
".eslintrc.js",
|
||||||
|
".gitignore",
|
||||||
|
".fes.js",
|
||||||
|
".fes.prod.js",
|
||||||
|
"mock.js",
|
||||||
|
"package.json",
|
||||||
|
"README.md",
|
||||||
|
"tsconfig.json",
|
||||||
|
"/src",
|
||||||
|
"/config"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/WeBankFinTech/fes.js.git",
|
||||||
|
"directory": "packages/fes-template"
|
||||||
|
},
|
||||||
|
"author": "harrywan",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/WeBankFinTech/fes.js/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/WeBankFinTech/fes.js#readme",
|
||||||
|
"publishConfig": {
|
||||||
|
"access": "public"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@webank/eslint-config-webank": "0.2.10"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fesjs/fes": "^2.0.0-rc.0",
|
||||||
|
"vue": "^3.0.5",
|
||||||
|
"ant-design-vue": "2.0.0"
|
||||||
|
},
|
||||||
|
"private": true
|
||||||
|
}
|
15
packages/fes-plugin-qiankun/examples/main/src/app.js
Normal file
15
packages/fes-plugin-qiankun/examples/main/src/app.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { access as accessApi } from '@fesjs/fes';
|
||||||
|
import PageLoading from '@/components/PageLoading';
|
||||||
|
|
||||||
|
export const beforeRender = {
|
||||||
|
loading: <PageLoading />,
|
||||||
|
action() {
|
||||||
|
const { setRole } = accessApi;
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
setRole('admin');
|
||||||
|
resolve();
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,29 @@
|
|||||||
|
<template>
|
||||||
|
<div class="page-loading">
|
||||||
|
<Spin size="large" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import Spin from 'ant-design-vue/lib/spin';
|
||||||
|
import 'ant-design-vue/lib/spin/style/css';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
return {
|
||||||
|
Spin
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
.page-loading{
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
</style>
|
BIN
packages/fes-plugin-qiankun/examples/main/src/images/icon.png
Normal file
BIN
packages/fes-plugin-qiankun/examples/main/src/images/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
@ -0,0 +1,7 @@
|
|||||||
|
<config>
|
||||||
|
{
|
||||||
|
"name": "app1-index",
|
||||||
|
"title": "子应用1-首页",
|
||||||
|
"microApp": "app1"
|
||||||
|
}
|
||||||
|
</config>
|
@ -0,0 +1,7 @@
|
|||||||
|
<config>
|
||||||
|
{
|
||||||
|
"name": "app1-test",
|
||||||
|
"title": "子应用1-测试",
|
||||||
|
"microApp": "app1"
|
||||||
|
}
|
||||||
|
</config>
|
@ -0,0 +1,11 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
main
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<config>
|
||||||
|
{
|
||||||
|
"name": "index",
|
||||||
|
"title": "首页"
|
||||||
|
}
|
||||||
|
</config>
|
37
packages/fes-plugin-qiankun/examples/main/tsconfig.json
Normal file
37
packages/fes-plugin-qiankun/examples/main/tsconfig.json
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "build/dist",
|
||||||
|
"module": "esnext",
|
||||||
|
"target": "esnext",
|
||||||
|
"lib": ["esnext", "dom"],
|
||||||
|
"sourceMap": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"jsx": "preserve",
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"suppressImplicitAnyIndexErrors": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"strict": true,
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"],
|
||||||
|
"@@/*": ["./src/.fes/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*",
|
||||||
|
"tests/**/*",
|
||||||
|
"test/**/*",
|
||||||
|
"__test__/**/*",
|
||||||
|
"typings/**/*",
|
||||||
|
"config/**/*",
|
||||||
|
".eslintrc.js",
|
||||||
|
".stylelintrc.js",
|
||||||
|
".prettierrc.js"
|
||||||
|
],
|
||||||
|
"exclude": ["node_modules", "build", "dist", "scripts", "src/.fes/*", "webpack", "jest"]
|
||||||
|
}
|
@ -7,7 +7,9 @@
|
|||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"start": "npm-run-all --parallel start:*",
|
||||||
|
"start:master": "cd ./examples/main && fes dev",
|
||||||
|
"start:app1": "cd ./examples/app1 && fes dev"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -32,6 +34,9 @@
|
|||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
"qiankun": "2.3.4"
|
"qiankun": "2.3.4"
|
||||||
},
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"npm-run-all": "^4.1.5"
|
||||||
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@webank/fes": "^2.0.0-rc.0",
|
"@webank/fes": "^2.0.0-rc.0",
|
||||||
"vue": "^3.0.5"
|
"vue": "^3.0.5"
|
||||||
|
@ -2,11 +2,11 @@ import { defaultHistoryType } from '../constants';
|
|||||||
|
|
||||||
function getMicroApp(options) {
|
function getMicroApp(options) {
|
||||||
const {
|
const {
|
||||||
microAppName, masterHistoryType, base, namespace, ...normalizedRouteProps
|
key, microAppName, masterHistoryType, base, namespace, ...normalizedRouteProps
|
||||||
} = options;
|
} = options;
|
||||||
return `(() => {
|
return `(() => {
|
||||||
const { getMicroAppRouteComponent } = require('@@/${namespace}/getMicroAppRouteComponent');
|
const { getMicroAppRouteComponent } = require('@@/${namespace}/getMicroAppRouteComponent');
|
||||||
return getMicroAppRouteComponent({ appName: '${microAppName}', base: '${base}', masterHistoryType: '${masterHistoryType}', routeProps: ${JSON.stringify(normalizedRouteProps)} })
|
return getMicroAppRouteComponent({key: '${key}', appName: '${microAppName}', base: '${base}', masterHistoryType: '${masterHistoryType}', routeProps: ${JSON.stringify(normalizedRouteProps)} })
|
||||||
})()`;
|
})()`;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ function modifyRoutesWithAttachMode({
|
|||||||
_routes.forEach((route) => {
|
_routes.forEach((route) => {
|
||||||
if (route.meta && route.meta.microApp) {
|
if (route.meta && route.meta.microApp) {
|
||||||
route.component = getMicroApp({
|
route.component = getMicroApp({
|
||||||
|
key: route.path,
|
||||||
microAppName: route.meta.microApp,
|
microAppName: route.meta.microApp,
|
||||||
masterHistoryType,
|
masterHistoryType,
|
||||||
base,
|
base,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
defineComponent,
|
defineComponent,
|
||||||
ref,
|
ref,
|
||||||
|
reactive,
|
||||||
watch,
|
watch,
|
||||||
computed,
|
computed,
|
||||||
onBeforeUnmount,
|
onBeforeUnmount,
|
||||||
@ -10,21 +11,17 @@ import { loadMicroApp } from "qiankun";
|
|||||||
import mergeWith from "lodash/mergeWith";
|
import mergeWith from "lodash/mergeWith";
|
||||||
// eslint-disable-next-line import/extensions
|
// eslint-disable-next-line import/extensions
|
||||||
import { getMasterOptions } from "./masterOptions";
|
import { getMasterOptions } from "./masterOptions";
|
||||||
{{#HAS_PLUGIN_MODEL}}
|
|
||||||
import { useModel } from '@@/core/pluginExports';
|
|
||||||
{{/HAS_PLUGIN_MODEL}}
|
|
||||||
import { onBeforeRouteLeave } from "@@/core/coreExports";
|
import { onBeforeRouteLeave } from "@@/core/coreExports";
|
||||||
|
|
||||||
let unmountPromise;
|
let unmountPromise;
|
||||||
async function unmountMicroApp(microApp) {
|
async function unmountMicroApp(microApp) {
|
||||||
if (microApp) {
|
if (microApp) {
|
||||||
if (microApp.mountPromise) {
|
return microApp.mountPromise.then(_microApp => {
|
||||||
await microApp.mountPromise;
|
// Now it is safe to call unmount
|
||||||
}
|
if(_microApp){
|
||||||
if (!unmountPromise) {
|
return _microApp.unmount()
|
||||||
unmountPromise = microApp.unmount();
|
}
|
||||||
}
|
})
|
||||||
return await unmountPromise;
|
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
@ -47,13 +44,7 @@ export const MicroApp = defineComponent({
|
|||||||
...globalSettings
|
...globalSettings
|
||||||
} = getMasterOptions();
|
} = getMasterOptions();
|
||||||
|
|
||||||
{{#HAS_PLUGIN_MODEL}}
|
|
||||||
// 约定使用 src/models/qiankunStateForMicro 中的数据作为主应用透传给微应用的 props,优先级高于 propsFromConfig
|
|
||||||
const stateForSlave = useModel('{{{qiankunStateForMicroModelNamespace}}}');
|
|
||||||
{{/HAS_PLUGIN_MODEL}}
|
|
||||||
{{^HAS_PLUGIN_MODEL}}
|
|
||||||
const stateForSlave = reactive({});
|
const stateForSlave = reactive({});
|
||||||
{{/HAS_PLUGIN_MODEL}}
|
|
||||||
|
|
||||||
// 挂载节点
|
// 挂载节点
|
||||||
const containerRef = ref(null);
|
const containerRef = ref(null);
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
import { MicroApp } from './MicroApp';
|
import { MicroApp } from './MicroApp';
|
||||||
|
|
||||||
export function getMicroAppRouteComponent({
|
export function getMicroAppRouteComponent({
|
||||||
|
key,
|
||||||
appName,
|
appName,
|
||||||
base,
|
base,
|
||||||
masterHistoryType,
|
masterHistoryType,
|
||||||
routeProps
|
routeProps
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
return <MicroApp base={base} masterHistoryType={masterHistoryType} name={appName} {...routeProps} />;
|
return <MicroApp key={key} base={base} masterHistoryType={masterHistoryType} name={appName} {...routeProps} />;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ export default function (api) {
|
|||||||
() => `
|
() => `
|
||||||
export const bootstrap = qiankun_genBootstrap(completeClientRender, app);
|
export const bootstrap = qiankun_genBootstrap(completeClientRender, app);
|
||||||
export const mount = qiankun_genMount('#${api.config.mountElementId}');
|
export const mount = qiankun_genMount('#${api.config.mountElementId}');
|
||||||
export const unmount = qiankun_genUnmount('#${api.config.mountElementId}');
|
export const unmount = qiankun_genUnmount();
|
||||||
export const update = qiankun_genUpdate();
|
export const update = qiankun_genUpdate();
|
||||||
|
|
||||||
if (!window.__POWERED_BY_QIANKUN__) {
|
if (!window.__POWERED_BY_QIANKUN__) {
|
||||||
|
@ -46,7 +46,7 @@ export function genBootstrap(oldRender, appPromise) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 子应用生命周期钩子Mount
|
// 子应用生命周期钩子Mount
|
||||||
export function genMount() {
|
export function genMount(mountElementId) {
|
||||||
return async (props) => {
|
return async (props) => {
|
||||||
// props 有值时说明应用是通过 lifecycle 被主应用唤醒的,而不是独立运行时自己 mount
|
// props 有值时说明应用是通过 lifecycle 被主应用唤醒的,而不是独立运行时自己 mount
|
||||||
if (typeof props !== 'undefined') {
|
if (typeof props !== 'undefined') {
|
||||||
@ -85,17 +85,11 @@ export function genUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 子应用生命周期钩子Unmount
|
// 子应用生命周期钩子Unmount
|
||||||
export function genUnmount(mountElementId) {
|
export function genUnmount() {
|
||||||
return async (props) => {
|
return async (props) => {
|
||||||
let container;
|
if (cacheAppPromise) {
|
||||||
try {
|
|
||||||
container = props?.container
|
|
||||||
? props.container.querySelector(mountElementId)
|
|
||||||
: document.querySelector(mountElementId);
|
|
||||||
} catch (e) {}
|
|
||||||
if (container && cacheAppPromise) {
|
|
||||||
const app = await cacheAppPromise;
|
const app = await cacheAppPromise;
|
||||||
app.unmount(container);
|
app.unmount();
|
||||||
}
|
}
|
||||||
const slaveRuntime = getSlaveRuntime();
|
const slaveRuntime = getSlaveRuntime();
|
||||||
if (slaveRuntime.unmount) {
|
if (slaveRuntime.unmount) {
|
||||||
|
@ -95,8 +95,5 @@ const completeClientRender = async () => {
|
|||||||
|
|
||||||
const app = completeClientRender();
|
const app = completeClientRender();
|
||||||
|
|
||||||
export default app;
|
|
||||||
|
|
||||||
|
|
||||||
{{{ entryCode }}}
|
{{{ entryCode }}}
|
||||||
|
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
base: '',
|
// base: '',
|
||||||
|
qiankun: {
|
||||||
|
micro: {}
|
||||||
|
},
|
||||||
define: {
|
define: {
|
||||||
__DEV__: false
|
__DEV__: false
|
||||||
},
|
},
|
||||||
|
@ -55,11 +55,10 @@
|
|||||||
"@fesjs/plugin-jest": "^2.0.0-rc.0",
|
"@fesjs/plugin-jest": "^2.0.0-rc.0",
|
||||||
"@fesjs/plugin-vuex": "^2.0.0-rc.0",
|
"@fesjs/plugin-vuex": "^2.0.0-rc.0",
|
||||||
"@fesjs/plugin-request": "^2.0.0-rc.0",
|
"@fesjs/plugin-request": "^2.0.0-rc.0",
|
||||||
"@fesjs/plugin-qiankun": "^2.0.0-alpha.0",
|
"@fesjs/plugin-qiankun": "^2.0.0-rc.0",
|
||||||
"ant-design-vue": "2.0.0",
|
"ant-design-vue": "2.0.0",
|
||||||
"vue": "^3.0.5",
|
"vue": "^3.0.5",
|
||||||
"vuex": "^4.0.0"
|
"vuex": "^4.0.0"
|
||||||
},
|
},
|
||||||
"private": true
|
"private": true
|
||||||
}
|
}
|
||||||
|
|
41
yarn.lock
41
yarn.lock
@ -6650,7 +6650,7 @@ cross-spawn@^5.0.1:
|
|||||||
shebang-command "^1.2.0"
|
shebang-command "^1.2.0"
|
||||||
which "^1.2.9"
|
which "^1.2.9"
|
||||||
|
|
||||||
cross-spawn@^6.0.0:
|
cross-spawn@^6.0.0, cross-spawn@^6.0.5:
|
||||||
version "6.0.5"
|
version "6.0.5"
|
||||||
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
|
resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
|
||||||
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
|
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
|
||||||
@ -11610,6 +11610,11 @@ memory-fs@^0.5.0:
|
|||||||
errno "^0.1.3"
|
errno "^0.1.3"
|
||||||
readable-stream "^2.0.1"
|
readable-stream "^2.0.1"
|
||||||
|
|
||||||
|
memorystream@^0.3.1:
|
||||||
|
version "0.3.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2"
|
||||||
|
integrity sha1-htcJCzDORV1j+64S3aUaR93K+bI=
|
||||||
|
|
||||||
meow@^3.3.0:
|
meow@^3.3.0:
|
||||||
version "3.7.0"
|
version "3.7.0"
|
||||||
resolved "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb"
|
resolved "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb"
|
||||||
@ -12277,6 +12282,21 @@ npm-pick-manifest@^3.0.0:
|
|||||||
npm-package-arg "^6.0.0"
|
npm-package-arg "^6.0.0"
|
||||||
semver "^5.4.1"
|
semver "^5.4.1"
|
||||||
|
|
||||||
|
npm-run-all@^4.1.5:
|
||||||
|
version "4.1.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.5.tgz#04476202a15ee0e2e214080861bff12a51d98fba"
|
||||||
|
integrity sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==
|
||||||
|
dependencies:
|
||||||
|
ansi-styles "^3.2.1"
|
||||||
|
chalk "^2.4.1"
|
||||||
|
cross-spawn "^6.0.5"
|
||||||
|
memorystream "^0.3.1"
|
||||||
|
minimatch "^3.0.4"
|
||||||
|
pidtree "^0.3.0"
|
||||||
|
read-pkg "^3.0.0"
|
||||||
|
shell-quote "^1.6.1"
|
||||||
|
string.prototype.padend "^3.0.0"
|
||||||
|
|
||||||
npm-run-path@^2.0.0:
|
npm-run-path@^2.0.0:
|
||||||
version "2.0.2"
|
version "2.0.2"
|
||||||
resolved "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"
|
resolved "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"
|
||||||
@ -12944,6 +12964,11 @@ picomatch@^2.0.4, picomatch@^2.0.5, picomatch@^2.2.1, picomatch@^2.2.2:
|
|||||||
resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
|
resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad"
|
||||||
integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==
|
integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==
|
||||||
|
|
||||||
|
pidtree@^0.3.0:
|
||||||
|
version "0.3.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/pidtree/-/pidtree-0.3.1.tgz#ef09ac2cc0533df1f3250ccf2c4d366b0d12114a"
|
||||||
|
integrity sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==
|
||||||
|
|
||||||
pify@^2.0.0, pify@^2.3.0:
|
pify@^2.0.0, pify@^2.3.0:
|
||||||
version "2.3.0"
|
version "2.3.0"
|
||||||
resolved "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
|
resolved "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
|
||||||
@ -14777,6 +14802,11 @@ shebang-regex@^3.0.0:
|
|||||||
resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
|
resolved "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
|
||||||
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
|
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
|
||||||
|
|
||||||
|
shell-quote@^1.6.1:
|
||||||
|
version "1.7.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2"
|
||||||
|
integrity sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==
|
||||||
|
|
||||||
shellwords@^0.1.1:
|
shellwords@^0.1.1:
|
||||||
version "0.1.1"
|
version "0.1.1"
|
||||||
resolved "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
|
resolved "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
|
||||||
@ -15229,6 +15259,15 @@ string-width@^4.1.0, string-width@^4.2.0:
|
|||||||
is-fullwidth-code-point "^3.0.0"
|
is-fullwidth-code-point "^3.0.0"
|
||||||
strip-ansi "^6.0.0"
|
strip-ansi "^6.0.0"
|
||||||
|
|
||||||
|
string.prototype.padend@^3.0.0:
|
||||||
|
version "3.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.1.2.tgz#6858ca4f35c5268ebd5e8615e1327d55f59ee311"
|
||||||
|
integrity sha512-/AQFLdYvePENU3W5rgurfWSMU6n+Ww8n/3cUt7E+vPBB/D7YDG8x+qjoFs4M/alR2bW7Qg6xMjVwWUOvuQ0XpQ==
|
||||||
|
dependencies:
|
||||||
|
call-bind "^1.0.2"
|
||||||
|
define-properties "^1.1.3"
|
||||||
|
es-abstract "^1.18.0-next.2"
|
||||||
|
|
||||||
string.prototype.trimend@^1.0.4:
|
string.prototype.trimend@^1.0.4:
|
||||||
version "1.0.4"
|
version "1.0.4"
|
||||||
resolved "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz#e75ae90c2942c63504686c18b287b4a0b1a45f80"
|
resolved "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz#e75ae90c2942c63504686c18b287b4a0b1a45f80"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user