@szgc/plt-core
安装
npm i @szgc/plt-core -S
初始化
为方便使用,在 webpack 打包通过 provider 插件已为全局加入 plt 变量。业务开发时直接通过 plt 对象即可访问平台 api 库
new webpack.ProviderPlugin({
plt: "@szgc/plt-core"
});
request 初始化
plt.request.init({
config?: AxiosRequestConfig; // axios请求参数配置
reqFilter?: Filter<AxiosRequestConfig>; // 请求拦截器
resFilter?: Filter<AxiosResponse>; // 响应拦截器
onFetchStart?: (...args: any) => any; // 批量请求开始回调
onFetchEnd?: (...args: any) => any; // 批量请求结束回调
onUnauthorized?: (...args: any) => any; // 为授权回调
});
websocket 初始化
// 直接调用平台初始化参数
// 初始化完成后,可通过plt.socket对象对socket对象进行操作
// plt.socket._client对象为Stomp.Client实例
plt.useSocket();
Api 说明
Api | 说明 |
---|---|
plt.request | 平台请求。支持批量请求,以数组的方式返回每个请求的结果 |
plt.socket | 平台 socket 对象 |
plt.useSocket | 平台开启 websocket 功能,默认是未开启的 |
plt.trim | 去掉字符串首尾空格 |
plt.dateFormat | 日期格式化,参照 moment 的格式化方案实现 |
plt.guid | 平台前端唯一 ID, 时间戳 + 5 位随机整数 |
plt.uuid | 生成 18 位 uuid,格式:8-4-4-4-12 |
plt.base64Encode | 字符串转 BASE64 编码 |
plt.base64Decode | BASE64 编码转字符串 |
plt.setCookie | 设置 Cookie |
plt.getCookie | 获取 Cookie |
plt.removeCookie | 移除 Cookie |
plt.setStorage | 设置某个 LocalStorage 存储 |
plt.getStorage | 获取某个 LocalStorage 存储 |
plt.removeStorage | 移除某个 LocalStorage 存储 |
plt.md5 | 对字符串进行 MD5 加密 |
plt.current | 平台登录用户信息 |
plt.login | 平台账号密码登录 |
plt.loginWithEmail | 平台邮箱验证码登录 |
plt.loginWithMobile | 平台手机验证码登录 |
plt.logout | 平台登出 |
plt.loadLoginCurrent | 获取 session 中当前登录用户信息 |
... | ... |
UI 组件
- plt.ui.Pdf Pdf 预览组件
- Props
- src {string} PDF 地址
- needText {boolean} 是否需要渲染文本,默认 false
- Props