1.2 KiB
1.2 KiB
@zhst/slave
介绍
供微前端应用使用的公共方法
安装
pnpm install @zhst/slave
使用
import React from 'react';
import slave from '@zhst/slave'
export default () => {
const handleInit = () => {
slave.init({
jumpUrl: `http://10.0.0.222:30058/metarial/login`,
to: 'http://www.baidu.com',
jumpToLogin: false,
tokenKey: 'token',
})
}
return (
<button onClick={handleInit} >测试</button>
)
}
API
参数 | 说明 | 类型 | 默认值 | 版本 |
---|---|---|---|---|
jumpToLogin | 是否打开登录校验跳转 | boolean | true | - |
jumpUrl | 登录跳转页面 | string | - | - |
tokenKey | 从链接获取的登录校验字段 | string | token | - |
showMsg | 是否显示“请先登录”提示框 | boolean | true | - |
msgText | 提示框自定义文案 | string | 请先登录 | - |
from | 来自哪个链接(可选) | string | - | - |
to | 准备去的链接(可选) | string | - | - |
slave 实例方法
方法 | 说明 | 类型 | 默认值 | 版本 |
---|---|---|---|---|
init | 初始化实例 | function | (data: SlaveProps) => void | - |
logOut | 退出登录 | function | () => void | - |