All Projects → hengshanMWC → film

hengshanMWC / film

Licence: other
针对axios和flyio之类的二度封装,将配置文件转成方法,主要解决parmas路径痛点

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to film

vue-ssr-template
A full-featured Webpack + vue-loader setup with hot reload, linting, testing & css extraction.. (Thanks for vue-hackernews-2.0)
Stars: ✭ 18 (+12.5%)
Mutual labels:  axios
bs-axios
Bucklescript bindings for axios
Stars: ✭ 74 (+362.5%)
Mutual labels:  axios
vue-mintUI-demo
采用vue2、Mint UI,做的移动端项目
Stars: ✭ 17 (+6.25%)
Mutual labels:  axios
react-jwt-auth
React JWT Authentication & Authorization example - React.js Login and Registration example
Stars: ✭ 307 (+1818.75%)
Mutual labels:  axios
shrtn-it
A url shortener developed as a course completion project
Stars: ✭ 16 (+0%)
Mutual labels:  axios
avbot-charts
Aviation charts
Stars: ✭ 20 (+25%)
Mutual labels:  axios
electron-admin-antd-vue
Electron Vue3.x Ant Design Admin template
Stars: ✭ 21 (+31.25%)
Mutual labels:  axios
proffy
React Native + ReactJS + NodeJS project developed on RocketSeat NexLevelWeek. This project is based on an application for connect students and teachers.
Stars: ✭ 30 (+87.5%)
Mutual labels:  axios
react-ant-admin
此框架使用与二次开发,前端框架使用react,UI框架使用ant-design,全局数据状态管理使用redux,ajax使用库为axios。用于快速搭建中后台页面。
Stars: ✭ 52 (+225%)
Mutual labels:  axios
react-redux-jwt-auth
React Redux: Token Authentication example with JWT, React Router, Axios, Thunk Middleware
Stars: ✭ 86 (+437.5%)
Mutual labels:  axios
project-3-crm
⭐crm 客户关系管理系统模板⭐一个不错的后台管理种子项目,拥有自由设置角色自由分配权限🔑的权限管理功能,三员管理多员管理均可,前端antd vue admin后端spring-boot-api-seedling 拥有完善的功能。文档包含需求文档,设计文档和测试文档等。同时配置了travis,拥有集成测试和自动构建的功能。
Stars: ✭ 128 (+700%)
Mutual labels:  axios
react admin
🎉 TS+Hooks 后台管理系统 http://hooks.sunhang.top
Stars: ✭ 39 (+143.75%)
Mutual labels:  axios
kugou
multiple implementations for kugou music
Stars: ✭ 25 (+56.25%)
Mutual labels:  axios
axios-mock-server
RESTful mock server using axios.
Stars: ✭ 33 (+106.25%)
Mutual labels:  axios
wwvue-cli
vue-cli升级版脚手架,应有尽有的开箱即用方法及配置,没有花里胡哨的晦涩难懂的操作,上手成本极低,现已新增simple(极简模式)、vue3和iview-template,是个很不错的垫脚石,来不及解释了赶紧上车😊😘
Stars: ✭ 15 (-6.25%)
Mutual labels:  axios
shop-native
基于weex(vuejs),同时使用了vuex, vue-router, axios,包含异步(async)语法糖在安卓端不兼容的解决方案
Stars: ✭ 15 (-6.25%)
Mutual labels:  axios
react-app-simple-chat-app
A Simple Chat Application using MERN stack (MongoDB, Express JS, React JS, Node JS) and Socket.io for real time chatting
Stars: ✭ 41 (+156.25%)
Mutual labels:  axios
axios-curlirize
axios plugin converting requests to cURL commands, saving and logging them.
Stars: ✭ 152 (+850%)
Mutual labels:  axios
madao admin manage
🎉 VUE前后端分离管理系统,基于RBAC的后台管理。
Stars: ✭ 38 (+137.5%)
Mutual labels:  axios
vue2.0-SellPosSystem
vue2.0实战项目——简单的快餐店系统
Stars: ✭ 35 (+118.75%)
Mutual labels:  axios

Features

Api factory

Scene

  请求数据这部分,贯穿着整个前端生涯,不知你又是怎样去管理这部分模块。接口一对一写成函数然后export出去?直接this.$fetch('userInfo/1')?前者冗余,后者碎片化不好维护。
  那些业务场景简单的还好,如果像后台管理那种,动不动上百个接口,如果不用一个足够简单的结构去维护这些接口,越到后期,成本越昂贵。
  所以,box-cat就是为了解决这个痛点而生,通过足够简单的结构object来维护接口,并自动生成接口函数

Introduction

box-cat只是解决接口的集中管理。到最后调用的本体还是我们传的http请求库

通过接口对象和HTTP请求库(例如axios、fly.js)进行二度封装,实现api集中管理。

// script引入
<script src="https://unpkg.com/box-cat/dist/boxCat.js"></script>
BoxCat.createProxy
// a.js
import { createApis, createProxy } from 'box-cat'
// server其中的key只要匹配到其中的method(不区分大小写)就会生成对应的以key为名的接口函数
const server = {
  // 接口函数: 接口
  postFile: 'wap/file',
  deleteFile: 'wap/files/:imgId',
  getUserUpFile: 'wap/file/:userId/:imgId
}
export default createApis(server, axios)
// createApiProxy返回一个proxy
// export default createProxy(server, axios)
// a1.js
import http from './a.js'
// 方法使用和对应的HTTP请求库一样
http.postFile({id: 1}).then().catch()
/*
* 如果路径带的有param,则第一个参数是params,http请求库的参数往后顺延
* 当你有多段param的时候,传的是对象
*/ 
await http.deleteFile(1)
await http.getUserUpFile({
  userId: 1,
  imgId: 10
})

method

createApi:返回所有接口方法

createApiProxy:返回Proxy实例,惰性生成接口方法。当判断不支持proxy时,内部会优雅降级为createApi

Options

// createApi和createApiProxy默认参数配置
createApis(server, response, {
  methods: {
    'get': ['get'],
    'post': ['post'],
    'put': ['put'],
    'delete': ['delete'],
    'options': ['options'],
    'head': ['head'],
    'trace': ['trace'],
    'connect': ['connect'],
    'patch': ['patch']
  },
  mergeMethods: {},
  rule: ':param',
  methodsRule: 'startsWith'
  config: {}
})

server

api的管理文件,key不区分大小写

response

HTTP 请求库(axios,fly.io之类)

options

methods

自定义methods,用于匹配接口函数名 例如:'post': ['ADD', 'post', 'submit']

mergeMethods

合并methods

rule

param的匹配规则

methodsRule

默认是:startsWith 匹配方法 'startsWith' | 'endsWith' | 'includes'

config

其他配置,相当于axios的config

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].