Giao diện
API reference
App resource
app:getInfo
Trả về thông tin ứng dụng.
GET /api/app:getInfoResponse:
json
{
"data": {
"database": { "dialect": "postgres" },
"version": "1.0.0",
"lang": "vi-VN",
"theme": "default",
"enabledLanguages": ["vi-VN", "en-US"],
"plugins": { "acl": true, "users": true }
}
}app:getLang
Lấy ngôn ngữ hiện tại và toàn bộ bản dịch.
GET /api/app:getLang?locale=vi-VNResponse:
json
{
"data": {
"lang": "vi-VN",
"resources": {
"client": { "Menu": "Menu", "Settings": "Cài đặt" }
}
}
}app:clearCache
Xóa toàn bộ cache server (schema, ACL, i18n). Yêu cầu quyền admin.
POST /api/app:clearCacheapp:restart
Restart toàn bộ ứng dụng. Yêu cầu quyền admin.
POST /api/app:restartapp:refresh
Refresh app state (reload plugin, clear internal state) mà không restart process.
POST /api/app:refreshDesktop Routes
desktopRoutes:list
Danh sách tất cả desktop routes (không lọc ACL).
GET /api/desktopRoutes:list?paginate=falsedesktopRoutes:listAccessible
Danh sách routes mà user hiện tại được phép truy cập (đã lọc qua ACL + role binding).
GET /api/desktopRoutes:listAccessibleResponse chỉ trả về các route có trong rolesDesktopRoutes của role hiện tại, kèm tree structure.
desktopRoutes:getAccessible
Chi tiết 1 route accessible theo filter key.
GET /api/desktopRoutes:getAccessible?filterByTk=<routeId>desktopRoutes:create
Tạo menu mới (phiên bản cơ bản).
POST /api/desktopRoutes:create
Body: {
"title": "Đơn hàng",
"type": "page",
"parentId": null,
"icon": "ShoppingCartOutlined",
"schemaUid": "uid_xxx"
}desktopRoutes:createV2
Tạo menu mới kèm cascade tạo uiSchema và uiWidget qua UiWidgetRepository.ensureModel.
POST /api/desktopRoutes:createV2
Body: {
"title": "Đơn hàng",
"type": "page",
"parentId": null,
"enableTabs": true,
"menuSchemaUid": "menu_uid",
"tabSchemaName": "tab_name"
}Sau khi tạo, tự động gán vào tất cả role có allowNewMenu: true.
desktopRoutes:update
Cập nhật thông tin menu.
PUT /api/desktopRoutes:update?filterByTk=<routeId>
Body: {
"title": "Đơn hàng (cập nhật)",
"hideInMenu": false,
"enableHeader": true
}desktopRoutes:destroy
Xóa menu (phiên bản cơ bản, chỉ xóa record).
DELETE /api/desktopRoutes:destroy?filterByTk=<routeId>desktopRoutes:destroyV2
Xóa menu kèm cascade xóa uiSchemas (qua schemaUid) và uiWidgets (qua tabSchemaName).
DELETE /api/desktopRoutes:destroyV2?filterByTk=<routeId>desktopRoutes:move
Di chuyển menu trong cây (thay đổi parentId và sort).
POST /api/desktopRoutes:move
Body: {
"sourceId": 10,
"targetId": 5,
"targetScope": { "parentId": null },
"method": "insertAfter"
}| Param | Mô tả |
|---|---|
sourceId | ID menu cần di chuyển |
targetId | ID menu đích |
targetScope | Scope mới (parentId) |
method | insertBefore, insertAfter, prepend, append |
Roles-Desktop Routes
roles.desktopRoutes:set
Gán danh sách desktop routes cho một role cụ thể. Thay thế toàn bộ binding cũ.
POST /api/roles/<roleName>/desktopRoutes:set
Body: {
"desktopRouteIds": [1, 2, 5, 10]
}Ví dụ sử dụng
Tạo menu page mới với tabs
typescript
const response = await agent.resource('desktopRoutes').createV2({
values: {
title: 'Quản lý đơn hàng',
type: 'page',
icon: 'ShoppingCartOutlined',
enableTabs: true,
enableHeader: true,
displayTitle: true,
},
});
const routeId = response.body.data.id;Gán menu cho role
typescript
await agent.resource('roles.desktopRoutes', 'member').set({
values: [routeId, existingRouteId],
});Lấy menu accessible cho user hiện tại
typescript
const response = await agent.resource('desktopRoutes').listAccessible();
const menuTree = response.body.data;