57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { essayProjection } from '@project/utils/projection';
|
|
|
|
export default OakComponent({
|
|
entity: 'essay',
|
|
isList: true,
|
|
projection: essayProjection,
|
|
sorters: [
|
|
{
|
|
// 先按置顶排序
|
|
sorter: {
|
|
$attr: {
|
|
topState: 1,
|
|
},
|
|
$direction: 'desc',
|
|
},
|
|
},
|
|
{
|
|
// 再按创建时间排序
|
|
sorter: {
|
|
$attr: {
|
|
$$createAt$$: 1,
|
|
},
|
|
$direction: 'desc',
|
|
},
|
|
},
|
|
],
|
|
formData({ data }) {
|
|
return {
|
|
list: data.map((item) => {
|
|
const fileIndex = item?.extraFile$entity?.findIndex(
|
|
(item) => item.tag1 === 'cover'
|
|
);
|
|
let url = '';
|
|
if (fileIndex !== undefined && fileIndex > -1) {
|
|
url = this.features.extraFile.getUrl(
|
|
item!.extraFile$entity![fileIndex]
|
|
);
|
|
}
|
|
return {
|
|
...item,
|
|
labels:
|
|
item.essayLabels$essay?.map((label) => {
|
|
return {
|
|
id: label.label.id,
|
|
name: label.label.name,
|
|
bgColor: label.label.bgColor,
|
|
textColor: label.label.textColor,
|
|
};
|
|
}) || [],
|
|
cover: url,
|
|
};
|
|
}),
|
|
};
|
|
},
|
|
actions: ['update', 'withdraw', 'publish', 'setTop', 'cancelTop', 'remove'],
|
|
});
|