npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jingxi

v1.0.8

Published

#### Description 鲸小喜前端npm包,提供跨项目公共依赖、插件功能

Downloads

4

Readme

jingxi

描述

鲸小喜前端npm包,提供跨项目公共依赖、插件功能
可根据项目需要开发相应的组件

安装依赖

npm install jingxi
// or
yarn add jingxi

项目目录

- dist        打包文件目录
- src         源码文件
  - request   ajax封装
  - index.js  入口文件
- webpack.config.js

ajax 使用

ajax 方法封装了 axios,内部参数基本与axios相同,主要是针对请求签名进行了封装
axios文档

const { ajax } from 'jingxi'
//options 与 axios 创建参数实例一样,具体参数看 
let request = new ajax(options, (config) => {
    //请求拦截器 在发送请求之前做些什么
    return config
}, (response) => {
    //请求拦截器 对响应数据做点什么
    return response
})
//支持 .get .post 方法
request.get(url)
request.post(url, data)

// options 默认值
{
  baseURL: '/',
  timeout: 10000,
  withCredentials: true,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  }
}

option新增参数

...
// 由于鲸小喜接口通过 method 区分
// 这部分接口掉用时 url 传 method 参数即可
urlIsMethod // Boolean,默认 false

// 是否开启签名校验
openSign // Boolean,默认 false

// 签名版本 目前有两种签名版本
// 1.0(鲸小喜)和 2.0 (美物满仓)
signVersion // String,默认 2.0

// 是否使用服务端时间生成signData (仅限saas使用)
serverSignTime // Boolean,默认 false
...

例:(saas、美物满仓)

//index.js
import { ajax } from 'jingxi'
export default new ajax({
  baseURL: process.env.BASE_API,
  openSign: true,
  signVersion: '2.0'
}, (config)=>{=
    // 在发送请求之前做些什么
    return config
}, (response) => {
    // 对响应数据做点什么
    return response
})

//login.js
import ajax from './index'
export const signUp = (data={}) => {
  return ajax.post(`/saas/register`,data)
}

例:h5项目(鲸小喜接口)

// index.js
export default new ajax({
  urlIsMethod: true,
  openSign: true,
  signVersion: '1.0',
  baseURL: baseUrl
})

//mjmk.js
import ajax from './index'
export const getList = (data={}) => {
  return ajax.post(`v2.mkmj.item.list`, data)
}