adminforth 2.13.0-next.26 → 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/App.vue +13 -20
- package/dist/spa/src/utils.ts +14 -1
- package/package.json +1 -1
package/dist/spa/src/App.vue
CHANGED
|
@@ -182,8 +182,6 @@ initFrontedAPI()
|
|
|
182
182
|
|
|
183
183
|
createHead()
|
|
184
184
|
const sideBarOpen = ref(false);
|
|
185
|
-
const defaultLayout = ref(true);
|
|
186
|
-
const headerOnlyLayout = ref(false);
|
|
187
185
|
const route = useRoute();
|
|
188
186
|
const router = useRouter();
|
|
189
187
|
const publicConfigLoaded = ref(false);
|
|
@@ -197,6 +195,14 @@ const isSidebarIconOnly = ref(localStorage.getItem('afIconOnlySidebar') === 'tru
|
|
|
197
195
|
|
|
198
196
|
const loggedIn = computed(() => !!coreStore?.adminUser);
|
|
199
197
|
|
|
198
|
+
const defaultLayout = computed(() => {
|
|
199
|
+
return route.meta?.sidebarAndHeader !== 'none';
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const headerOnlyLayout = computed(() => {
|
|
203
|
+
return route.meta?.sidebarAndHeader === 'headerOnly';
|
|
204
|
+
});
|
|
205
|
+
|
|
200
206
|
const expandedWidth = computed(() => coreStore.config?.iconOnlySidebar?.expandedSidebarWidth || '16.5rem');
|
|
201
207
|
|
|
202
208
|
const theme = ref('light');
|
|
@@ -308,19 +314,6 @@ async function loadMenu() {
|
|
|
308
314
|
loginRedirectCheckIsReady.value = true;
|
|
309
315
|
}
|
|
310
316
|
|
|
311
|
-
function handleCustomLayout() {
|
|
312
|
-
if (route.meta?.sidebarAndHeader === 'none') {
|
|
313
|
-
defaultLayout.value = false;
|
|
314
|
-
} else if (route.meta?.sidebarAndHeader === 'preferIconOnly') {
|
|
315
|
-
defaultLayout.value = true;
|
|
316
|
-
isSidebarIconOnly.value = true;
|
|
317
|
-
} else if (route.meta?.sidebarAndHeader === 'headerOnly') {
|
|
318
|
-
headerOnlyLayout.value = true;
|
|
319
|
-
} else {
|
|
320
|
-
defaultLayout.value = true;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
317
|
function humanizeSnake(str: string): string {
|
|
325
318
|
if (!str) {
|
|
326
319
|
return '';
|
|
@@ -345,10 +338,11 @@ watch(title, (title) => {
|
|
|
345
338
|
document.title = title;
|
|
346
339
|
})
|
|
347
340
|
|
|
348
|
-
watch(
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
341
|
+
watch(route, () => {
|
|
342
|
+
// Handle preferIconOnly layout
|
|
343
|
+
if (route.meta?.sidebarAndHeader === 'preferIconOnly') {
|
|
344
|
+
isSidebarIconOnly.value = true;
|
|
345
|
+
}
|
|
352
346
|
});
|
|
353
347
|
|
|
354
348
|
|
|
@@ -376,7 +370,6 @@ onMounted(async () => {
|
|
|
376
370
|
loadPublicConfig(); // and this
|
|
377
371
|
// before init flowbite we have to wait router initialized because it affects dom(our v-ifs) and fetch menu
|
|
378
372
|
await initRouter();
|
|
379
|
-
handleCustomLayout();
|
|
380
373
|
|
|
381
374
|
adminforth.menu.refreshMenuBadges = async () => {
|
|
382
375
|
await coreStore.fetchMenuBadges();
|
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();
|