Skip to content

Commit

Permalink
fix web error && fix dds
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyuki committed Sep 30, 2021
1 parent 88c0511 commit cf2cf11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 10 additions & 8 deletions packages/webpack-plugin/lib/runtime/optionProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,23 @@ export default function processOption (
})
// 处理visibilitychange时触发当前活跃页面组件的onshow/onhide
if (inBrowser) {
const errorHandler = function (e, fromVue) {
const errorHandler = function (args, fromVue) {
if (global.__mpxAppCbs && global.__mpxAppCbs.error && global.__mpxAppCbs.error.length) {
global.__mpxAppCbs.error.forEach((cb) => {
cb(e)
cb.apply(null, args)
})
} else if (fromVue) {
throw e
throw args[0]
}
}
Vue.config.errorHandler = function (e) {
return errorHandler(e, true)
Vue.config.errorHandler = (...args) => {
return errorHandler(args, true)
}
window.addEventListener('error', errorHandler)
window.addEventListener('unhandledrejection', event => {
errorHandler(event.reason)
window.addEventListener('error', (event) => {
return errorHandler([event.error, event])
})
window.addEventListener('unhandledrejection', (event) => {
return errorHandler([event.reason, event])
})
document.addEventListener('visibilitychange', function () {
const vnode = global.__mpxRouter && global.__mpxRouter.__mpxActiveVnode
Expand Down
4 changes: 3 additions & 1 deletion packages/webpack-plugin/lib/wxs/wxs-pre-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ module.exports = function (content) {
(property.name === 'constructor' || property.value === 'constructor') &&
!(t.isMemberExpression(path.parent) && path.parentKey === 'object')
) {
path.replaceWith(t.logicalExpression('||', t.memberExpression(path.node, t.identifier('name'), path.node)))
path.replaceWith(t.logicalExpression('||', t.memberExpression(path.node, t.identifier('name')), path.node))
path.skip()
}
}
})
Expand All @@ -82,6 +83,7 @@ module.exports = function (content) {
!(t.isMemberExpression(path.parent) && path.parentKey === 'object')
) {
path.replaceWith(t.memberExpression(path.node, t.identifier('name')))
path.skip()
}
},
CallExpression (path) {
Expand Down

0 comments on commit cf2cf11

Please sign in to comment.