mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
docs:更新文档
This commit is contained in:
10
node_modules/vitepress/dist/client/shared/config.d.ts
generated
vendored
Normal file
10
node_modules/vitepress/dist/client/shared/config.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { SiteData } from '/@types/shared';
|
||||
export declare function resolveSiteDataByRoute(siteData: SiteData, route: string): {
|
||||
themeConfig: any;
|
||||
locales: {};
|
||||
lang: string;
|
||||
title: string;
|
||||
description: string;
|
||||
base: string;
|
||||
head: import("../../../types/shared").HeadConfig[];
|
||||
};
|
||||
50
node_modules/vitepress/dist/client/shared/config.js
generated
vendored
Normal file
50
node_modules/vitepress/dist/client/shared/config.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
const inBrowser = typeof window !== 'undefined';
|
||||
function findMatchRoot(route, roots) {
|
||||
// first match to the routes with the most deep level.
|
||||
roots.sort((a, b) => {
|
||||
const levelDelta = b.split('/').length - a.split('/').length;
|
||||
if (levelDelta !== 0) {
|
||||
return levelDelta;
|
||||
}
|
||||
else {
|
||||
return b.length - a.length;
|
||||
}
|
||||
});
|
||||
for (const r of roots) {
|
||||
if (route.startsWith(r))
|
||||
return r;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function resolveLocales(locales, route) {
|
||||
const localeRoot = findMatchRoot(route, Object.keys(locales));
|
||||
return localeRoot ? locales[localeRoot] : undefined;
|
||||
}
|
||||
// this merges the locales data to the main data by the route
|
||||
export function resolveSiteDataByRoute(siteData, route) {
|
||||
route = cleanRoute(siteData, route);
|
||||
const localeData = resolveLocales(siteData.locales || {}, route) || {};
|
||||
const localeThemeConfig = resolveLocales((siteData.themeConfig && siteData.themeConfig.locales) || {}, route) || {};
|
||||
return {
|
||||
...siteData,
|
||||
...localeData,
|
||||
themeConfig: {
|
||||
...siteData.themeConfig,
|
||||
...localeThemeConfig,
|
||||
// clean the locales to reduce the bundle size
|
||||
locales: {}
|
||||
},
|
||||
locales: {}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Clean up the route by removing the `base` path if it's set in config.
|
||||
*/
|
||||
function cleanRoute(siteData, route) {
|
||||
if (!inBrowser) {
|
||||
return route;
|
||||
}
|
||||
const base = siteData.base;
|
||||
const baseWithoutSuffix = base.endsWith('/') ? base.slice(0, -1) : base;
|
||||
return route.slice(baseWithoutSuffix.length);
|
||||
}
|
||||
Reference in New Issue
Block a user