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

gm-utils

v3.0.2

Published

冠美小程序前端api库

Downloads

26

Readme

gm-apis gm-utils 冠美-阿里小程序API函数库

介绍

冠美-阿里小程序API函数库,从 阿里小程序渐进框架 框架中分离出来,定位为函数库,封装常用方法、云函数以及工具函数。

文档查看【语雀】

安装

npm i gm-apis -s or

npm i gm-utils -s

或者小程序开发工具依赖选项卡进行安装

1

初始化

app.js文件头部你需要加这两行代码,框架就开始运作了

import gmApi from "gm-apis";
let apis = gmApi({
    env:'test'
});

示例

下面是完整的app.js文件示例

import gmApis from "gm-apis";
// import myApi from "./myApi"; //自己定义和项目具体业务相关的云函数

let apis = gmApis({//config
  env:"test",    //当前环境 test | online ,切换环境这个字段必改,
  envs:{
    //根据上面env判断对应配置,并深度合并到config
    "test":{
        //测试环境的配置
        appUrl:"https://m.duanqu.com?_ariver_appid=3000000003651171&nbsv=0.1.2004151741.2&nbsource=debug&nbsn=DEBUG",
    },
    "online":{
        //正式环境的配置
        appUrl:"https://m.duanqu.com?_ariver_appid=3000000003651171"
    }
  },
  
  //店铺配置信息 涉及入会地址
  shop:{
    shopId: "106564654",
    sellerId:"1818112088",
  },
    //涉及分享信息和相关api
  share:{
      //https://miniapp.open.taobao.com/docV3.htm?docId=118909&docType=1
      title:"",
      desc:"",
      imageUrl:"",
      // url 地址信息在会在相关函数中动态生成,所以这里不用设置
  },
  debug: false,//是否开启框架内的log调试信息 apis.util.log apis.util.warn
  isAutoLoading: true, //是否开启调云函数自动显示loading
  
  //数据库配置 影响相关函数:apis.$init apis.$save apis.$get apis.$set 等
  activityId: "",  //不配置或字符串为空 默认为 "default"
  isAutoInitICSS: true, //是否自动创建页面配置数据库表和索引 默认表名 icss 建议设置test环境下开启,online环境手动创建表和索引 或者在online环境下执行apis.ICSSInit(true);创建表格和索引
  ICSSTableName: 'icss' //页面配置数据表名
});


// apis.addAPI(myApi) //来自引入文件myApi

// apis.config 为配置信息(根据环境会自动切换)
// 云函数也会根据环境自动切换 
//apis可以放入到App配置中如:
App({
  apis,//页面和组件 可以获取  let apis = getApp().apis;
  onLaunch(options) {
  },
  onShow(options) {
  },
  //...
});

下面是完整的myApi.js文件示例(自己定义和项目具体业务相关的云函数)

export default (apis) => {
    
    const { fn, f, fetchData, fetchMessage, config, dateFormat } = apis;
    //config 为配置信息
    //console.log("apis", apis)


    let myApis = {
        async activityGet(){
            return await f("activity.activityGet", {activityId: apis.config.activityId});
        },
        //...
    };

    //在外部apis对象可以调用 apis.activityGet

    return myApis
}

调试

部分函数支持在开发者工具中调用调试

2