Skip to content

Commit b603027

Browse files
committed
Merge branch 'bug-fix'
2 parents 7c17928 + af48850 commit b603027

28 files changed

+4444
-139
lines changed

lerna.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,8 @@
77
"conventionalCommits": false,
88
"gitTagVersion": false,
99
"gitReset": false,
10-
"allowBranch": ["master"],
11-
"ignoreChanges": [
12-
"**/CHANGELOG.md",
13-
"**/node_modules/**",
14-
"**/package.json",
15-
"**/*.md",
16-
"**/test/**"
17-
],
10+
"allowBranch": ["master", "bug-fix"],
11+
"ignoreChanges": ["**/CHANGELOG.md", "**/node_modules/**", "**/package.json", "**/*.md", "**/test/**"],
1812
"message": "chore(release): publish"
1913
}
2014
},

package.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "vue-async",
3-
"version": "0.1.0",
3+
"version": "1.0.2",
44
"description": "Vue Async",
55
"private": true,
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/aceHubert/vue-async.git"
99
},
1010
"scripts": {
11-
"serve": "lerna run serve --sort --parallel",
11+
"build:es": "lerna run build:es --sort --parallel",
1212
"build": "lerna run build --sort --stream --scope=@vue-async/{module-loader,resource-manager,utils}",
1313
"clean": "lerna clean --yes",
1414
"lint": "lerna run lint --parallel --stream",
@@ -31,6 +31,13 @@
3131
"@babel/preset-env": "^7.7.4",
3232
"@commitlint/cli": "^8.3.4",
3333
"@commitlint/config-conventional": "^8.3.4",
34+
"@rollup/plugin-alias": "^3.1.1",
35+
"@rollup/plugin-babel": "^5.0.0",
36+
"@rollup/plugin-commonjs": "^11.1.0",
37+
"@rollup/plugin-json": "^4.0.2",
38+
"@rollup/plugin-multi-entry": "^3.0.0",
39+
"@rollup/plugin-node-resolve": "^7.1.3",
40+
"@rollup/plugin-replace": "^2.3.1",
3441
"@types/jest": "^24.0.23",
3542
"@types/node": "^12.12.14",
3643
"@typescript-eslint/eslint-plugin": "^2.12.0",
@@ -55,6 +62,13 @@
5562
"lerna-changelog": "^1.0.1",
5663
"lint-staged": "^10.2.0",
5764
"prettier": "^2.0.5",
65+
"rollup": "^1.27.2",
66+
"rollup-plugin-clear": "^2.0.7",
67+
"rollup-plugin-dts": "^1.4.2",
68+
"rollup-plugin-license": "^2.0.0",
69+
"rollup-plugin-serve": "^1.0.1",
70+
"rollup-plugin-terser": "^5.1.2",
71+
"rollup-plugin-typescript2": "^0.27.0",
5872
"ts-jest": "^24.2.0",
5973
"typescript": "^3.7.2",
6074
"util": "^0.12.1",

packages/module-loader/dev/App.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// app
2+
3+
export default Vue.extend({
4+
name: 'App',
5+
render(h) {
6+
return h('div', { domProps: { id: 'app' } }, [
7+
h('router-link', { staticStyle: { margin: '0 10px; 5px' }, props: { to: { name: 'remote-page-a' } } }, 'Page A'),
8+
h('router-view'),
9+
]);
10+
},
11+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default Vue.extend({
2+
name: 'Playground',
3+
computed: Vuex.mapState('dynamicComponent', { dynamicComponents: 'dashboard' }),
4+
render(h) {
5+
const children = Object.values(this.dynamicComponents || {}).map((component) =>
6+
h(component.component || component),
7+
);
8+
return h('div', { staticClass: 'playground' }, [h('h3', 'Dashboard'), ...children]);
9+
},
10+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="zh-CN">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
8+
<title>Dev Serve</title>
9+
</head>
10+
11+
<body>
12+
<noscript>
13+
<strong>We're sorry but this site doesn't work properly without JavaScript enabled.
14+
Please enable it to continue.</strong>
15+
</noscript>
16+
<div id="app"></div>
17+
<!-- built files will be auto injected -->
18+
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.js"></script>
19+
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue-router/3.1.3/vue-router.min.js"></script>
20+
<script src="https://cdnjs.cloudflare.com/ajax/libs/vuex/3.1.3/vuex.min.js"></script>
21+
<script src="/static/utils.min.js"></script>
22+
<script src="/index.js"></script>
23+
</body>
24+
25+
</html>

packages/module-loader/dev/main.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Vue from 'vue';
2+
import router, { addRoutes } from './router';
3+
import store from './store';
4+
import ModuleLoader from '@vue-async/module-loader';
5+
import App from './app';
6+
7+
const moduleLoader = new ModuleLoader({
8+
addRoutes, // 重写 addRoutes
9+
});
10+
11+
const vm = new Vue({
12+
router,
13+
store,
14+
moduleLoader,
15+
render: (h) => h(App),
16+
});
17+
18+
vm.$moduleLoader({
19+
dymanicRouter: '/static/dymanicRouter.umd.js',
20+
dymanicComponent: '/static/dymanicComponent.umd.js',
21+
}).then(() => {
22+
vm.$mount('#app');
23+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* router
3+
*/
4+
import Dashboard from './Dashboard';
5+
const Notfound = {
6+
template: `<h3>Not Found</h3>`,
7+
};
8+
9+
const router = new VueRouter({
10+
base: '/',
11+
mode: 'history',
12+
routes: [
13+
{
14+
path: '/',
15+
name: 'index',
16+
component: Dashboard,
17+
},
18+
{ path: '*', component: Notfound },
19+
],
20+
});
21+
22+
// 模块中路由配置没有根前缀,用于主程序自定义
23+
function root(routes) {
24+
return routes.map((route) => {
25+
route.path = '/' + route.path;
26+
return route;
27+
});
28+
}
29+
30+
export function addRoutes(routes) {
31+
const options = router.options;
32+
// 合并路由
33+
options.routes = root(routes).concat(options.routes);
34+
const newRouter = new VueRouter(options);
35+
router.matcher = newRouter.matcher;
36+
}
37+
38+
export default router;

0 commit comments

Comments
 (0)