提交 19b13028 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat: app onError 监听

上级 2462bfdf
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
path: '' path: ''
} as OnShowOptions } as OnShowOptions
}, },
onLaunch: function (res : OnLaunchOptions) { onLaunch: function (res : OnLaunchOptions) {
this.globalData.launchOptions = res this.globalData.launchOptions = res
...@@ -45,37 +45,37 @@ ...@@ -45,37 +45,37 @@
// ) // )
// observer1.observe({ // observer1.observe({
// entryTypes: ['render', 'navigation'], // entryTypes: ['render', 'navigation'],
// } as PerformanceObserverOptions) // } as PerformanceObserverOptions)
// 统计上报 - 应用启动 // 统计上报 - 应用启动
// #ifdef APP-ANDROID || APP-IOS || WEB // #ifdef APP-ANDROID || APP-IOS || WEB
// uni.report({ // uni.report({
// name: 'uni-app-launch', // name: 'uni-app-launch',
// options: res, // options: res,
// success(res_data) { // success(res_data) {
// console.log(res_data); // console.log(res_data);
// }, fail(err) { // }, fail(err) {
// console.log(err); // console.log(err);
// } // }
// }) // })
// #endif // #endif
// #ifdef APP // #ifdef APP
if (process.env.NODE_ENV !== 'development') { //真机运行可以注释此条件 if (process.env.NODE_ENV !== 'development') { //真机运行可以注释此条件
uni.getPrivacySetting({ uni.getPrivacySetting({
success(res1){ success(res1){
if(res1.needAuthorization){ if(res1.needAuthorization){
uni.openDialogPage({ uni.openDialogPage({
url: '/pages/component/button/privacy', url: '/pages/component/button/privacy',
}) })
} }
} }
}) })
} }
// #endif // #endif
}, },
onShow: function (res : OnShowOptions) { onShow: function (res : OnShowOptions) {
this.globalData.onShowOption = res this.globalData.onShowOption = res
// 处理scheme或通用链接直达 // 处理scheme或通用链接直达
let url = this.getRedirectUrl(res.appScheme, res.appLink); let url = this.getRedirectUrl(res.appScheme, res.appLink);
if (null != url) { if (null != url) {
...@@ -86,35 +86,35 @@ ...@@ -86,35 +86,35 @@
// 自动化测试 // 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100) setLifeCycleNum(state.lifeCycleNum + 100)
console.log('App Show') console.log('App Show')
// #ifdef APP-ANDROID || APP-IOS || WEB // #ifdef APP-ANDROID || APP-IOS || WEB
// 统计上报 - 应用显示 // 统计上报 - 应用显示
// uni.report({ // uni.report({
// name: 'uni-app-show', // name: 'uni-app-show',
// success(res_data) { // success(res_data) {
// console.log(res_data); // console.log(res_data);
// }, fail(err) { // }, fail(err) {
// console.log(err); // console.log(err);
// } // }
// }) // })
// #endif // #endif
}, },
onHide: function () { onHide: function () {
// 自动化测试 // 自动化测试
setLifeCycleNum(state.lifeCycleNum - 100) setLifeCycleNum(state.lifeCycleNum - 100)
console.log('App Hide') console.log('App Hide')
// #ifdef APP-ANDROID || APP-IOS || WEB // #ifdef APP-ANDROID || APP-IOS || WEB
// 统计上报 - 应用进入后台 // 统计上报 - 应用进入后台
// uni.report({ // uni.report({
// name: 'uni-app-hide', // name: 'uni-app-hide',
// success(res) { // success(res) {
// console.log(res); // console.log(res);
// }, fail(err) { // }, fail(err) {
// console.log(err); // console.log(err);
// } // }
// }) // })
// #endif // #endif
}, },
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
...@@ -138,22 +138,23 @@ ...@@ -138,22 +138,23 @@
}, },
onExit() { onExit() {
console.log('App Exit') console.log('App Exit')
}, },
// onError(err : any) {
// // #ifdef APP-ANDROID || APP-IOS || WEB
// // 统计上报 - 应用发生错误
// uni.report({
// name: 'uni-app-error',
// options: err,
// success(res) {
// console.log(res);
// }, fail(err) {
// console.log(err);
// }
// })
// // #endif
// },
// #endif // #endif
onError(err : any) {
console.log('App onError', err)
// // #ifdef APP-ANDROID || APP-IOS || WEB
// // 统计上报 - 应用发生错误
// uni.report({
// name: 'uni-app-error',
// options: err,
// success(res) {
// console.log(res);
// }, fail(err) {
// console.log(err);
// }
// })
// // #endif
},
methods: { methods: {
increasetLifeCycleNum() { increasetLifeCycleNum() {
setLifeCycleNum(state.lifeCycleNum + 100) setLifeCycleNum(state.lifeCycleNum + 100)
...@@ -205,4 +206,4 @@ ...@@ -205,4 +206,4 @@
background-color: #fff !important; background-color: #fff !important;
} }
/* #endif */ /* #endif */
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册