Giao diện
@digiforce-nc/plugin-hello
Plugin mẫu cho developer — template khởi điểm để tạo plugin mới, minh họa cấu trúc, vòng đời và cách tích hợp với hệ thống Digiforce.
Plugin này làm gì?
plugin-hello không có chức năng nghiệp vụ — nó là boilerplate plugin cho developer muốn tạo plugin riêng. Plugin minh họa đầy đủ: cấu trúc thư mục, server/client plugin class, đăng ký collection, thêm API endpoint, tạo UI component, và hook vào vòng đời ứng dụng.
Cấu trúc plugin
Vòng đời plugin
Tính năng minh họa
| # | Tính năng | Mô tả |
|---|---|---|
| 1 | Server plugin class | Kế thừa Plugin, implement lifecycle methods |
| 2 | Collection | Khai báo collection "hello" với fields |
| 3 | API endpoint | REST endpoint /api/hello:greet |
| 4 | Client plugin class | Đăng ký route, component, settings |
| 5 | React component | Trang "Hello World" minh họa |
| 6 | Lifecycle hooks | beforeLoad, load, install, afterStart |
API endpoints (minh họa)
| Endpoint | Mô tả |
|---|---|
hello:greet | Trả về message "Hello, World!" |
hello CRUD | CRUD collection hello |
Database (minh họa)
| Bảng | Mô tả |
|---|---|
hello | Bảng mẫu (name, message, createdAt) |
Thành phần client (minh họa)
| Thành phần | Mô tả |
|---|---|
HelloPage | Trang minh họa hiển thị message |
HelloBlockInitializer | Block initializer mẫu |
HelloSettings | Settings page mẫu |
Dependencies
| Package | Vai trò |
|---|---|
@digiforce-nc/server | Server framework |
@digiforce-nc/database | Database ORM |
@digiforce-nc/client | Client UI framework |
Sử dụng làm template
- Copy thư mục
plugin-hellosang tên plugin mới - Đổi tên package trong
package.json - Đổi tên class
PluginHelloServer/PluginHelloClient - Thay đổi collection, API, UI theo nhu cầu
- Đăng ký plugin trong ứng dụng