GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - colodoo/lanb-analog: providing analog data for the FE

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
dist
dist
 
 
src
src
 
 
LICENSE
LICENSE
 
 
README-en.md
README-en.md
 
 
README.md
README.md
 
 
package.json
package.json
 
 
webpack.config.js
webpack.config.js
 
 

Repository files navigation

lanb-analog

为前端提供模拟测试数据

中文文档
English

特性

轻量级

Lanb-alalog是一个轻量级的小插件。 它仅仅只有2.15k,却可以对所有的ajax请求进行监控。

拦截

它依赖于Ajax-hook,如果你想要自定义自己的请求拦截器,那么该项目可以是一个很好的参考。

开始

该项目基于webpack构建,如果你是个爱折腾的人,那么你可以按照如下方法,来获得这个库。

npm install
npm run start

如果想马上获得这个库,那么你可以参考 ./dist/index.html

我们只要像这样重写alalog这个参数

var analog = {};
analog.data = [
    {
        url: 'http://lanb-analog.com/list',
        data: [{ id: 1, name: "测试1" }, { id: 2, name: "测试2" }]
    }
]

然后在我们请求Ajax的时候,url参数后的所有内容就会当成一个匹配项,如果正确匹配了,我们就会把data这个字段中的内容都作为结果返回。

$.ajax({
    url: '?url=http://lanb-analog.com/list',
    type: 'post',
    dataType: 'json',
    success(result) {
        console.log(result)
    }, error(xhr) {
        console.log(xhr.responseJSON)
    },
}) 

扩展

Analog.fn({
    // 需要被重写和扩展的方法
    open: (arg, xhr) => {
        console.log("%O", xhr)
    }
})

我们将保留最最基本的功能,直到该方法被覆盖为止。

社区

  • 组织
  • 加入讨论

许可证书

MIT

About

providing analog data for the FE

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.