mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): page: support manage_menu more options. close #366
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user