only generate type data once
This commit is contained in:
parent
8fb1408bb4
commit
e0a2fb0256
6 changed files with 21 additions and 11 deletions
|
@ -30,7 +30,7 @@ async function readSubdir(subdir: string): Promise<dirData[]> {
|
|||
return data;
|
||||
}
|
||||
|
||||
export async function generateTypeData(): Promise<RouteData[]> {
|
||||
async function generateTypeData(): Promise<RouteData[]> {
|
||||
const mainDir = import.meta.env.SECRET_MODULES_PATH;
|
||||
|
||||
if (!mainDir || mainDir == "") {
|
||||
|
@ -56,3 +56,13 @@ export async function generateTypeData(): Promise<RouteData[]> {
|
|||
}
|
||||
return routes;
|
||||
}
|
||||
|
||||
let globalTypeData: Promise<RouteData[]>;
|
||||
|
||||
export function getTypeData(): Promise<RouteData[]> {
|
||||
if (!globalTypeData) {
|
||||
globalTypeData = generateTypeData();
|
||||
}
|
||||
|
||||
return globalTypeData;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue