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

@fastweb/linkup

v1.0.0-beta.72

Published

#### 设置运行环境

Downloads

41

Readme

基础用法

设置运行环境

linkUp.setEnv({
  env: '1', //1 为H5 2为小程序
  __linkUpRuntime: 'TR' //环境有 TR 三方 QA PRE ONLINE
});

初始化

e.g.

const im = linkUp.trDrugStore({
  owner: {
    userId: '98225514'
  },
  appInfo: 'GY'
});

说明

linkUp.trDrugStore为 IMSDK 初始化方法

参数说明

| 参数名 | 默认值 | 说明 | | -------------- | ------ | ----------------------------------------------------- | | owner.userId | 无 | userId由服务端获取 初始化时传入 | | appInfo | 无 | 规定字符串 用来识别三方用户 初始化时传入 例如国药GY |

方法

closeCore() 关闭 IM

e.g.

im.closeCore();
getwsStatus() 获取 IM 状态

e.g.

im.getwsStatus();
linkUp.api.getHistory({ groupId, start, limit, startServerMsgId }) 异步方法 获取 IM 状态

e.g.

linkUp.api.getHistory({ groupId, start, limit, startServerMsgId }).then(r => {
  r ==
    {
      data: [
        {
          serverMessageId: 1566474238400,
          clientMsgId: 1566474238400,
          createDate: 1566474238400,
          group: {
            groupId: 94881,
            type: 1,
            avatar: 'http://static.qa.91jkys.com/index/478d5744-81c2-4cca-aa10-e4db1298d077.png',
            title: '测试',
            subTitle: '点点滴滴',
            date: 1566474238400
          },
          owner: {
            userId: 98215506,
            userName: '所属',
            userAvatar: 'http://static.qa.91jkys.com/index/478d5744-81c2-4cca-aa10-e4db1298d077.png'
          },
          messageInfo: {
            type: 'Text',
            body: {
              text: 'ZZZZZ'
            }
          }
        }
      ]
    };
});
uploadImg(fd) 异步方法 上传图片 fd 为 formdata

e.g.

if (!window.FormData) {
  //不支持formdata的不支持哦
  return;
}
let upload = this.$refs.imgUploader;
const file = upload.files[0]; // File对象
if (!file) {
  // 用户取消了本次操作
  return;
}
let { size } = file;
let fd = new FormData();
fd.append('file', file);
let res = await linkUp.api.uploadImg(fd);
const { fullPath } = res.data.result;
linkUp.api.getGroupMessage({ groupId, ownerId }) 异步方法 获取当前聊天组信息(用户信息和医生信息)

e.g.

linkUp.api.getGroupMessage({ groupId, ownerId }).then(res => {
  res ==
    {
      result: {
        doctor: {
          modified: 1560416726000,
          nickName: '杨振环医生',
          ownerName: '杨振环医生',
          uType: 1,
          uid: 49522775
        },
        user: {
          avatar: 'http://baidu.com/avatar/30310601_avatar.png',
          nickName: '董蔚来',
          ownerName: '董蔚来',
          uType: 2,
          uid: 30310601
        }
      },
      ok: true,
      error: {}
    };
});
getAllGroupList() 异步方法 获取所有聊天组 List[暂不支持]

e.g.

im.getAllGroupList({
  uid: 'xxx'
}).then(r => {
  //结果待定
});
sendMessage() 异步方法 发送消息

e.g.

async function sendMsg() {
  let res = await im.sendMessage({
    group: {
      groupId: '92821' //当前聊天组ID
    },
    messageInfo: {
      type: 'Text',
      body: {
        text: 'hello'
      }
    }
  });
  if (res) {
    //消息发送成功
  } else {
    //消息发送失败
  }
}

sendMsg();

