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

vk-unicloud-page

v1.17.8

Published

【前端SDK】VK云函数路由模式uniCloud开发框架,在你的项目根目录执行npm命令:npm i vk-unicloud-page 进行安装和升级

Downloads

178

Readme

作者:VK

更新时间:2020-07-22

极简安装步骤

在你的项目根目录执行npm命令:npm i vk-unicloud-page 进行安装

  1. npm方式安装
npm i vk-unicloud-page
  1. main.js引入vk-unicloud-page库
// main.js
import vk from 'vk-unicloud-page';
Vue.use(vk);

this.vk.callFunction函数的参数说明

/**
 * 云函数请求封装 - 统一入口
 * @description 通过云函数路由,1个云函数实现多个云函数的效果。
 * @params {String}   url       请求路径,该路径实为router云函数的service目录下的路径
 * @params {Object}   data      请求参数
 * @params {String}   title     遮罩层提示语,为空或不传则代表不显示遮罩层。
 * @params {Boolean}  isRequest 是否使用云函数url化地址访问云函数,默认false
 * @params {Boolean}  noAlert   为true代表请求错误时,不会有弹窗提示。默认为false
 * @params {Function} success   请求成功时,执行的回调函数
 * @params {Function} fail      请求失败时,执行的回调函数
 * @params {Function} complete  无论请求成功与否,都会执行的回调函数
 */

普通方式调用云函数示例


this.vk.callFunction({
	url: 'user/kh/setAvatar',
	title:'请求中...',
	data:{
		avatar: "https://xxxxxxx.jpg"
	},
	success(data) {
		// 修改成功
	}
});

云函数url化方式调用云函数示例

isRequest:true 代表使用url访问云函数,一般用于PC后台管理页面使用

this.vk.callFunction({
	url: 'user/kh/setAvatar',
	title:'请求中...',
	isRequest:true,
	data:{
		avatar: "https://xxxxxxx.jpg"
	},
	success(data) {
		// 修改成功
	}
});

注意:云函数url化方式调用需要配置你的云函数url路径地址

main.js 在代码Vue.use(vk); 的下方添加

// 自定义云函数路由配置
Vue.prototype.vk.callFunctionUtil.setConfig({
    // 云函数路由(主函数url化地址)
    functionPath:"https://xxxxx.bspapp.com/http/router",
    // 云函数路由(开发测试函数url化地址)
    testFunctionPath:"https://xxxxx.bspapp.com/http/router-test",
});

前端非法token拦截器

main.js 在代码Vue.use(vk); 的下方添加

// 自定义token拦截器
Vue.prototype.vk.callFunctionUtil.interceptor.login = (obj = {}) =>{
	let {params, res} = obj;
	// 下方代码可自己修改,写成你自己的逻辑处理。
	if(!params.noAlert){
		Vue.prototype.vk.alert(res.result.msg);
	}
	console.log("跳自己的登录页面");
	// 上方代码可自己修改,写成你自己的逻辑处理。
};

如何切换正式环境和开发环境

main.js 在代码Vue.use(vk); 的下方添加

// 自定义云函数路由配置
Vue.prototype.vk.callFunctionUtil.setConfig({
	// 是否开启测试环境,true:使用测试环境,false:使用正式环境,默认true
  isTest:true
});