Giao diện
@digiforce-nc/plugin-client
Plugin Web UI — quản lý menu desktop/mobile, cung cấp API thông tin ứng dụng, tích hợp ACL cho hệ thống menu, và đồng bộ tên menu với localization.
Plugin này làm gì?
Hãy hình dung ứng dụng Digiforce như một tòa nhà: plugin-client là sơ đồ tầng — nó quyết định người dùng thấy những phòng nào (menu), cửa nào mở (route), và bảng thông tin ở sảnh (app info). Plugin còn phối hợp với ACL để đảm bảo mỗi role chỉ thấy menu được phép.
Ba nhiệm vụ chính
| # | Nhiệm vụ | Chi tiết |
|---|---|---|
| 1 | Menu management | CRUD desktop/mobile routes, di chuyển, sắp xếp, cascade xóa uiSchemas + uiWidgets |
| 2 | App API | Endpoints lấy thông tin hệ thống, đổi ngôn ngữ, xóa cache, restart, refresh |
| 3 | ACL binding | Tự động gán menu mới cho role có allowNewMenu: true, endpoint roles.desktopRoutes:set |
API endpoints
App resource
| Endpoint | Mô tả |
|---|---|
app:getInfo | Thông tin ứng dụng (version, locale, plugins đã cài) |
app:getLang | Lấy ngôn ngữ hiện tại và toàn bộ bản dịch |
app:clearCache | Xóa toàn bộ cache server |
app:restart | Restart ứng dụng (admin only) |
app:refresh | Refresh app state mà không restart |
Desktop routes
| Endpoint | Mô tả |
|---|---|
desktopRoutes:list | Danh sách tất cả desktop routes |
desktopRoutes:listAccessible | Chỉ các route user được phép truy cập (đã lọc ACL) |
desktopRoutes:getAccessible | Chi tiết 1 route accessible theo key |
desktopRoutes:create / createV2 | Tạo menu mới (v2 hỗ trợ nested creation) |
desktopRoutes:update | Cập nhật thông tin menu |
desktopRoutes:destroy / destroyV2 | Xóa menu (v2 cascade xóa uiSchemas + uiWidgets) |
desktopRoutes:move | Di chuyển vị trí menu trong cây |
roles.desktopRoutes:set | Gán danh sách menu cho role cụ thể |
Cascade delete
Khi xóa menu qua destroyV2, plugin tự động dọn dẹp toàn bộ tài nguyên UI liên quan:
ACL binding — allowNewMenu
Khi admin tạo menu mới, plugin kiểm tra tất cả role có cờ allowNewMenu: true và tự động gán:
Database — 3 bảng chính
| Bảng | Chứa gì | Ví dụ |
|---|---|---|
desktopRoutes | Menu desktop (path, title, icon, parentId, sort) | { title: 'Đơn hàng', path: '/orders' } |
mobileRoutes | Menu mobile (tương tự desktop) | { title: 'Dashboard', path: '/m/dashboard' } |
rolesDesktopRoutes | Liên kết role ↔ menu (M2M) | { roleName: 'admin', desktopRouteId: 5 } |
Thành phần client
| Thành phần | Mô tả |
|---|---|
DesktopRoutesManager | Trang quản lý menu desktop (Settings → Desktop Menu) — drag-drop sắp xếp |
MobileRoutesManager | Trang quản lý menu mobile (Settings → Mobile Menu) |
RouteSchemaComponent | Render nội dung trang từ uiSchema gắn với route |
Dependencies
| Package | Vai trò |
|---|---|
@digiforce-nc/client | Client framework (peer) |
@digiforce-nc/server | Server framework (peer) |
@digiforce-nc/database | Database ORM (peer) |
@digiforce-nc/plugin-localization | Đồng bộ tên menu với bản dịch |
Mục lục chi tiết
- Kiến trúc — DesktopRoutes tree, app resource, menu-role binding
- API reference — App resource endpoints, desktopRoutes CRUD, roles.desktopRoutes:set
- Database schema — ER diagram, desktopRoutes, mobileRoutes, rolesDesktopRoutes
- FAQ — Câu hỏi thường gặp