mirror of https://github.com/ElemeFE/element
update route
parent
e320f43c2d
commit
287868d165
|
@ -10,6 +10,8 @@ var ISNTALL_COMPONENT_TEMPLATE = ` Vue.component({{name}}.name, {{name}});`
|
||||||
var MAIN_TEMPLATE = `{{include}}
|
var MAIN_TEMPLATE = `{{include}}
|
||||||
|
|
||||||
const install = function(Vue) {
|
const install = function(Vue) {
|
||||||
|
if (install.installed) return;
|
||||||
|
|
||||||
{{install}}
|
{{install}}
|
||||||
|
|
||||||
Vue.use(Loading);
|
Vue.use(Loading);
|
||||||
|
|
|
@ -263,52 +263,54 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="pure-g">
|
<div id="app">
|
||||||
<div class="pure-u-1-6 app__sidebar pure-menu pure-menu-scrollable app__menu">
|
<div class="pure-g">
|
||||||
<a class="pure-menu-heading app__brand" v-link="'/'">
|
<div class="pure-u-1-6 app__sidebar pure-menu pure-menu-scrollable app__menu">
|
||||||
<span class="app__eleme">ELEME</span>NT
|
<router-link class="pure-menu-heading app__brand" to="/">
|
||||||
</a>
|
<span class="app__eleme">ELEME</span>NT
|
||||||
|
</router-link>
|
||||||
|
|
||||||
<template v-for="nav in navs">
|
<template v-for="(nav, key) in navs">
|
||||||
<a
|
<a
|
||||||
href="#"
|
href="#"
|
||||||
@click.prevent="navState.$set($index, !navState[$index] || false)"
|
@click.prevent="navState.$set(key, !navState[key] || false)"
|
||||||
class="pure-menu-heading app__menu__label"
|
class="pure-menu-heading app__menu__label"
|
||||||
:class="{ 'unfold': !navState[$index] }"
|
:class="{ 'unfold': !navState[key] }"
|
||||||
v-text="nav.group"></a>
|
v-text="nav.group"></a>
|
||||||
<ul
|
<ul
|
||||||
class="pure-menu-list"
|
class="pure-menu-list"
|
||||||
transition="slidedown"
|
transition="slidedown"
|
||||||
v-show="!navState[$index]"
|
v-show="!navState[key]"
|
||||||
:style="{
|
:style="{
|
||||||
maxHeight: nav.list.length * 44 + 'px'
|
maxHeight: nav.list.length * 44 + 'px'
|
||||||
}">
|
}">
|
||||||
<li
|
<li
|
||||||
class="pure-menu-item app__menu__item"
|
class="pure-menu-item app__menu__item"
|
||||||
v-for="item in nav.list"
|
v-for="item in nav.list"
|
||||||
v-if="!item.disabled">
|
v-if="!item.disabled">
|
||||||
<a
|
<router-link
|
||||||
class="pure-menu-link app__menu__link"
|
class="pure-menu-link app__menu__link"
|
||||||
v-link="{ path: item.path, activeClass: 'active' }"
|
:to="{ path: item.path, activeClass: 'active' }"
|
||||||
v-text="item.name"></a>
|
v-text="item.name"></router-link>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="pure-u-5-6 app__content">
|
||||||
|
<header class="app__header">
|
||||||
|
<h1 class="app__headline">{{ $route.title || 'element 后台组件' }}</h1>
|
||||||
|
</header>
|
||||||
|
<section class="app__main" ref="main">
|
||||||
|
<p class="app__description">{{ $route.description }}</p>
|
||||||
|
<router-view></router-view>
|
||||||
|
</section>
|
||||||
|
<toc main=".app__main"></toc>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-5-6 app__content">
|
|
||||||
<header class="app__header">
|
<button class="hljs__button" ref="button"></button>
|
||||||
<h1 class="app__headline">{{ $route.title || 'element 后台组件' }}</h1>
|
|
||||||
</header>
|
|
||||||
<section class="app__main" v-el:main>
|
|
||||||
<p class="app__description">{{ $route.description }}</p>
|
|
||||||
<router-view></router-view>
|
|
||||||
</section>
|
|
||||||
<toc main=".app__main"></toc>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="hljs__button" v-el:button></button>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -341,10 +343,10 @@
|
||||||
this.navs = navs;
|
this.navs = navs;
|
||||||
},
|
},
|
||||||
|
|
||||||
ready() {
|
mounted() {
|
||||||
this.mainContent = document.querySelector('.app__content');
|
this.mainContent = document.querySelector('.app__content');
|
||||||
|
|
||||||
E.delegate(this.$els.main, '.hljs__button', 'click.highlight', e => {
|
E.delegate(this.$refs.main, '.hljs__button', 'click.highlight', e => {
|
||||||
const parent = e.target.parentNode;
|
const parent = e.target.parentNode;
|
||||||
|
|
||||||
toggleClass(parent, 'open');
|
toggleClass(parent, 'open');
|
||||||
|
@ -352,7 +354,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
E.undelegate(this.$els.main, '.hljs', 'click.highlight');
|
E.undelegate(this.$refs.main, '.hljs', 'click.highlight');
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
@ -34,20 +34,20 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
switch: true
|
value: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
effect() {
|
effect() {
|
||||||
return this.switch ? 'dark' : 'light';
|
return this.value ? 'dark' : 'light';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<el-switch
|
<el-switch
|
||||||
:value.sync="switch"
|
v-model="value"
|
||||||
on-text="黑色"
|
on-text="黑色"
|
||||||
off-text="白色"
|
off-text="白色"
|
||||||
on-color="#1f2d3d"
|
on-color="#1f2d3d"
|
||||||
|
|
|
@ -5,22 +5,15 @@ import configRouter from './route.config';
|
||||||
import Element from 'main/index.js';
|
import Element from 'main/index.js';
|
||||||
import 'packages/theme-default/src/index.css';
|
import 'packages/theme-default/src/index.css';
|
||||||
|
|
||||||
// test Released package
|
|
||||||
// import Element from '../lib/index.js';
|
|
||||||
// import '../lib/theme-default/index.css';
|
|
||||||
|
|
||||||
Vue.use(Element);
|
Vue.use(Element);
|
||||||
Vue.use(VueRouter);
|
Vue.use(VueRouter);
|
||||||
|
|
||||||
const router = new VueRouter();
|
const router = new VueRouter({
|
||||||
const app = Vue.extend({
|
base: __dirname,
|
||||||
template: '<entry></entry>',
|
routes: configRouter
|
||||||
components: { entry }
|
|
||||||
});
|
});
|
||||||
|
|
||||||
configRouter(router);
|
new Vue({ // eslint-disable-line
|
||||||
router.start(app, 'app');
|
render: h => h(entry),
|
||||||
|
router
|
||||||
router.afterEach(() => {
|
}).$mount('#app');
|
||||||
document.body.scrollTop = 0;
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
<title>test-vue2</title>
|
||||||
<title>Element 后台组件</title>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<app></app>
|
<div id="app"></div>
|
||||||
<!-- built files will be auto injected -->
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,40 +1,36 @@
|
||||||
import navConfig from './nav.config.json';
|
import navConfig from './nav.config.json';
|
||||||
|
|
||||||
const registerRoute = (config) => {
|
const registerRoute = (config) => {
|
||||||
let route = {};
|
let route = [];
|
||||||
config.map(nav => nav.list.map(page => {
|
config
|
||||||
try {
|
.map(nav =>
|
||||||
route[page.path] = page.path !== '/changelog' ? {
|
nav.list.map(page => {
|
||||||
component: require(`./docs${page.path}.md`),
|
if (page.path === '/changelog') return;
|
||||||
title: page.title || page.name,
|
const component = require(`./docs${page.path}.md`);
|
||||||
description: page.description
|
|
||||||
} : {
|
route.push({
|
||||||
component: require('../CHANGELOG.md'),
|
path: page.path,
|
||||||
title: page.title || page.name,
|
title: page.title || page.name,
|
||||||
description: page.description
|
description: page.description,
|
||||||
};
|
component: component.default || component
|
||||||
} catch (e) {
|
});
|
||||||
console.error(e);
|
})
|
||||||
page.disabled = true;
|
);
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
return { route, navs: config };
|
return { route, navs: config };
|
||||||
};
|
};
|
||||||
|
|
||||||
const route = registerRoute(navConfig);
|
const route = registerRoute(navConfig);
|
||||||
|
|
||||||
export const navs = route.navs;
|
route.route.push({
|
||||||
export default function configRouter(router) {
|
path: '/changelog',
|
||||||
router.map(Object.assign({
|
component: require('../CHANGELOG.md')
|
||||||
'*': {
|
});
|
||||||
component: require('./docs/home.md')
|
|
||||||
}
|
|
||||||
}, route.route));
|
|
||||||
|
|
||||||
router.beforeEach(transition => {
|
route.route.push({
|
||||||
document.title = transition.to.title || document.title;
|
path: '*',
|
||||||
transition.to.router.app.$broadcast('element.example.reload');
|
component: require('./docs/home.md')
|
||||||
transition.next();
|
});
|
||||||
});
|
|
||||||
};
|
export const navs = route.navs;
|
||||||
|
export default route.route;
|
||||||
|
|
|
@ -41,10 +41,10 @@
|
||||||
"purecss": "^0.6.0",
|
"purecss": "^0.6.0",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"uppercamelcase": "^1.1.0",
|
"uppercamelcase": "^1.1.0",
|
||||||
"vue": "^1.0.26",
|
"vue": "^2.0.0-beta.5",
|
||||||
"vue-loader": "^8.5.3",
|
"vue-loader": "^9.2.0",
|
||||||
"vue-markdown-loader": "^0.4.0",
|
"vue-markdown-loader": "^0.4.0",
|
||||||
"vue-popup": "^0.1.8",
|
"vue-popup": "^0.1.8",
|
||||||
"vue-router": "^0.7.13"
|
"vue-router": "^2.0.0-beta.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
}
|
}
|
||||||
]"
|
]"
|
||||||
>
|
>
|
||||||
<i class="el-icon-loading" v-if="loading"></i><i :class="'el-icon-' + icon" v-if="icon && !loading"></i><span v-if="_slotContents && _slotContents.default">
|
<i class="el-icon-loading" v-if="loading"></i>
|
||||||
<slot></slot>
|
<i :class="'el-icon-' + icon" v-if="icon && !loading"></i>
|
||||||
</span>
|
<slot></slot>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -84,6 +84,6 @@ Object.keys(Components).forEach(function (key) {
|
||||||
// 开发模式不需要将不存在的 style.css 打包进去
|
// 开发模式不需要将不存在的 style.css 打包进去
|
||||||
cooking.add('externals', externals);
|
cooking.add('externals', externals);
|
||||||
|
|
||||||
cooking.config.vue.loaders.html = 'html?minimize=true&conservativeCollapse=false';
|
// cooking.config.vue.loaders.html = 'html?minimize=true&conservativeCollapse=false';
|
||||||
|
|
||||||
module.exports = cooking.resolve();
|
module.exports = cooking.resolve();
|
||||||
|
|
Loading…
Reference in New Issue