feat: migrate app routes and business modules

This commit is contained in:
2026-08-12 18:22:59 +08:00
parent 555aa00043
commit cc706378c2
247 changed files with 28623 additions and 14988 deletions
+31
View File
@@ -0,0 +1,31 @@
const createRequestCancelledError = () => {
const error = new Error('请求已取消')
error.code = 'REQUEST_CANCELLED'
return error
}
// 页面只持有控制器,不依赖各端 RequestTask 的实现差异。
// 新请求会接管控制器;页面卸载时 abort() 会拒绝等待中的 Promise
// 避免已销毁页面继续处理成功回调。
export const createRequestController = () => {
let abortCurrent = null
return {
bind(abortRequest) {
if (typeof abortRequest !== 'function') throw new TypeError('请求中止器必须是函数')
if (abortCurrent) abortCurrent()
abortCurrent = abortRequest
},
release(abortRequest) {
if (abortCurrent === abortRequest) abortCurrent = null
},
abort() {
const abortRequest = abortCurrent
abortCurrent = null
if (abortRequest) abortRequest()
}
}
}
export const isRequestCancelled = (error) => error?.code === 'REQUEST_CANCELLED'
export { createRequestCancelledError }