tachybase_todo/packages/plugin-pages/src/actions/menus.ts

15 lines
441 B
TypeScript
Raw Normal View History

import { Model, ModelCtor } from '@nocobase/database';
import { actions } from '@nocobase/actions';
2021-03-28 13:34:51 +08:00
import { flatToTree } from '../utils';
export const list = async (ctx, next) => {
await actions.common.list(ctx, async () => {
const items = ctx.body.rows as any;
ctx.body.rows = flatToTree(items.map(item => item.toJSON()), {
id: 'id',
parentId: 'parent_id',
children: 'children',
});
});
await next();
}