feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -233,6 +233,17 @@ const runUniNavigation = (
|
||||
return promise;
|
||||
};
|
||||
|
||||
const runUniNavigationAfterCurrent = (key, invoke) => {
|
||||
if (!navigationInFlight) return runUniNavigation(key, invoke);
|
||||
if (navigationInFlight.key === key) return navigationInFlight.promise;
|
||||
|
||||
const currentPromise = navigationInFlight.promise;
|
||||
return currentPromise.then(
|
||||
() => runUniNavigationAfterCurrent(key, invoke),
|
||||
() => runUniNavigationAfterCurrent(key, invoke),
|
||||
);
|
||||
};
|
||||
|
||||
const asNavigationPromise = (execute) => {
|
||||
try {
|
||||
return execute();
|
||||
@@ -494,6 +505,18 @@ export const goRoot = (routeKey, params = {}) =>
|
||||
uni.reLaunch({ url, ...callbacks }));
|
||||
});
|
||||
|
||||
export const recoverToAuthRoot = () =>
|
||||
asNavigationPromise(() => {
|
||||
const route = getRoute("A01");
|
||||
const url = buildValidatedRouteUrl("A01", route, Object.freeze({}));
|
||||
if (isCurrentTarget("A01", {})) return Promise.resolve(false);
|
||||
|
||||
// 401 可能在上一场页面转场仍持锁时返回。普通点击可以被去重,登录恢复不能
|
||||
// 被静默丢弃,因此等待当前转场收尾后再重置页面栈。
|
||||
return runUniNavigationAfterCurrent(`recovery-root:${url}`, (callbacks) =>
|
||||
uni.reLaunch({ url, ...callbacks }));
|
||||
});
|
||||
|
||||
export const openNoticeTarget = (targetType, params, sourceKey = "N02") =>
|
||||
asNavigationPromise(() => {
|
||||
assertScalarString("通知目标类型", targetType);
|
||||
|
||||
Reference in New Issue
Block a user