mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-05-15 15:35:19 +08:00
782 B
782 B
trigger
| trigger |
|---|
| always_on |
API 定义与调用规范
API 定义
import Api from '@/common/Api';
export const accountApi = {
list: Api.newGet('/sys/accounts'),
save: Api.newPost('/sys/accounts'),
update: Api.newPut('/sys/accounts/{id}'),
del: Api.newDelete('/sys/accounts/{id}'),
changeStatus: Api.newPut('/sys/accounts/change-status/{id}/{status}'),
};
调用模式
// 简单请求
await accountApi.del.request({ id: row.id });
// 响应式(用于 loading 状态)
const { execute, isFetching } = accountApi.list.useApi();
// 表格集成
<page-table :page-api="accountApi.list" />
边界
- ✅ Always: API 定义集中放在
api.ts - 🚫 Never: 直接调用 axios,必须通过 API 封装