![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@jimengio/api-base
Advanced tools
公司项目 API 前端复用逻辑
包含功能:
注意事项
原先耦合的代码需要手动处理一遍, 搜则对应的逻辑会丢失:
EJimuApiEvent.ErrorUnauthorized
事件, 调用 clearUserInfoCache()
,EJimuApiEvent.ErrorMessage
事件, 调用 message.error(errorHumanized)
,EJimuApiEvent.ErrorGotoSignin
调用 gotoSignin(signinPath, location.href)
.yarn add @jimengio/api-base
import { get } from "@jimengio/api-base";
get({
baseURL: `http://my-api/api`,
url: `/info`,
});
// 发送其他方法
get({
method: "POST",
baseURL: `http://my-api/api`,
url: `/info`,
});
import { addGlobalErrorMessages } from "@jimengio/api-base";
addGlobalErrorMessages({
00001: "信息不合法",
});
对于特定的错误码定制错误信息(覆盖默认注册的错误信息):
put({
url: `/plants/${plantId}/materials/${materialId}`,
baseURL: coresBaseUrl,
data: options,
errorMessage: {
[ApiErrorCode.DBDup]: lingual.materialCodeAlreadyExists,
},
});
通过 false
可以关闭特定错误码的报错提示:
{
errorMessage: {
[ApiErrorCode.DBDup]: false,
},
}
通过 axios 的 paramsSerializer
的参数可以对数组格式的 query 参数进行格式化:
{
paramsSerializer: (params) => Qs.stringify(params, {arrayFormat: 'brackets'}),
}
import { EJimuApiEvent } from "@jimengio/api-base";
JimuApisEventBus.on(EJimuApiEvent.ErrorMessage, (error: string) => {
console.error(error);
});
export { changeApisLingual, EApisLangKind } from "@jimengio/api-base";
changeApisLingual(EApisLangKind.enUS);
展示网络加载进度(不精确):
import { NetProgress } from "@jimengio/api-base";
<NetProgress />;
get
post
put
del
patch
, 基础 HTTP 请求changeApisLingual
, EApisLangKind
用于修改多语言配置NetProgress
渲染网络状态的组件addGlobalErrorMessages
addGlobalStatusCodeErrorMessages
设置错误文案`ApiError
IJimuApiOption
API 属性配置类型BuiltinApiErrorCode
内置错误码, 偶尔会用到generateCancelToken
getApiBaseUrl
setApiBaseUrl
setApiDefaultHeader
API 状态修改方法globalErrorMessages
globalStatusCodeErrorMessages
(类型为 IErrorMessages
) 读取全局错误文案配置showError
触发错误FAQs
> 公司项目 API 前端复用逻辑
We found that @jimengio/api-base demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.