1.0.9 • Published 3 years ago

weeget-hybird-js-sdk v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago
  1. 安装
npm i weeget-hybird-js-sdk -S
  1. 引入
// hybrid.ts文件
import DispatchHybirdMethod from 'weeget-hybird-js-sdk';

// 初始化
const hybirdMessage = new DispatchHybirdMethod({
  client: 'h5',
  appKey: import.meta.env.VITE_APP_SIGN_KEY, // appKey 可以与APP同学获取
});

const createHybirdMethod = (type: string, params: object) => {
  return new Promise((reslove) => {
    hybirdMessage
      .sendEvent(type, params)
      .then((res: any) => {
        reslove(res);
      })
      .catch((err: any) => reslove(err));
  });
};

export const getLoginInfo = () => createHybirdMethod('loginEvent', {});

export const jumpEventHander = (params: any) => createHybirdMethod('jumpEvent', params);

export default {
  getLoginInfo,
  jumpEventHander,
};

使用

  • 获取用户信息
import { getLoginInfo } from './hybrid'
getLoginInfo().then(res => {
  console.log('获取用户信息:', res)
})