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

ivy-fe

v1.0.61

Published

### 初始化 ``` // 入口文件 import Vue from 'vue' import router from './router' import axios from 'axios' import Mint from 'mint-ui' import config from './config' require('ivy-fe').init({Vue, router, axios, config, Mint}) ``` * 注册MintUI的组件,并且在Vue.prototype上添加$Toa

Downloads

6

Readme

前端公共库

初始化

// 入口文件
import Vue from 'vue'
import router from './router'
import axios from 'axios'
import Mint from 'mint-ui'
import config from './config'
require('ivy-fe').init({Vue, router, axios, config, Mint})
  • 注册MintUI的组件,并且在Vue.prototype上添加$Toast/$Indicator/$MessageBox
  • 添加部分全局函数
  • 全局错误处理,网络请求的错误拦截器

添加的全局函数

new Date().format('YYYY-MM-DD hh:mm:ss') // 指定时间格式
Date.newDate('2018-01-01') // IOS上的new Date()不识别此格式,这个函数能够成功
Date.formatMs(63001, 'mm分ss.SSS') === '1分30.001' // 格式化为几小时几分

登陆注册信息管理

  • 登陆注册信息通常放到全局的store里,方便其他需要的地方使用
// 项目store文件
import ivyStore from 'ivy-fe/ivyStore'
let config = require('./config')

export default {
  logined: ivyStore.logined,
  async login(vue, force = 0) { // force用于强制登陆,否则login调用多次,实际登陆一次
    return await ivyStore.login(vue, force)
  },
  async bindPhone(options) {
    return await ivyStore.bindPhone(options)
  },
}

辅助函数

import * as utils from 'ivy-fe/utils'

await sleep(2000) // 睡眠2000毫秒

let uuid = uuid() // 生成uuid

let os = getOs() // 返回 android / mac

isWeixin()
isIos()
isAndroid()

cacheSet(key, value, expire) // expire为过期时间,-1永不过期,0立即过去,存储格式为json
cacheGet(key) // 获取缓存的数据

// 许多页面需要手动删除定时器,写了自动管理的定时器,相同的timer-name会把之前同名的定时器删除
// 结束之后不删除定时器也不会导致太多的定时器
setAutoTimer(() => console.log('one second'), 1000, 'timer-name')

微信函数

import * as weixin as 'ivy-fe/weixin'

await wxConfigReady() // 等待微信config

await weixinPay(payInfo) // 微信支付

await weixinShare(shareInfo) // 微信分享

await getWxAddress() // 获取微信地址

音频类

import AudioPromise from 'ivy-fe/audioPromise'

let audio = new AudioPromise(this.detail.audioUrl,
  e => this.updateTime(e), e => this.updateStatus(e))
// return a promise,播放结束时resolve,还可以传入结束时间
audio.play(this.currentTime || 0)
audio.pause()

其他

// 打开app,默认打开了音频App
import openApp from 'ivy-fe/openApp'
openApp()

// 打开弹出层,在addressMod组建内部,可以使用close属性关闭弹出层,也可以在外部使用closeAll关闭所有弹出层
import showDiv, {closeAll} from 'ivy-fe/showDiv'
await showDiv(addressMod, {receiveInfo: this.receiveInfo})
closeAll()

// 打开注册框
import showBindPhone from 'ivy-fe/showBindPhone'
showBindPhone()
// 手机绑定之后,如果前面store使用了ivyStore,登陆信息会放到全局store里,

配置

  • 多个项目中复用的配置放到此公共包
  • webpack配置主要包括后端代理
  • config主要包括appid,以及一些跳转