Skip to content
关注公众号,获取新课通知

用户列表


控制器:app/controller/admin/user.js

js
	async index() {
        const { ctx, app } = this;

        let data = await ctx.page('User')

        await ctx.renderTemplate({
            title: "用户管理",
            tempType: "table",
            table: {
                // 按钮
                buttons: {
                    add: "/admin/user/create"
                },
                // 表头
                columns: [{
                    title: '用户',
                    fixed: 'left',
                    render(item) {
                        let avatar = item.avatar || '/public/assets/img/profiles/avatar-01.jpg'
                        return `
                        <h2 class="table-avatar">
                            <a class="avatar avatar-sm mr-2"><img class="avatar-img rounded-circle bg-light" src="${avatar}"></a>
                            <a>${item.username}</a>
                        </h2>`
                    },
                }, {
                    title: '金币',
                    key: 'coin',
                    width: 180,
                    fixed: 'center'
                },{
                    title: '时间',
                    key: 'created_time',
                    width: 180,
                    fixed: 'center'
                }, {
                    title: "操作",
                    width: 200,
                    fixed: 'center',
                    action:{
                        edit:function(id){
                            return `/admin/user/edit/${id}`
                        },
                        delete:function(id){
                            return `/admin/user/delete/${id}`
                        },
                    }
                }],
                data
            }
        })
    }

路由:app/router.js

js
router.get("/admin/user", controller.admin.user.index);