@foxpage/foxpage-api-handler
v1.0.13
Published
response handler
Downloads
29
Readme
背景
toast 展示信息空间较少,覆盖了后端的错误详情,难以提供更加准确的信息
问题
errorToast 函数,错误信息通过前端定义,基本没有用到后端的返回结果
前端现有文案
| Error Code | Description | | --------------------------------------- | ----------------------------- | | fetchListFailed | | | deleteContentFailed | 删除失败,此${type}正在被使用 | | obtainFailed | 获取动态,mock | | uploadFailed | | | deleteFailed | | | updateFailed | | | fetchFailed | | | saveFailed | | | publishFailed | | | offlineFailed | 下线 | | liveFailed | 激活 | | previewFailed | | | fetchUpdateInfoFailed | | | saveResourceFiled | | | saveComponentFiled | | | copyFailed | | | commitFailed | 上架 | | revokeFailed | 下架 | | fetchDetailFailed | | | addFailed | | | fetchPageListFailed | | | checkFailed | | | lockFailed | | | unlockFailed | | | searchFailed | | | cloneFailed | | | disabledFailed | 禁用 | | fetchComponentVersionResourceInfoFailed | 查询组件版本资源信息失败 | | fetchMockFailed | | | parsePageFailed | | | fetchTemplateFailed | | | fetchCatalogFailed | 查询目录失败 | | fetchHtmlFailed | | | fetchDslFailed | | | uploadScreenshotFailed | | | fetchVersionsFailed | 历史版本 | | tagSaveFailed | 标签同步失败 |
服务端
接口返回状态码 status 字段由 3 部分组成,动作,模块,数据,结果
在返回的 status 使用常量的方式传入,组合成最终的一个数值结果
动作
{
"action": {
"create": "10",
"update": "11",
"remove": "12",
"query": "13",
"publish": "14",
"live": "15",
"offline": "16",
"clone": "17",
"purchase": "18",
"deprecate": "19",
"sync": "20",
...
}
}
模块
{
"module": {
"organization": "01",
"team": "02",
"application": "03"
...
}
}
数据
{
"dataType": {
"folder": "01",
"file": "02",
"content": "03",
"version": "04",
"detail": "05",
"builder": "06",
"setting": "07",
"tag": "08",
...
}
}
结果
{
"result": {
"success": "01",
"params-invalid": "02",
"error": "03",
"access-deny": "04"
...
}
}
样例
获取应用详情成功:13-03-05-01
更新应用详情失败:11-03-05-03