修复可能导致渲染进程无响应的问题

pull/277/head
lyswhut 2020-05-08 20:23:23 +08:00
parent 26bdf25423
commit 16903b0f5a
2 changed files with 4 additions and 5 deletions

View File

@ -32,7 +32,9 @@ global.envParams = parseEnv()
app.commandLine.appendSwitch('wm-window-animations-disabled')
// https://github.com/electron/electron/issues/18397
app.allowRendererProcessReuse = true
// 开发模式下为true时 多次引入native模块会导致渲染进程卡死
// https://github.com/electron/electron/issues/22791
app.allowRendererProcessReuse = !isDev
app.on('web-contents-created', (event, contents) => {

View File

@ -63,11 +63,9 @@ const buildHttpPromose = (url, options) => {
}).then(ro => {
obj.requestObj = ro
if (obj.isCancelled) obj.cancelHttp()
console.log(obj.requestObj, obj.isCancelled)
})
})
obj.cancelHttp = () => {
console.log('cancel: ', obj)
if (!obj.requestObj) return obj.isCancelled = true
obj.cancelFn(new Error(requestMsg.cancelRequest))
cancelHttp(obj.requestObj)
@ -86,7 +84,7 @@ const buildHttpPromose = (url, options) => {
export const httpFetch = (url, options = { method: 'get' }) => {
const requestObj = buildHttpPromose(url, options)
requestObj.promise = requestObj.promise.catch(err => {
console.log('出错', err)
// console.log('出错', err)
if (err.message === 'socket hang up') {
// window.globalObj.apiSource = 'temp'
return Promise.reject(new Error(requestMsg.unachievable))
@ -101,7 +99,6 @@ export const httpFetch = (url, options = { method: 'get' }) => {
return Promise.reject(err)
}
})
console.log(requestObj)
return requestObj
}