App.vue
@@ -8,6 +8,7 @@
        getUserInfo
    } from "./utils/auth";
    import getuiUtils from "./utils/getuiUtils";
    import { overrideUniRequest, cancelAllRequest } from './utils/RequestQueue'
    export default {
        onLaunch: function() {
            console.log('App Launch')
@@ -69,6 +70,12 @@
                }
            }, false);
            // #endif
            overrideUniRequest()
            // 路由跳转时取消所有请求
            this.setupRouteInterceptor()
        },
        onShow: function() {
            console.log('App Show')
@@ -98,6 +105,23 @@
                        }
                    });
                }, 300)
            },
            setupRouteInterceptor() {
                const methods = [
                    'navigateTo',
                    'redirectTo',
                    'navigateBack',
                    'switchTab',
                    'reLaunch'
                ]
                methods.forEach((m) => {
                    uni.addInterceptor(m, {
                        invoke() {
                            cancelAllRequest()
                        }
                    })
                })
            }
        }
    }