adminforth 2.13.0-next.27 → 2.13.0-next.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/spa/src/utils.ts +14 -1
- package/package.json +1 -1
package/dist/spa/src/utils.ts
CHANGED
|
@@ -36,7 +36,20 @@ export async function callApi({path, method, body, headers}: {
|
|
|
36
36
|
if (r.status == 401 ) {
|
|
37
37
|
useUserStore().unauthorize();
|
|
38
38
|
useCoreStore().resetAdminUser();
|
|
39
|
-
|
|
39
|
+
const currentPath = router.currentRoute.value.path;
|
|
40
|
+
const homeRoute = router.getRoutes().find(route => route.name === 'home');
|
|
41
|
+
const homePagePath = (homeRoute?.redirect as string) || '/';
|
|
42
|
+
let next = '';
|
|
43
|
+
if (currentPath !== '/login' && currentPath !== homePagePath) {
|
|
44
|
+
if (Object.keys(router.currentRoute.value.query).length > 0) {
|
|
45
|
+
next = currentPath + '?' + Object.entries(router.currentRoute.value.query).map(([key, value]) => `${key}=${value}`).join('&');
|
|
46
|
+
} else {
|
|
47
|
+
next = currentPath;
|
|
48
|
+
}
|
|
49
|
+
await router.push({ name: 'login', query: { next: next } });
|
|
50
|
+
} else {
|
|
51
|
+
await router.push({ name: 'login' });
|
|
52
|
+
}
|
|
40
53
|
return null;
|
|
41
54
|
}
|
|
42
55
|
return await r.json();
|