修复路由
This commit is contained in:
@@ -16,7 +16,6 @@ a, .green {
|
|||||||
|
|
||||||
.flex {
|
.flex {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.fill {
|
.fill {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router'
|
||||||
|
|
||||||
import './assets/main.css'
|
import './assets/main.css'
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
|
|||||||
@@ -3,21 +3,15 @@ import VueRouter from 'vue-router'
|
|||||||
|
|
||||||
Vue.use(VueRouter)
|
Vue.use(VueRouter)
|
||||||
const ctx = import.meta.glob('../views/App*.vue', {eager: true})
|
const ctx = import.meta.glob('../views/App*.vue', {eager: true})
|
||||||
const router = new VueRouter({
|
const routes = [{path: '/', name: 'home'}]
|
||||||
mode: 'history', routes: [{
|
Object.values(ctx).map(file => {
|
||||||
path: '/', name: 'home',
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
const routes = []
|
|
||||||
console.log(ctx)
|
|
||||||
await Promise.all(Object.values(ctx).map(file => {
|
|
||||||
if (file.default) {
|
if (file.default) {
|
||||||
let {name, label = name, path = name} = file.default
|
let {name, label = name, path = `/apps/${name}`} = file.default
|
||||||
routes.push({name, path, label})
|
routes.push({name, path, label, component: file.default})
|
||||||
return router.addRoute("home", {path, name, component: () => file.default})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})).then(() => {
|
|
||||||
localStorage.setItem('routes', JSON.stringify(routes))
|
|
||||||
})
|
})
|
||||||
export default router
|
localStorage.setItem('routes', JSON.stringify(routes.slice(1).map(v => ({name: v.name, label: v.label, path: v.path}))))
|
||||||
|
|
||||||
|
export default new VueRouter({
|
||||||
|
mode: 'history', routes
|
||||||
|
})
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="AppSpanTable"></section>
|
<section class="AppSpanTable">
|
||||||
|
ASDASD
|
||||||
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.AppSpanTable {
|
.AppSpanTable {
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user