Bỏ qua, đến nội dung

Cấu hình chi tiết — Mobile

Collection mobileRoutes

Tất cả route mobile được lưu trong collection mobileRoutes:

TrườngKiểuMô tả
idbigInt (PK)ID tự tăng
typestringLoại route: tab, page, link
titlestringTiêu đề hiển thị (hỗ trợ dịch đa ngôn ngữ)
iconstringIcon từ Ant Design Icons
schemaUidstringReference đến UI schema (nội dung trang)
parentIdbigInt (FK)Route cha (hỗ trợ navigation lồng nhau)
sortintegerThứ tự hiển thị
hiddenbooleanẨn/hiện route
enableTabsbooleanBật/tắt tab con bên trong route

Quan hệ với Roles

Route và Role có quan hệ nhiều-nhiều thông qua bảng trung gian rolesMobileRoutes:

Tab Bar

Giới hạn và quy tắc

Quy tắcGiá trị
Số tab tối đa5
Icon setAnt Design Icons (5.x)
BadgeHỗ trợ hiển thị số đếm trên icon (ví dụ: thông báo mới)
Tab conRoute có enableTabs = true sẽ hiển thị tab con khi được chọn

Ẩn/hiện tab con

Khi route cha thay đổi enableTabs, plugin tự động cập nhật hidden cho tất cả route con:

Phân quyền chi tiết

ACL Snippets

SnippetActionsMô tả
ui.mobilemobileRoutes:create, update, move, destroyQuản trị route mobile
pm.mobilemobileRoutes:list, roles.mobileRoutes:*Cấu hình hệ thống mobile

Action listAccessible

Action đặc biệt lọc route theo role hiện tại:

  • User root: Trả về tất cả route (không lọc)
  • User thường: Lọc route dựa trên role → roles.mobileRoutes association

Auto-assign route cho role

Khi tạo route mới (mobileRoutes.afterCreate):

  1. Plugin tìm tất cả role có allowNewMobileMenu = true
  2. Tự động thêm route vào mobileRoutes.roles cho các role đó
  3. Mặc định, adminmemberallowNewMobileMenu = true

Khi thêm/xoá route khỏi role (rolesMobileRoutes.afterBulkCreate/Destroy):

  • Plugin tự động đồng bộ các tab con ẩn (hidden = true) theo route cha

Responsive Breakpoints

BreakpointKích thướcGiao diện
Mobile< 768pxGiao diện mobile (antd-mobile)
Tablet768–1024pxGiao diện mobile (antd-mobile)
Desktop> 1024pxGiao diện desktop (antd)

Plugin sử dụng react-device-detect để phát hiện thiết bị. Trên desktop, bạn có thể truy cập trực tiếp /m để xem bản preview mobile.

Đa ngôn ngữ (Localization)

Plugin đăng ký source mobile-routes với plugin Localization:

Thuộc tínhGiá trị
Source namemobile-routes
Namespacelm-mobile-routes
CollectionmobileRoutes
Trường đồng bộtitle

Khi admin tạo/sửa tiêu đề route, tiêu đề tự động được đồng bộ vào bảng dịch. Quản lý bản dịch tại Settings → Localization.

API Reference

Lấy danh sách route cho user hiện tại

typescript
const response = await api.resource('mobileRoutes').listAccessible();
// Trả về: tree structure của routes user có quyền truy cập

Tạo route mới (admin)

typescript
await api.resource('mobileRoutes').create({
  values: {
    type: 'tab',
    title: 'Báo cáo',
    icon: 'BarChartOutlined',
    schemaUid: 'report-page-schema',
    sort: 3,
  },
});

Cập nhật route

typescript
await api.resource('mobileRoutes').update({
  filterByTk: routeId,
  values: {
    title: 'Trang chủ',
    icon: 'HomeOutlined',
  },
});

Sắp xếp route

typescript
await api.resource('mobileRoutes').move({
  sourceId: 5,
  targetId: 3,
  sortField: 'sort',
});