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

@hnutils/utils

v0.0.9

Published

``` npm install @hnutils/utils ``` #### http使用 http.js ``` import { httpClientInstall } from '@hnutils/utils'; Vue.use(httpClientInstall, { loading(config, msg) { // loading console.log(config); }, error(response) { // error-inspect

Downloads

11

Readme

@hn-utils/utils

http包下载

npm install @hnutils/utils

http使用

http.js

import { httpClientInstall } from '@hnutils/utils';
Vue.use(httpClientInstall, {
  loading(config, msg) {
    // loading
    console.log(config);
  },
  error(response) {
    // error-inspect
    console.log('response', response);
    if (response.status === 404) {
      message.error('网络异常');
    }
    if (response.status !== 401 && response.status !== 404) {
      if (response.data) {
        message.error(response.data.message || response.data.error);
      } else if (response.message) {
        message.error(response.message);
      } else if (response.error) {
        message.error(response.error);
      } else {
        message.error(response)
      }
    }
  },
  streamTypes: ['application/vnd.ms-excel;charset=UTF-8'],  // 不需要对返回对象处理的content-type
  clear() {
  },
  responseCb(response) {
    console.log('response-inspect', responseCb);
  },
  errHeader: {
    'x-test': '我是x-test请求头报错返回'   // 用于自定义处理请求头特定报错
  },
  requestCb(config) {
    console.log('request-inspect', config);
    <!-- const _sign = window.location.search.split('tgt=')[1];
    if (_sign) {
      setToken(_sign);
    }
    const meta = config.meta || {};
    const isToken = meta.isToken === false;
    if (getToken() && !isToken) {
      config.headers[website.Authorization] = website.Authorization + getToken(); // 让每个请求携带token--['Authorization']为自定义key 请根据实际情况自行修改
    }
    config.headers['csrftoken'] = createCSRFToken(config.url); -->
  },
  encrypt: process.env.NODE_ENV === 'local' ? false : website.VUE_APP_ENCRYPT === 'encrypt', // 加解密
  gateway: process.env.NODE_ENV !== 'local' ? website.VUE_APP_GATEWAY + website.VUE_APP_BASE_API : '',  // 网关
  baseApi: process.env.NODE_ENV !== 'local' ? website.VUE_APP_BASE_API : '',  // baseApi
  mode: process.env.NODE_ENV === 'local' ? 'debugRemote' : '' // local: 本地不加网关; debugRemote:本地加网关;
});
export default Vue.prototype.$http;

api.js

import request from './http.js';
const xxx = {
  getTableData(data) {
    return request({
      url: 'xxx',
      method: 'post',
      data: data,
      closeEncrypt: true   // 单个关闭加密
      responseType: 'blob' // 文件类型上传,对返回实体不做任何处理
    });
  },
};
export default xxx;

http代理

// 加密接口,本地调试默认加上/proxy代理
getBaseUrl() {
    if (this.options.mode === 'local') {
      return '/proxy${this.options.gateway}';
    }
    if (this.options.mode === 'debugRemote') {
      return `/proxy${this.options.gateway}`;
    }
    return '';
  }
// 其他接口,默认加/proxy代理
getBaseUrl() {
    if (this.options.mode === 'local') {
      return '/proxy';
    }
    if (this.options.mode === 'debugRemote') {
      return `/proxy${this.options.gateway}${this.options.baseApi}`;
    }
    return `${this.options.gateway}${this.options.baseApi}`;
  }
// vue.config.js文件代理相关
devServer: {
    proxy: {
      '/proxy': {
        target: 'http://172.16.120.88:9999', //代理地址,这里设置的地址会代替axios中设置的baseURL
        changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
        pathRewrite: { '/proxy': '' }
      }
    },
  },