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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@foundbyte/uni-libs

v1.1.6-alpha.1

Published

FoundByte Uni Libs

Readme

一码游贵州SDK包

服务

初始化

如需使用服务api,必须进行初始化,所有服务方法都需要依赖该方法生成的实例对象进行调用

import { OneTravelSDK, EAppEnv, ECaller } from '@foundbyte/uni-libs'

// 方式一、默认参数
const oneTravelSdk = new OneTravelSDK();

// 方式二、动态参数
const oneTravelSdk = new OneTravelSDK({
  appEnv: EAppEnv.PROD,
  caller: ECaller.web
})

参数

| 参数名 | 描述 | 类型 | 是否必填 | 默认值 | |-----|-----|-----|-----|-----| | appEnv | 环境变量 | EAppEnv | 否 | EAppEnv.PROD | | caller | 调用者 | ECaller | 否 | ECaller.WEB |

goodsService

商品服务

跳转商品详情页

oneTravelSdk.goodsService.jumpToProductDetailPage({
  ...
})

参数

| 参数名 | 描述 | 类型 | 是否必填 | 默认值 | |-----|-----|-----|-----|-----| | item | 商品项 | IJumpProductDetailItem | 是 | - |

工具(webView应用)

navigateTo(H5)

原生路由跳转

import { navigateTo } from '@foundbyte/uni-libs'
navigateTo({
  src: '/pages/index/index',
  params: {
    id: 1
  }
})  

/**
 * 去登录,并返回刷新
 */
export const toLogin = () => {
  navigateTo({ src: `/pages/sign-in/index?url=${encodeURIComponent(window.location.href)}&delta=1` })
}

redirectTo(H5)

原生路由重定向

import { redirectTo } from '@foundbyte/uni-libs'
redirectTo({
  src: '/pages/index/index',
  params: {
    id: 1
  }
})  

navigateBack(H5)

原生路由返回

import { navigateBack } from '@foundbyte/uni-libs'
navigateBack({
  delta: 1
})  

setShareParam(H5)

设置页面分享内容

import { setShareParam, EBusinessLine } from '@foundbyte/uni-libs'

setShareParam({
  /** 标题 */
  title: '',
  /** 缩略图 */
  imageUrl: '',
  /** web完整链接,不需要encodeURIComponent */
  shareUrl: ''
},
/** 业务线id, 没有可忽略 */
businessType: EBusinessLine.Foods
) 

downLoadFile(H5)

下载文件

import { downLoadFile } from '@foundbyte/uni-libs'

// 传入要下载的文件链接
downLoadFile('https://xxx.pdf')

环境判断(H5)

import { isAlipay, isWeixin, isHarmony, isAndroid, isiOS } from '@foundbyte/uni-libs'

/** 支付宝小程序、微信、鸿蒙app、安卓app、苹果app */
console.info(isAlipay, isWeixin, isHarmony, isAndroid, isiOS)

原生应用、小程序

router 路由跳转封装(针对原生应用、小程序,WebView、H5请参考上面的方法)

对 uni.navigateTo 等路由跳转 API 的统一封装,入参与 uni 保持一致,统一返回 Promise,业务代码只需将 uni.navigateTo 替换为 router.navigateTo。

import { router } from '@foundbyte/uni-libs'

// url 已拼好参数(与 uni 用法一致)
router.navigateTo({ url: '/pages/detail/index?id=123' })

// 通过 query 对象自动拼接参数
router.navigateTo({ url: '/pages/detail/index', query: { id: '123' } })

// 返回 Promise:成功跳转 resolve(true),被拦截器取消 resolve(false),跳转失败 reject
const navigated = await router.navigateTo({ url: '/pages/detail/index' })

// 其余方法与 uni 一一对应
router.redirectTo({ url: '/pages/detail/index' })
router.reLaunch({ url: '/pages/index/index' })
router.switchTab({ url: '/pages/tab-bar/index' })
await router.navigateBack({ delta: 1 })

特性

  • 页面栈达到最大层级时(微信小程序、支付宝小程序最多 10 层,App iOS/Android 同样有上限),navigateTo 自动降级为 redirectTo,使路由在最后一层循环;鸿蒙端因 getCurrentPages() 真机返回空数组,使用内部层级计数兜底
  • 可通过 setRouterMaxLevel(level) 调整层级上限(默认 10)
  • H5 无层级限制,不降级

路由拦截器

支持注册全局拦截器做登录校验等业务拦截,任一拦截器返回 false 取消本次跳转,支持异步:

import { addRouterInterceptor, router } from '@foundbyte/uni-libs'

// 返回注销函数
const remove = addRouterInterceptor(({ action, options }) => {
  if (action === 'navigateTo' && needAuth(options?.url) && !isLogin) {
    // 跳转登录页并取消本次跳转
    router.navigateTo({ url: '/pages/sign-in/index' })
    return false
  }
})

remove() // 注销拦截器

// 也可通过 removeRouterInterceptor 移除(与 addRouterInterceptor 返回的注销函数等价)
import { removeRouterInterceptor } from '@foundbyte/uni-libs'
removeRouterInterceptor(interceptorFn)

拦截器上下文: | 参数名 | 描述 | 类型 | |-----|-----|-----| | action | 跳转方式 | 'navigateTo' | 'redirectTo' | 'reLaunch' | 'switchTab' | 'navigateBack' | | options | 跳转入参(navigateBack 时为 INavigateBackOptions) | INavigateOptions | ISwitchTabOptions | INavigateBackOptions |