perf(projects): manage menu: add transform to component
This commit is contained in:
parent
71f2c5535b
commit
0abbfa5d0c
@ -6,7 +6,7 @@ import { $t } from '@/locales';
|
|||||||
import { enableStatusOptions, menuIconTypeOptions, menuTypeOptions } from '@/constants/business';
|
import { enableStatusOptions, menuIconTypeOptions, menuTypeOptions } from '@/constants/business';
|
||||||
import SvgIcon from '@/components/custom/svg-icon.vue';
|
import SvgIcon from '@/components/custom/svg-icon.vue';
|
||||||
import { getLocalIcons } from '@/utils/icon';
|
import { getLocalIcons } from '@/utils/icon';
|
||||||
import { getLayoutAndPage } from './shared';
|
import { getLayoutAndPage, transformLayoutAndPageToComponent } from './shared';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'MenuOperateDrawer'
|
name: 'MenuOperateDrawer'
|
||||||
@ -162,6 +162,9 @@ function closeDrawer() {
|
|||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
await validate();
|
await validate();
|
||||||
|
|
||||||
|
model.component = transformLayoutAndPageToComponent(model.layout, model.page);
|
||||||
|
|
||||||
// request
|
// request
|
||||||
window.$message?.success($t('common.updateSuccess'));
|
window.$message?.success($t('common.updateSuccess'));
|
||||||
closeDrawer();
|
closeDrawer();
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
const LAYOUT_PREFIX = 'layout.';
|
const LAYOUT_PREFIX = 'layout.';
|
||||||
const VIEW_PREFIX = 'view.';
|
const VIEW_PREFIX = 'view.';
|
||||||
|
const FIRST_LEVEL_ROUTE_COMPONENT_SPLIT = '$';
|
||||||
|
|
||||||
export function getLayoutAndPage(component?: string | null) {
|
export function getLayoutAndPage(component?: string | null) {
|
||||||
const FIRST_LEVEL_ROUTE_COMPONENT_SPLIT = '$';
|
|
||||||
|
|
||||||
let layout = '';
|
let layout = '';
|
||||||
let page = '';
|
let page = '';
|
||||||
|
|
||||||
@ -22,3 +21,22 @@ function getLayout(layout: string) {
|
|||||||
function getPage(page: string) {
|
function getPage(page: string) {
|
||||||
return page.startsWith(VIEW_PREFIX) ? page.replace(VIEW_PREFIX, '') : '';
|
return page.startsWith(VIEW_PREFIX) ? page.replace(VIEW_PREFIX, '') : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function transformLayoutAndPageToComponent(layout: string, page: string) {
|
||||||
|
const hasLayout = Boolean(layout);
|
||||||
|
const hasPage = Boolean(page);
|
||||||
|
|
||||||
|
if (hasLayout && hasPage) {
|
||||||
|
return `${LAYOUT_PREFIX}${layout}${FIRST_LEVEL_ROUTE_COMPONENT_SPLIT}${VIEW_PREFIX}${page}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasLayout) {
|
||||||
|
return `${LAYOUT_PREFIX}${layout}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasPage) {
|
||||||
|
return `${VIEW_PREFIX}${page}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user