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

@tapd/tapd-open-js-sdk

v3.24.0

Published

tapd js sdk for open platform

Downloads

54

Readme

Open TAPD JS SDK 🐶🐶

🐶 🐶 🐶 🐶 🐶 🐶 🐶 🐶 🐶 🐶 🐶 🐶 🐶 🐶

使用


// 这里需要做设配
import SDK from "@tencent/tapd-open-js-sdk";

const sdk = SDK();

sdk.events.on('event from ', function(data){
  return 'world'; // return to tapd
})

sdk.handler('handle name', {
  hello: 'world', // You param to you service
})

sdk.navigator.openAppIndex('rul')

sdk.ui.openDialog({url: 'tencent.com'})

API

ui

.alert(message: string)

调用tapd的消息提示组件

sdk.ui.alert('Hello World')

.confirm(message: string) => Promise

调用TAPD侧的确认框。

sdk.ui.confirm('来个点赞3连?')
  .then(() => {
    alert('THX 😍')
  })

.closeDialog

关闭弹窗

sdk.ui.closeDialog()

.openDialog(params)

调用TAPD侧弹框

sdk.ui.openDialog(params)

参数:params

title: string

弹窗标题

url: string

弹窗URL

height: number

高度

width: number

宽度

showBtn: boolean

是否显示确认按钮

btnYesText: string

确认按钮文本

btnNoText: string

取消按钮文本

.resizeDialog(width: number, height: number)

调整弹框大小

sdk.ui.resizeDialog(300, 400)

handler

.handler(handlerName: string, params = {}) => Promise <res>

function调用。

参数

handlerName: 接口名

params: 传递给接口的参数。只支持普通对象

返回

res: 接口返回

sdk.handler('story', {id: 'tsets'});

navigator

.openAppIndex(url: string)

于TAPD侧打开调用sdk的嵌入应用新的页面。url 为嵌入应用的路由。

sdk.navigator.openAppIndex('/about')

.openObjectWindow(params: { entityType: string, entityId: string })

打开TAPD业务对象的详情页(目前只支持需求,任务,缺陷)

sdk.navigator.openObjectWindow({entityType: 'story', entityId: '123'})

.syncUrl(options: {url: string, refresh: bolean})

更新当前浏览器的路由,一般用于同步嵌入应用路由与浏览器路由

sdk.navigator.syncUrl({url: 'http://tapd.oa.com/', refresh: false})

参数

url: 目标路由

refresh: 跟新路由后是否刷新页面

context

.getEntranceData() => Promise <entranceConfigs >

获取当前页面嵌入TAPD的配置信息

const entranceConfigs = await sdk.context.getEntranceData() // return {appId, entranceId, code}

返回 entranceConfigs

appId: 应用ID

code: tapd Token,

entranceId: 挂载点ID

.refreshCode() => Promise <code>

跟新tapd授予码code,一般用于授权码过期

const newCode = await sdk.context.refreshCode()

iframe

.syncPageEvent(params: {entranceId: string, data: any}) => Promise

当在TADP的页面中有多个挂载点页面,可以通过这个方法在不同挂载点间通信

sdk.iframe.syncPageEvent({
  entranceId: 'app_for_obj_detail_bottom_card',
  data: {
    msg: '下次一定'
  }
})

.setPageHeight(height: number)

调用应用在TAPD侧的高度

sdk.iframe.setPageHeight(400)

command

.refreshAttachmentList()

当嵌入应用页面在tapd的业务对象(需求,任务,缺陷)详情页面,将更新页面里的附件列表

sdk.command.refreshAttachmentList()

.showObjDetailBottomCard()

当嵌入应用页面在tapd的业务对象(需求,任务,缺陷)详情页面, 可以唤起挂在类型为 app_for_obj_detail_bottom_card 的挂载页面

sdk.command.showObjDetailBottomCard()

request

.getUserListByKeyWords(params: {key_word: string, workspace_id: string, per_page: number}, configs: {timeout: number }) => Promise <response>

调用tapd侧的人名搜索接口

sdk.request
  .getUserListByKeyWords({
    key_word: 'tom',
    workspace_id: '1'
  })
  .then((response) => {
    console.log(response)
  })

返回 response

data: Array

用户列表

keyword: String

搜素的关键字

.getWorkspaceMemberList(params: {workspace_id: string,page_size: number, page: number }) => Promise<response>

调用TAPD侧获取项目下人员名单接口。

sdk.request
  .getWorkspaceMemberList({
    page_size: 100,
    workspace_id: '1',
    page: 1
  })
  .then((response) => {
    console.log(response)
  })

返回 response

data: Array

成员列表

count: String

总人数

.getAllRelateMember(params: object}) => Promise

获取对象相关成员名单

sdk.request.getAllRelateMember({
  workspace_id: '755',
  entity_type: 'bug',
  entity_id: '1000000755089798713',
  include_self: 1
  include_relate_story_member: 0
  include_sub_story_member: 0
})
.then((res) => {
  alert(res, ' 😍')
})

参数 params:

workspace_id: string

tapd 项目ID

entity_type: string

资源类型: story|bug|task

include_self: 0 | 1

是否包括用户

include_relate_story_member: 0 | 1

是否包含关联需求

include_sub_story_member: 0 | 1

是否包含子需求

event

.on(event: string, cb: data => res, config: {once: bolean})

监听来着TADP测的事件。

参数:

event: 事件名

cb: 回调函数,参数为接受的数据,当在函数中返回数据时,将会把返回的数据发回给TAPD

once: 是否只监听一次

sdk.event.on('ConfirmYes', function() {
  return {
    id: 'target Objct ID'
  }
}, {
  once: true
})