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

txim-plugin

v1.0.4

Published

用于天象文化有限公司用户与客服及其签约老师之前的交流

Downloads

3

Readme

使用方法

引用方法

MVC框架项目直接cdn引用

<link href="https://jsdelivr.txsdk.com/npm/txim-plugin@latest/lib/index.min.css" rel="stylesheet" />
<script src="https://jsdelivr.txsdk.com/npm/txim-plugin@latest/lib/index.min.js" charset="utf-8"></script>

MVVM框架项目使用npm引入

npm install txim-plugin --save
import 'txim-plugin'
import 'txim-plugin/lib/index.min.css'
注:若项目中多次使用,可在入口处调用。或在组件中单独调用

初始化window.txim.init() => (Promise)

引入后即可初始化

window.txim.init({
    SDKAppID: '1400205071',//必填
    mode: 'development'//默认'production'
}).then(res => {
    if(res.status === 1 ) tim实例创建成功
    else tim实例创建失败
})

注: 1.初始化成功后,也可将window.txim注册到vue根实例
    2.如果需要在初始化成功后立即登录,请在回调中调用登录,以免因为异步产生的错误
    3.测试环境下请设置mode为'development':
        正式账户:1400183358(production)
        测试账户:1400205071(development)
    4.tim的创建方法是静态的,不会报错,请仔细检查

登录与打开

window.txim.login() => (Promise)

window.txim.open() => (Promise)

初始化成功的条件下,可在业务需要的地方登录

window.txim.login({
    token: 't4L35Olq7Idf0kLkKdyGfuXvKH2mhJxQ',//必填
    role: 'member'//默认'member'
}).then(res => {
    if(res.status === 1) window.txim.open(options)//登录成功
    else console.log(res.msg)//登录失败
})

注: 1.login方法中token为依附项目的登录access_token
    2.login方法中role为登录角色,可根据需要设置为:'member','teacher','kefu'
    3.login方法重复调用不会重复登录,因此建议将所有的open调用在login回调中,如果成功则调用,失败则自行处理逻辑。当然了,在可以保证login已经成功的情况下,单独调用open也是可以的

window.txim.open(options)传参

options = {
    //隐藏会话列表,默认false
    hideChat: Boonlean,
    //隐藏通讯录,默认false
    hideList: Boonlean,
    //隐藏我的,默认false
    hideMy: Boonlean,
    //宽度,默认100%
    width: Number,
    //高度,默认100%(在设置宽度的情况下才有效,不设的话自动长宽比)
    height: 100%,
    //层级: 默认1
    zIndex: Number,
    //主题颜色,默认'#e35c57'(因为有赞导航栏字体颜色的原因,只能设置较深的主题色)
    theme: Color,
    //会话ID,设置后可直接进入某一会话
    chat: null,
    //直接进入某一会话后,将界面锁定在会话(只有设置chat后才生效)
    limitedInChat: false
}

监听未读信息数量变动

window.txim.addUnreadMessageListener('name',Function)//添加监听事件

window.txim.removeUnreadMessageListener('name')//注销监听事件

事件可以在init后添加或注销,但是只有login成功后才会生效

//添加监听console1
window.txim.addUnreadMessageListener('console1',num => {
    //num为未读消息数,每次更新都会触发以下逻辑代码
    console.log(num)
})
//添加监听console2
window.txim.addUnreadMessageListener('console2',num => {
    //num为未读消息数,每次更新都会触发以下逻辑代码
    console.log(num*10)
})
//注销监听console1
window.txim.removeUnreadMessageListener('console1')

注: 1.如果是MVC框架,页面更新会属性内存栈,可以不用手动注销监听事件,但是在MVVC中,如果为组件添加监听事件,应该在组件注销时,同时注销监听事件,以免逻辑报错

window.txim.logout()退出

正常情况下不需要退出,下次打开时会更快,内容也会自动缓存更新。必要时可使用logout方法退出,退出后需重新login

npm发布

1.npm login登录你的npm账户

2.修改package.json中的version,该"version"字段的格式必须x.x.x符合语义版本控制准则

2.在项目根目录下npm publish