{"id":19451779,"url":"https://github.com/zhengxs2018/axios-http","last_synced_at":"2025-04-25T04:30:30.982Z","repository":{"id":118133466,"uuid":"450013197","full_name":"zhengxs2018/axios-http","owner":"zhengxs2018","description":"大多数前端应用都需要通过 HTTP 协议与后端服务器通讯，为约定和规范从 UI 交互到请求服务端数据的完整方案，进一步简化了应用的数据请求流程，基于Axios 提供了 HTTP 模块。WIP: 💪 正在积极开发中。","archived":false,"fork":false,"pushed_at":"2022-03-18T05:47:14.000Z","size":1590,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2025-04-03T15:52:30.887Z","etag":null,"topics":["axios","helpers","http-client","jsonp","library","retry"],"latest_commit_sha":null,"homepage":"https://zhengxs2018.github.io/axios-http","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhengxs2018.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-20T08:25:28.000Z","updated_at":"2024-09-13T12:27:36.000Z","dependencies_parsed_at":"2023-07-06T15:31:23.729Z","dependency_job_id":null,"html_url":"https://github.com/zhengxs2018/axios-http","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengxs2018%2Faxios-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengxs2018%2Faxios-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengxs2018%2Faxios-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhengxs2018%2Faxios-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhengxs2018","download_url":"https://codeload.github.com/zhengxs2018/axios-http/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250754541,"owners_count":21481834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["axios","helpers","http-client","jsonp","library","retry"],"created_at":"2024-11-10T16:43:03.064Z","updated_at":"2025-04-25T04:30:30.976Z","avatar_url":"https://github.com/zhengxs2018.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @zhengxs/axios-http\n\n\u003e 模块尚未发布，正在积极开发中\n\n\u003e **注意**: 模块将作为 [VueExpress](https://github.com/zhengxs2018/vue-express) 一部分一起发布。\n\n大多数前端应用都需要通过 HTTP 协议与后端服务器通讯，为约定和规范从 UI 交互到请求服务端数据的完整方案，进一步简化了应用的数据请求流程，基于 [Axios][axios] 提供了 HTTP 模块。\n\n可以从 [这里](https://juejin.cn/post/7053471988752318472) 了解此模块的理念。\n\n**依赖关系图**\n\n![Dependency tree](./dependency-tree.png)\n\n- **@zhengxs/axios-http** 统一出口\n- **@zhengxs/axios-client** Axios 的封装\n- **@zhengxs/axios-helpers** 助手函数\n- **@zhengxs/axios-plugin-\\*** 功能插件 (`ps: 兼容 Axios 的实例`)\n- **@zhengxs/axios-shared** 兼容层，用于解决依赖的模块方法未导出的问题\n- **@zhengxs/axios-types** 提供给其他模块使用的 TS 类型\n\n框架集成中\n\n- **@zhengxs/axios-vue** 提供给 `Vue 2 \u0026 3` 使用的插件，由 [vue-demi](https://github.com/vueuse/vue-demi) 提供技术支持\n\n## 使用\n\n### 安装依赖\n\n```sh\n# With NPM\n$ npm install @zhengxs/axios-http --save\n\n# With Yarn\n$ yarn add @zhengxs/axios-http\n\n# With PNPM\n$ pnpm add @zhengxs/axios-http\n```\n\n### 示例\n\n```js\nimport http from '@zhengxs/axios-http'\n\n// 设置基础地址\nhttp.setBaseURL('https://example.com')\n\n// 设置自定义请求头\nhttp.setHeader('x-api-version', 'v1')\n\n// 设置 Authorization 头\n// 默认为 Bearer 类型\nhttp.setAuthorization('Bearer xxx')\n\n// 设置 Authorization 头，自动加认证类型\n// 默认为 Bearer 类型\nhttp.setToken('xxx')\n\n// 启用自动重试\nhttp.enableAutoRetry()\n\n// 发送请求\nhttp.request('http://example.com/test')\n\n// 发送 jsonp 请求\nhttp.request('http://example.com/test', {\n  jsonp: true // 设置 jsonp=true 可以将普通请求变为 jsonp\n})\n```\n\n## 文档\n\n您可以点击 [这里](https://zhengxs2018.github.io/axios-http/) 查看文档。\n\n## 启动项目\n\n本项目为 monorepo 架构，使用 [lerna](https://github.com/lerna/lerna) (`可选`) 进行管理，但默认配置的包管理器为 [yarn 1.x](https://classic.yarnpkg.com/lang/en/).\n\nlerna 是可选的工具，但 yarn 必须全局安装。\n\n```sh\n# 安装依赖\n$ yarn install\n\n# 生成 .d.ts 文件\n$ yarn build:dts\n\n# 启动文档\n$ yarn docs:dev\n\n# 发布文档\n$ yarn docs:release\n```\n\n## 注意\n\n依赖关系图 使用 [package-dependency-graph](https://github.com/plantain-00/package-dependency-graph) 模块生成，因国内网络访问 github 问题，不再内置此模块，需要的可以使用 cnpm 进行全局安装。\n\n## License\n\nMIT\n\n[axios]: https://axios-http.com/\n[swr]: https://swr.vercel.app/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhengxs2018%2Faxios-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhengxs2018%2Faxios-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhengxs2018%2Faxios-http/lists"}