diff --git a/packages/vue/src/context/imports.ts b/packages/vue/src/context/imports.ts index d06df64..9c0a04b 100644 --- a/packages/vue/src/context/imports.ts +++ b/packages/vue/src/context/imports.ts @@ -3,15 +3,12 @@ import { writeFile } from 'node:fs/promises'; import type { ElegantRouterFile } from '@elegant-router/core'; import type { ElegantVueRouterOption, LayoutFile } from '../types'; import { ensureFile } from '../shared/fs'; +import { createPrefixCommentOfGenFile } from './comment'; function getImportsCode(files: ElegantRouterFile[], options: ElegantVueRouterOption) { const layoutFiles = getLayoutFile(options); - const preCode = `/* eslint-disable */ -/* prettier-ignore */ -// Generated by elegant-router -// Read more: https://github.com/soybeanjs/elegant-router -`; + const preCode = createPrefixCommentOfGenFile(); let importCode = `import type { RouteComponent } from "vue-router"; import type { LastLevelRouteKey, RouteLayout } from "@elegant-router/types"; @@ -56,7 +53,7 @@ import type { LastLevelRouteKey, RouteLayout } from "@elegant-router/types"; exportCode += '\n};\n'; - return `${preCode}\n${importCode}${exportLayoutCode}\n${exportCode}`; + return `${preCode}\n\n${importCode}${exportLayoutCode}\n${exportCode}`; } function getImportKey(name: string) { diff --git a/packages/vue/src/context/options.ts b/packages/vue/src/context/options.ts index 539acca..71c2f90 100644 --- a/packages/vue/src/context/options.ts +++ b/packages/vue/src/context/options.ts @@ -14,7 +14,7 @@ export function createPluginOptions(erOptions: ElegantRouterOption, options?: Pa 'not-found': '/:pathMatch(.*)*' }; const DEFAULT_LAYOUTS: Record = { - default: 'src/layouts/default-layout/index.vue' + base: 'src/layouts/base-layout/index.vue' }; const opts: ElegantVueRouterOption = { @@ -34,5 +34,7 @@ export function createPluginOptions(erOptions: ElegantRouterOption, options?: Pa ...options }; + opts.defaultLayout = Object.keys(opts.layouts)[0]; + return opts; } diff --git a/packages/vue/src/types/index.ts b/packages/vue/src/types/index.ts index b43d2de..f0b5ac4 100644 --- a/packages/vue/src/types/index.ts +++ b/packages/vue/src/types/index.ts @@ -49,7 +49,7 @@ export interface ElegantVueRouterOption extends ElegantRouterOption { * @default * ```ts * const layouts: Record = { - * default: 'src/layouts/default-layout/index.vue' + * base: 'src/layouts/base-layout/index.vue' * } * ``` */