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

xluni-utils

v2.2.0

Published

uniapp框架api集成,包括http请求等等

Downloads

3

Readme

xluni-utils

uniapp 框架的工具插件

安装

pnpm i xluni-utils

http

utils 新建 request.ts 文件,如下

import { http } from "xluni-utils";

const defHttp = http.create({
  baseUrl: "", // 接口根地址
});

// 请求拦截器 ,可以加token,返回false则中断请求
defHttp.interceptor.request = (config: any) => {
  // config.header.token = "1234";

  return config;
};

// 响应拦截器,返回所有的响应数据,return的值为false则会触发Promise.reject()
defHttp.interceptor.response = (response: any) => {
  console.log(response);
  return response;
};

export default defHttp;

类型列表

  • CreateConfig

| 属性 | 类型 | 默认值 | 可选值 | 备注 | | --------------- | ------- | ------------------------------------ | --------------- | --------------------------------- | | baseUrl | string | -- | -- | 接口根地址 | | timeout | number | 60000 | -- | 请求超时的时间,单位 ms | | method | string | GET | POST/PUT/DELETE | 请求方式 | | header | object | {"content-type": "application/json"} | -- | 请求头 | | responseType | string | text | arraybuffer | 设置响应的数据类型 | | sslVerify | boolean | true | false | 验证 ssl 证书 | | withCredentials | boolean | false | true | 跨域请求时是否携带凭证(cookies) | | firstIpv4 | boolean | false | true | DNS 解析时优先使用 ipv4 |

路由

toPage(url,data,events)

保留当前页面,跳转到应用内的某个页面,使用 backTo 可以返回到原页面。

  • url 必填,需要跳转的应用内非 tabBar 的页面的路径

  • data 非必填,页面参数

  • events 非必填,页面间通信,参考地址:https://uniapp.dcloud.net.cn/api/router.html#navigateto

toTab(url)

跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面。

  • url 必填,需要跳转的应用内 tabBar 的页面的路径

backTo(delta)

关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages() 获取当前的页面栈,决定需要返回几层。

  • delta 非必填,返回的页面数,必须大于 0 的整数,默认为 1

closeTo(url,data)

关闭当前页面,跳转到应用内的某个页面。

  • url 必填,需要跳转的应用内非 tabBar 的页面的路径
  • data 非必填,页面参数

closeAllTo

关闭所有页面,打开到应用内的某个页面。

  • url 必填,需要跳转的应用内页面路径
  • url 非必填,页面参数,如果跳转的页面路径是 tabBar 页面则不能带参数

数据缓存

  • setStorage 保存数据

  • getStorage 获取数据

  • removeStorage 删除数据

类型判断

  • typeOf 类型判断,返回类型的小写

  • checkType 类型检查,返回布尔值

  • isNumber 数值类型

  • isString 字符类型

  • isArray 数组类型

  • isFunction 函数类型

  • isObject object 类型