feat(projects): page: support manage_menu more options. close #366

This commit is contained in:
Soybean
2024-05-07 01:36:22 +08:00
parent ebe55af7d5
commit c4b5c65625
9 changed files with 286 additions and 205 deletions

View File

@ -41,20 +41,39 @@ export function transformLayoutAndPageToComponent(layout: string, page: string)
return '';
}
export function transformToQueryObject(data: Record<string, string>[]) {
const query: Record<string, string> = {};
data.forEach(pair => {
if (pair.key && pair.value) {
query[pair.key] = pair.value;
}
});
return query;
/**
* Get route name by route path
*
* @param routeName
*/
export function getRoutePathByRouteName(routeName: string) {
return `/${routeName.replace(/_/g, '/')}`;
}
export function transformToKeyValuePairs(query?: Record<string, string>) {
const safeQuery = query || {};
return Object.entries(safeQuery).map(([key, value]) => ({
key,
value
}));
/**
* Get path param from route path
*
* @param routePath route path
*/
export function getPathParamFromRoutePath(routePath: string) {
const [path, param = ''] = routePath.split('/:');
return {
path,
param
};
}
/**
* Get route path with param
*
* @param routePath route path
* @param param path param
*/
export function getRoutePathWithParam(routePath: string, param: string) {
if (param.trim()) {
return `${routePath}/:${param}`;
}
return routePath;
}