59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import { icon } from '../../../utils/components';
|
|
import { date } from '../../../utils/format';
|
|
import { Tab } from '../../common/types';
|
|
|
|
export function getLogsTab(forSite: boolean) {
|
|
const childRoute = forSite ? '站点日志' : '工作台日志';
|
|
const url = forSite ? 'jcloud.api.site.logs' : 'jcloud.api.bench.logs';
|
|
|
|
return {
|
|
label: '日志',
|
|
icon: icon('file-text'),
|
|
route: 'logs',
|
|
childrenRoutes: [childRoute],
|
|
type: 'list',
|
|
list: {
|
|
resource({ documentResource: res }) {
|
|
return {
|
|
makeParams: () => {
|
|
if (res.pagetype === 'Site') {
|
|
return { name: res.pg.name };
|
|
} else {
|
|
return { name: res.pg.group, bench: res.name };
|
|
}
|
|
},
|
|
url,
|
|
auto: true,
|
|
cache: ['ObjectList', url, res.name]
|
|
};
|
|
},
|
|
route(row) {
|
|
return {
|
|
name: childRoute,
|
|
params: { logName: row.name }
|
|
};
|
|
},
|
|
columns: [
|
|
{
|
|
label: '名称',
|
|
fieldname: 'name'
|
|
},
|
|
{
|
|
label: '大小',
|
|
fieldname: 'size',
|
|
class: 'text-gray-600',
|
|
format(value) {
|
|
return `${value} kB`;
|
|
}
|
|
},
|
|
{
|
|
label: '修改时间',
|
|
fieldname: 'modified',
|
|
format(value) {
|
|
return value ? date(value, 'lll') : '';
|
|
}
|
|
}
|
|
]
|
|
}
|
|
} satisfies Tab as Tab;
|
|
} |