初始提交

This commit is contained in:
lyswhut
2019-08-16 17:27:23 +08:00
parent 4dc34a48f4
commit 14f7bd10a3
112 changed files with 24294 additions and 2 deletions
+56
View File
@@ -0,0 +1,56 @@
import Vue from 'vue'
import Router from 'vue-router'
import paths from './paths'
function route(path, view, name, meta) {
return {
name: name || view,
path,
meta,
component: (resovle) => import(
`../views/${view}.vue`
).then(resovle),
}
}
Vue.use(Router)
const router = new Router({
mode: 'hash',
routes: paths.map(path => route(path.path, path.view, path.name, path.meta)).concat([
{ path: '*', redirect: '/search' },
]),
linkActiveClass: 'active-link',
linkExactActiveClass: 'exact-active-link',
scrollBehavior(to, from, savedPosition) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (savedPosition) {
resolve(savedPosition)
} else {
const position = {}
// new navigation.
// scroll to anchor by returning the selector
if (to.hash) {
position.selector = to.hash
}
// check if any matched route config has meta that requires scrolling to top
if (to.matched.some(m => m.meta.scrollToTop)) {
// cords will be used if no selector is provided,
// or if the selector didn't match any element.
position.x = 0
position.y = 0
}
// if the returned position is falsy or an empty object,
// will retain current scroll position.
resolve(position)
}
}, 500)
})
},
})
export default router
+40
View File
@@ -0,0 +1,40 @@
export default [
// {
// path: '/',
// // redirect: '/app',
// // props: true,
// component: () => import('../views/Dashboard.vue'),
// name: 'Dashboard',
// alias: '/dashboard'
// }
{
path: '/search',
name: 'search',
view: 'Search',
},
{
path: '/leaderboard',
name: 'leaderboard',
view: 'Leaderboard',
},
{
path: '/recommend',
name: 'recommend',
view: 'Recommend',
},
{
path: '/list',
name: 'list',
view: 'List',
},
{
path: '/download',
name: 'download',
view: 'Download',
},
{
path: '/setting',
name: 'setting',
view: 'Setting',
},
]