| 方法名 | 说明 | 是否异步 | | ---------------------- | ------------------------------------------------------------------------------- | -------- | | im.getwsStatus | 0 连接中 1 打开 2 关闭中 3 已关闭 | 否 | | im.closeCore | 调用后关闭 socket | 否 | | im.api.getHistory | 异步方法返回聊天历史记录 | 是 | | im.api.uploadImg | 参数类型待定 返回值为图片 url | 是 | | im.api.getGroupMessage | 异步方法 参数类型待定 返回值为用户信息和医生信息 | 是 | | im.api.getAllGroupList | 异步方法 参数类型待定 返回值为所有聊天组 List | 是 | | im.sendMessage | 发送客户端消息给服务端 返回值为true时表示消息发送成功 false表示消息发送失败 | 是 |

事件

connecting IM 连接中

e.g.

im.trpubsub.on('connecting', () => {});
LoginSuccess IM 登录成功

e.g.

im.trpubsub.on('LoginSuccess', () => {
  console.log('登录成功');
});
close IM 关闭

e.g.

im.trpubsub.on('close', () => {
  console.log('IM已断开');
});
message 接收消息

e.g.

im.trpubsub.on('message', ms => {
  console.log(ms, 'immessage');
});

| 事件名 | 默认值 | 说明 | | ------------ | ------ | ------------------------------------------------------------ | | LoginSuccess | 无 | 登录成功后会执行 所有用户操作需要在用户登录完成后进行 | | close | 无 | IM 断开后会执行 | | message | 无 | 回调函数第一个参数为消息内容 只返回用户消息 系统消息不会推送 | | connecting | 无 | 连接中时会进行调用 |

消息

| 消息类型 | type | 是否需要接收 | 是否需要实现发送 | 说明 | | ------------ | ---------- | ------------ | ---------------- | ------------------------- | | 文本消息 | Text | 是 | 是 | - | | 图片消息 | Image | 是 | 是 | 需要调用图片上传 后再发送 | | 系统文本消息 | SysText | 是 | 否 | - | | 富文本 | RichText | 是 | 否 | - | | 富链接 | RichLink | 是 | 否 | - | | 结束咨询消息 | Finish | 是 | 否 | - |

!> 客户端没有实现的消息类型 请提示暂不支持该数据类型

文本消息
        {
          type: 'Text',//Text 必须首字母大写
          body: {
            text: 'hello',//文本内容
          },
        }
系统文本消息
        {
          type: "SysText",//消息类型
          body: {
            text: "abcd",//消息内容
          },
        }
富文本消息
        {
          type: "RichText",//消息类型
          body: {
            text: "abcd", // 富文本,文本内容
            imageList: ["http://abc/def.jpg", "http://abc/ghi.jpg"], // 富文本,图片url数组
          },
        }
图片类消息
        {
          type: "Image",//消息类型
          body: {
            thumbnail: "http://abc/abc_thumbnail.jpg",
            fileUrl: "http://abc/abc.jpg",
            fileSize: 1024,
          }
        }
语音类消息
        {
          type: "Audio",//消息类型
          body: {
            fileUrl: "http://abc/def.wav",
            audioLength: 15,
          }
        }
富链接类消息
        {
          type: "RichLink",//消息类型
          body: {
              // 链接地址
              linkAddress: "http://www.google.com",
              // 标题
              linkTitle: "谷歌首页",
              // 副标题
              linkDetail: "详情描述",
              // 链接图片
              linkImg: "http://abc/kkk.png"
            }
        }
指导模板类消息
        {
          type: "Template",//消息类型
          body: {
              title: "指导模板标题",
              desc: "指导模板详情描述",
              imIconImg: "http://abc/iii.png"
              templateId:11
          },
        }
结束咨询消息
        {
          type: "Finish",//消息类型
          body: {
            text: "本次咨询已结束"
          },
        }
等待无回应消息
        {
          type: "FinishNoReply",//消息类型
          body: {
            text: "当前咨询医生暂无回复,建议更换医生咨询"
          },
        }