pps-h5-lib
v1.0.8
Published
this is a qoe project of pps
Downloads
2
Readme
团队公共模块lib
Usage
使用指南指南
npm 使用
- npm install --save pps-h5-lib
提供的工具类以及使用方法:
Application
- import { Application } from 'pps-h5-lib'
- 实现自己项目的 Application mock 和 baseApiUrl必须重写,用来匹配打包环境
import { Application } from 'pps-h5-lib'
export default {
...Application,
mock: true && process.env.NODE_ENV == 'development',
baseApiUrl: process.env.NODE_ENV == 'production' ? (window.location.protocol + '//toutiao.iqiyi.com') : 'http://10.16.171.78:8085',
baseHttpWebUrl: process.env.NODE_ENV == 'production' ? (window.location.protocol + '//static.iqiyi.com/nadou') : (process.env.NODE_ENV == 'qa' ? 'http://nadouh5.iqiyi.com/nadou' : 'http://localhost:8080'),
baseWebUrl: process.env.NODE_ENV == 'production' ? (window.location.protocol + '//static.iqiyi.com/nadou') : (process.env.NODE_ENV == 'qa' ? 'http://nadouh5.iqiyi.com/nadou' : 'http://localhost:8080')
}
- 使用 Application.init()应用项目重写后的 Application ;执行init()后会自动获取用户信息、设备信息;自动发送页面展示pingback
import Application from 'root/common/Application';
Application.pageInfo = {
pingBack: {
rpage: 'template',//产品定义rpage
pageName: 'templatepps'//Grafana实时统计页面PV
}
};
Application.init(() => {
let self = this;
if (Application.appInfo.ppuid) {
self.isLogin = true;
} else {
self.isLogin = false;
}
if (process.env.NODE_ENV == 'development') {
self.isLogin = true;
}
self.init();
});
- Application.appInfo init执行后存取应用用户信息设备信息
appInfo: {
ppuid: '',
authCookie: '',
deviceId: '',
appVersion: '',
'user-agent': window.userAgent,
client_ip: '',
key: '',
deviceType: '',
/**
* 风控侧平台定义
0:其他
1:android(安卓端)
2:ios
3:PCW(PC网页)
4:H5
5: PCA
6: 微信小程序
7: android tv
8: UWP
*/
platform: '',
dfp: '',
appChannel: '',
networkStatus: '',
qyID: '',
sign: '',
timestamp: '',
userIcon: '',
userName: '',
appIdNaDou: 'wx3c55020afc58a8fc',
appIdHaoDUo: 'wx03071aa0b1ab1541',
appIdPPS: 'wx3b61b7eb6946daf5',
},
- Application.browser 存取平台浏览器型号信息如 Application.browser.chrome Application.browser.version
browser: {
qq: /qqbrowser|QQ|QQbrowser/.test(navigator.userAgent),
weixin: /MicroMessenger/i.test(navigator.userAgent),
uc: /ucbrowser|ucweb/i.test(navigator.userAgent),
baidubox: /baiduboxapp/i.test(navigator.userAgent),
baidubrowser: /baidubrowser/i.test(navigator.userAgent),
weibo: /weibo/i.test(navigator.userAgent),
ios_egt_9: /iPhone OS (\d+)/i.exec(navigator.userAgent) && /iPhone OS (\d+)/i.exec(navigator.userAgent)[1] >= 9,
ios_egt_10: /iPhone OS (\d+)/i.exec(navigator.userAgent) && /iPhone OS (\d+)/i.exec(navigator.userAgent)[1] > 9,
qiyinews: /QYNews/.test(navigator.userAgent) && !(/IqiyiApp\/pps/.test(navigator.userAgent)), //爱奇艺头条webview //兼容pps图文详情页打开后两个ua头都有的情况 9.8.5后修复
pps: /IqiyiApp\/pps/.test(navigator.userAgent), //PPSwebview
iqiyiAPP: /IqiyiApp\/iqiyi/.test(navigator.userAgent), //只用来判断是否为爱奇艺系列app内(含头条)
...Detect.browser
}
- Application.os.android Application.os.ios Application.os.version
Api 负责发送ajax的工具类 引用到项目中需要重写根据环境切换baseApiUrl
- _request: function (url, params, option) {} 返回一个promise
- extendParams: object 页面统计信息扩展参数
- consuming: 分别监控用户操作触发的、或者有可能多次被访问的异步请求
- ajax: 监控页面一组 ajax 请求(组件初始化、影响页面展示的请求等)的总耗时
- sampleRate: number{0-100}发送比例 默认%1比例发送
- p1: string 业务线名称
- bc: string 同一个p1下区分字业务线