| | |
| | | import { $t } from '@/locales' |
| | | |
| | | export function createMenuSearchState() { |
| | | return { |
| | | name: '', |
| | |
| | | if (!title) { |
| | | return '' |
| | | } |
| | | return String(title).split('.').pop() || String(title) |
| | | return String(title).trim() |
| | | } |
| | | |
| | | export function getMenuDisplayTitle(row = {}, titleFormatter = defaultMenuTitleFormatter) { |
| | |
| | | } |
| | | |
| | | export function getMenuTypeText(row = {}) { |
| | | if (row.meta?.isAuthButton || Number(row.type) === 1) return '按钮' |
| | | if (hasNestedMenus(row)) return '目录' |
| | | return '菜单' |
| | | if (row.meta?.isAuthButton || Number(row.type) === 1) return $t('pages.system.menu.types.button') |
| | | if (hasNestedMenus(row)) return $t('pages.system.menu.types.directory') |
| | | return $t('pages.system.menu.types.menu') |
| | | } |
| | | |
| | | export function getMenuStatusMeta(status) { |
| | | return normalizeMenuNumber(status, 1) === 1 |
| | | ? { text: '启用', type: 'success' } |
| | | : { text: '禁用', type: 'danger' } |
| | | ? { text: $t('common.status.enabled'), type: 'success' } |
| | | : { text: $t('common.status.disabled'), type: 'danger' } |
| | | } |
| | | |
| | | export function normalizeMenuTreeOptions(nodes = [], titleFormatter = defaultMenuTitleFormatter) { |
| | |
| | | export function buildMenuTreeOptions(tree = [], titleFormatter = defaultMenuTitleFormatter) { |
| | | return [ |
| | | { |
| | | label: '顶级菜单', |
| | | label: $t('table.topLevelMenu'), |
| | | value: 0, |
| | | children: normalizeMenuTreeOptions(tree, titleFormatter) |
| | | } |