feat: update template
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import type { ColumnDef } from '@tanstack/react-table'
|
||||
|
||||
import { StatusLabel } from '@/components/label'
|
||||
import { DictLabel } from '@/components/label'
|
||||
import { MenuIcon } from '@/components/menu-icon'
|
||||
import { menuTypeDict, type MenuTypeValues, type StatusValues } from '@/enum'
|
||||
import { menuTypeDict, statusLabel, type MenuTypeValues, type StatusValues } from '@/enum'
|
||||
import { formatDate, hasPermission } from '@/lib'
|
||||
import type { MenuTree } from '@/schemas'
|
||||
|
||||
@@ -28,7 +28,7 @@ export const createColumns = (): ColumnDef<MenuTree>[] => {
|
||||
{
|
||||
accessorKey: 'path',
|
||||
header: '菜单路径',
|
||||
meta: { className: ' max-w-36' },
|
||||
meta: { className: 'max-w-36' },
|
||||
cell: ({ row }) => <div className='overflow-hidden'>{row.getValue('path')}</div>,
|
||||
},
|
||||
{
|
||||
@@ -37,40 +37,41 @@ export const createColumns = (): ColumnDef<MenuTree>[] => {
|
||||
meta: { className: 'max-w-20' },
|
||||
cell: ({ row }) => {
|
||||
const menuType = menuTypeDict[row.getValue('type') as MenuTypeValues]
|
||||
return <div>{menuType}</div>
|
||||
return <DictLabel text={menuType} />
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'permission_code',
|
||||
header: '权限字符',
|
||||
meta: { className: ' max-w-36' },
|
||||
meta: { className: 'max-w-36' },
|
||||
cell: ({ row }) => <div>{row.getValue('permission_code')}</div>,
|
||||
},
|
||||
{
|
||||
accessorKey: 'status',
|
||||
header: '菜单状态',
|
||||
meta: { className: ' max-w-36' },
|
||||
meta: { className: 'max-w-36' },
|
||||
cell: ({ row }) => {
|
||||
const status = row.getValue('status') as StatusValues
|
||||
return <StatusLabel value={status} />
|
||||
const { text, dotClass } = statusLabel[status]
|
||||
return <DictLabel text={text} dotClass={dotClass} />
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'hidden',
|
||||
header: '是否隐藏',
|
||||
meta: { className: ' max-w-36' },
|
||||
meta: { className: 'max-w-36' },
|
||||
cell: ({ row }) => <div>{row.getValue('hidden') ? '是' : '否'}</div>,
|
||||
},
|
||||
{
|
||||
accessorKey: 'sort',
|
||||
header: '菜单排序',
|
||||
meta: { className: ' max-w-36' },
|
||||
meta: { className: 'max-w-36' },
|
||||
cell: ({ row }) => <div>{row.getValue('sort')}</div>,
|
||||
},
|
||||
{
|
||||
accessorKey: 'created_at',
|
||||
header: '创建时间',
|
||||
meta: { className: ' max-w-36' },
|
||||
meta: { className: 'max-w-36' },
|
||||
cell: ({ row }) => {
|
||||
const rawDate = row.getValue('created_at') as string
|
||||
return <div className='overflow-hidden'>{formatDate(rawDate)}</div>
|
||||
@@ -79,7 +80,7 @@ export const createColumns = (): ColumnDef<MenuTree>[] => {
|
||||
{
|
||||
accessorKey: 'updated_at',
|
||||
header: '修改时间',
|
||||
meta: { className: ' max-w-36' },
|
||||
meta: { className: 'max-w-36' },
|
||||
cell: ({ row }) => {
|
||||
const rawDate = row.getValue('updated_at') as string
|
||||
return <div className='overflow-hidden'>{formatDate(rawDate)}</div>
|
||||
@@ -91,7 +92,7 @@ export const createColumns = (): ColumnDef<MenuTree>[] => {
|
||||
columns.push({
|
||||
id: 'actions',
|
||||
enableHiding: false,
|
||||
meta: { className: ' max-w-36 sticky right-0' },
|
||||
meta: { className: 'max-w-36 sticky right-0' },
|
||||
cell: RowActions,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user