Skip to content

Commit 613ea7f

Browse files
committed
chore: simplify code
1 parent 05cb65a commit 613ea7f

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

Diff for: lib/app/util.js

-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ export function injectMixins (options, mixins) {
55
options.mixins.push(...mixins)
66
}
77

8-
export function pathToComponentName (pages, path) {
9-
const page = findPageForPath(pages, path)
10-
return page && page.key
11-
}
12-
138
export function findPageForPath (pages, path) {
149
for (let i = 0; i < pages.length; i++) {
1510
const page = pages[i]

Diff for: lib/default-theme/Layout.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import Home from './Home.vue'
2727
import Navbar from './Navbar.vue'
2828
import Page from './Page.vue'
2929
import Sidebar from './Sidebar.vue'
30-
import { pathToComponentName } from '@app/util'
3130
import store from '@app/store'
3231
import { resolveSidebarItems } from './util'
3332
import throttle from 'lodash.throttle'
@@ -94,7 +93,7 @@ export default {
9493
nprogress.configure({ showSpinner: false })
9594
9695
this.$router.beforeEach((to, from, next) => {
97-
if (to.path !== from.path && !Vue.component(pathToComponentName(this.$site.pages, to.path))) {
96+
if (to.path !== from.path && !Vue.component(to.name)) {
9897
nprogress.start()
9998
}
10099
next()

Diff for: lib/prepare.js

+1
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ async function genRoutesFile ({ siteData: { pages }, sourceDir, pageFiles }) {
318318
const filePath = path.resolve(sourceDir, file)
319319
let code = `
320320
{
321+
name: ${JSON.stringify(componentName)},
321322
path: ${JSON.stringify(pagePath)},
322323
component: ThemeLayout,
323324
beforeEnter: (to, from, next) => {

0 commit comments

Comments
 (0)