logologo
Bắt đầu
Hướng dẫn
Phát triển
Plugin
API
English
简体中文
日本語
한국어
Deutsch
Français
Español
Português
Русский
Italiano
Türkçe
Українська
Tiếng Việt
Bahasa Indonesia
ไทย
Polski
Nederlands
Čeština
العربية
עברית
हिन्दी
Svenska
Bắt đầu
Hướng dẫn
Phát triển
Plugin
API
logologo
Tổng quan API

@nocobase/auth

AuthManager
Auth
BaseAuth

@nocobase/cache

CacheManager
Cache

@nocobase/cli

Giao diện dòng lệnh NocoBase
Biến Môi Trường Toàn Cầu

@nocobase/client

Ứng dụng
Plugin

@nocobase/database

bộ sưu tập
Trường

interfaces

BaseInterface
Các Toán Tử Lọc

RelationRepository

BelongsToManyRepository
belongs-to-repository
HasManyRepository
HasOneRepository
Repository

shared

create-options
destroy-options
find-one
Bắt đầu với Bộ sưu tập
transaction
update-options

@nocobase/data-source-manager

DataSourceManager
DataSource (trừu tượng)
ICollectionManager
ICollection
IField
IModel
IRepository

@nocobase/flow-engine

Trình quản lý nguồn dữ liệu
Ngữ cảnh luồng
FlowEngine
FlowModel
Tài nguyên luồng

@nocobase/logger

Logger

@nocobase/server

AppCommand
Ứng dụng
AuditManager
Ngữ cảnh
Di chuyển
Plugin

@nocobase/sdk

Auth
Storage
Previous PagePlugin
Next PageAuth
TIP

Tài liệu này được dịch bởi AI. Đối với bất kỳ thông tin không chính xác nào, vui lòng tham khảo phiên bản tiếng Anh

#APIClient

#Tổng quan

APIClient là một lớp bao bọc (wrapper) dựa trên axios, được sử dụng để gửi các yêu cầu thao tác tài nguyên của NocoBase từ phía client thông qua HTTP.

#Cách sử dụng cơ bản

class PluginSampleAPIClient extends Plugin {
  async load() {
    const res = await this.app.apiClient.request({
      // ...
    });
  }
}

#Thuộc tính của thể hiện (Instance Properties)

#axios

Thể hiện axios, cho phép truy cập các API của axios, ví dụ như apiClient.axios.interceptors.

#auth

Lớp xác thực phía client, tham khảo Auth.

#storage

Lớp lưu trữ phía client, tham khảo Storage.

#Phương thức của lớp (Class Methods)

#constructor()

Hàm khởi tạo, dùng để tạo một thể hiện APIClient.

#Chữ ký

  • constructor(instance?: APIClientOptions)

#Kiểu dữ liệu

interface ExtendedOptions {
  authClass?: any;
  storageClass?: any;
}

export type APIClientOptions =
  | AxiosInstance
  | (AxiosRequestConfig & ExtendedOptions);

#request()

Gửi một yêu cầu HTTP.

#Chữ ký

  • request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D> | ResourceActionOptions): Promise<R>

#Kiểu dữ liệu

type ResourceActionOptions<P = any> = {
  resource?: string;
  resourceOf?: any;
  action?: string;
  params?: P;
};

#Chi tiết

#AxiosRequestConfig

Các tham số yêu cầu axios chung. Tham khảo Request Config.

const res = await apiClient.request({ url: '' });
#ResourceActionOptions

Các tham số yêu cầu thao tác tài nguyên của NocoBase.

const res = await apiClient.request({
  resource: 'users',
  action: 'list',
  params: {
    pageSize: 10,
  },
});

| Thuộc tính | Kiểu dữ liệu | Mô tả