mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-10-09 08:40:06 +08:00
37 lines
710 B
TypeScript
37 lines
710 B
TypeScript
/**
|
|
*
|
|
* @author Ray <https://github.com/XiaoDaiGua-Ray>
|
|
*
|
|
* @date 2023-07-21
|
|
*
|
|
* @workspace ray-template
|
|
*
|
|
* @remark 今天也是元气满满撸代码的一天
|
|
*/
|
|
|
|
/**
|
|
*
|
|
* 路由更新前,取消上一路由所有请求
|
|
*
|
|
* 生命周期示意图:
|
|
* beforeRouteUpdate -> cancelAllRequest -> routeUpdate
|
|
*/
|
|
|
|
import { axiosCanceler } from '@/axios/utils/interceptor'
|
|
|
|
const AppRequestCancelerProvider = defineComponent({
|
|
name: 'AppRequestCancelerProvider',
|
|
setup(_, { expose }) {
|
|
onBeforeRouteUpdate(() => {
|
|
axiosCanceler.cancelAllRequest()
|
|
})
|
|
|
|
expose()
|
|
},
|
|
render() {
|
|
return <div class="app-style-provider"></div>
|
|
},
|
|
})
|
|
|
|
export default AppRequestCancelerProvider
|