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

toca-sdk

v2.1.3

Published

toca mina sdk

Downloads

2

Readme

1. 引入包 tock-sdk (1.0.8)

npm install toca-sdk

2. 如何使用

示例:获取当前用户

import sdk from 'toca-sdk';

const account = new sdk.Account();
account.getCurrentUser().then(user => {
    //当前用户信息
}).catch(err => {
    console.log('获取用户信息失败')
})

3. 接口列表

实例方法

| 类名 | 方法 | 请求参数 | | ------- | ------------------------ | -------------------------------- | | Account | getCurrentUser() | 获取当前用户 | | Account | getToken() | 获取 Token | | Network | request(options) | 发起请求 | | Network | get(url, headers) | 发起 get 请求 | | Network | post(url, data, headers) | 发起 post 请求 | | Network | put(url, data, headers) | 发起 put 请求 | | Network | del(url, headers) | 发起 delete 请求 | | Network | head(url, headers) | 发起 head 请求 | | Network | options(url, headers) | 发起 options 请求 | | System | navigate(name) | 导航到指定位置 | | System | openExternal(url) | 使用外部默认浏览器打开指定的 URL | | System | openNewApp(app) | 打开一个新的 App |

事件

| 对象 | 事件 | 说明 | | --------------- | ------- | ---------------------------- | | webviewToRender | ready | 当前页面已就绪时,触发的回调 | | webviewToRender | message | 宿主窗口发送的消息 |

静态方法

| 类名 | 方法名 | 参数 | 返回值说明 | | ----------- | ------------ | ---- | ------------------------------------ | | Environment | isInElectron | 无 | bool 类型,true 表示在 electron 环境 |

==注意: 调用任何 实例化 API 之前,需要确保窗口已经就绪。==

示例:在 Vue 页面加载时,获取用户信息


<script>
import sdk from 'toca-sdk';
export default {
    created() {
        sdk.webviewToRender.on('ready', () => {
            const account = new sdk.Account();
            account.getCurrentUser().then(user => {
                // 当前登录的用户信息
            }).catch(err => {
                // 获取用户信息出错
            });
        });
    }
}

</script>

4. 接口参数说明

类型 System

方法: navigate(name) 导航到指定的位置

参数说明:

| 参数 | 类型 | 说明 | | ---- | ------ | ----------------------------------------------------------------- | | name | string | 已有的 App 的名称,当前的名称有 Network、ShareScreen、Varys、Mine |

方法: openExternal(url) 使用默认浏览器,打开给定的 URL

参数说明:

| 参数 | 类型 | 说明 | | ---- | ------ | ----------------------------- | | url | string | 网址,例如 https://www.ly.com |

方法: openNewApp(app) 打开一个新的应用,如果已经存在,则激活

参数说明:

| 参数 | 类型 | 说明 | | ---- | ------ | ---------------------- | | app | object | 应用程序对象, 如下示例 |

{
    name: 'demo',
    title: '示例程序',
    favicon: 'https://127.0.0.1/static/logo.c3d215c7.png',
    type: 'mina',
    nodeintegration: true,
    version: '1.0.0',
    orig: 'http://10.181.152.213:3000/app.zip'
}