2024-09-30 00:23:19 +08:00
|
|
|
import PageIndex from "@/components/PageIndex.svelte";
|
|
|
|
import PageLogs from "@/components/logs/PageLogs.svelte";
|
|
|
|
import PageRecords from "@/components/records/PageRecords.svelte";
|
|
|
|
import PageApplication from "@/components/settings/PageApplication.svelte";
|
|
|
|
import PageBackups from "@/components/settings/PageBackups.svelte";
|
2022-08-05 11:00:38 +08:00
|
|
|
import PageExportCollections from "@/components/settings/PageExportCollections.svelte";
|
|
|
|
import PageImportCollections from "@/components/settings/PageImportCollections.svelte";
|
2024-09-30 00:23:19 +08:00
|
|
|
import PageMail from "@/components/settings/PageMail.svelte";
|
|
|
|
import PageStorage from "@/components/settings/PageStorage.svelte";
|
|
|
|
import PageSuperuserLogin from "@/components/superusers/PageSuperuserLogin.svelte";
|
|
|
|
import ApiClient from "@/utils/ApiClient";
|
2024-11-06 03:12:17 +08:00
|
|
|
import { isTokenExpired } from "pocketbase";
|
2024-09-30 00:23:19 +08:00
|
|
|
import { wrap } from "svelte-spa-router/wrap";
|
2022-07-07 05:19:05 +08:00
|
|
|
|
2022-07-10 16:46:21 +08:00
|
|
|
const routes = {
|
2024-11-06 03:12:17 +08:00
|
|
|
"/pbinstal/:token": wrap({
|
|
|
|
asyncComponent: () => import("@/components/base/PageInstaller.svelte"),
|
|
|
|
conditions: [(details) => {
|
|
|
|
return details.params.token && !isTokenExpired(details.params.token)
|
|
|
|
}],
|
|
|
|
userData: { showAppSidebar: false },
|
|
|
|
}),
|
|
|
|
|
2022-07-07 05:19:05 +08:00
|
|
|
"/login": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
component: PageSuperuserLogin,
|
2024-11-06 03:12:17 +08:00
|
|
|
conditions: [(_) => !ApiClient.authStore.isValid],
|
2022-07-10 16:46:21 +08:00
|
|
|
userData: { showAppSidebar: false },
|
2022-07-07 05:19:05 +08:00
|
|
|
}),
|
|
|
|
|
|
|
|
"/request-password-reset": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
asyncComponent: () => import("@/components/superusers/PageSuperuserRequestPasswordReset.svelte"),
|
2024-11-06 03:12:17 +08:00
|
|
|
conditions: [(_) => !ApiClient.authStore.isValid],
|
2022-07-10 16:46:21 +08:00
|
|
|
userData: { showAppSidebar: false },
|
2022-07-07 05:19:05 +08:00
|
|
|
}),
|
|
|
|
|
|
|
|
"/confirm-password-reset/:token": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
asyncComponent: () => import("@/components/superusers/PageSuperuserConfirmPasswordReset.svelte"),
|
2024-11-06 03:12:17 +08:00
|
|
|
conditions: [(_) => !ApiClient.authStore.isValid],
|
2022-07-10 16:46:21 +08:00
|
|
|
userData: { showAppSidebar: false },
|
2022-07-07 05:19:05 +08:00
|
|
|
}),
|
|
|
|
|
|
|
|
"/collections": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
component: PageRecords,
|
2024-11-06 03:12:17 +08:00
|
|
|
conditions: [(_) => ApiClient.authStore.isValid],
|
2022-07-10 16:46:21 +08:00
|
|
|
userData: { showAppSidebar: true },
|
2022-07-07 05:19:05 +08:00
|
|
|
}),
|
|
|
|
|
|
|
|
"/logs": wrap({
|
|
|
|
component: PageLogs,
|
2024-11-06 03:12:17 +08:00
|
|
|
conditions: [(_) => ApiClient.authStore.isValid],
|
2022-07-10 16:46:21 +08:00
|
|
|
userData: { showAppSidebar: true },
|
2022-07-07 05:19:05 +08:00
|
|
|
}),
|
|
|
|
|
|
|
|
"/settings": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
component: PageApplication,
|
2024-11-06 03:12:17 +08:00
|
|
|
conditions: [(_) => ApiClient.authStore.isValid],
|
2022-07-10 16:46:21 +08:00
|
|
|
userData: { showAppSidebar: true },
|
2022-07-07 05:19:05 +08:00
|
|
|
}),
|
|
|
|
|
|
|
|
"/settings/mail": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
component: PageMail,
|
2024-11-06 03:12:17 +08:00
|
|
|
conditions: [(_) => ApiClient.authStore.isValid],
|
2022-07-10 16:46:21 +08:00
|
|
|
userData: { showAppSidebar: true },
|
2022-07-07 05:19:05 +08:00
|
|
|
}),
|
|
|
|
|
|
|
|
"/settings/storage": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
component: PageStorage,
|
2024-11-06 03:12:17 +08:00
|
|
|
conditions: [(_) => ApiClient.authStore.isValid],
|
2022-07-10 16:46:21 +08:00
|
|
|
userData: { showAppSidebar: true },
|
2022-07-07 05:19:05 +08:00
|
|
|
}),
|
|
|
|
|
2022-08-05 11:00:38 +08:00
|
|
|
"/settings/export-collections": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
component: PageExportCollections,
|
2024-11-06 03:12:17 +08:00
|
|
|
conditions: [(_) => ApiClient.authStore.isValid],
|
2022-08-05 11:00:38 +08:00
|
|
|
userData: { showAppSidebar: true },
|
|
|
|
}),
|
|
|
|
|
|
|
|
"/settings/import-collections": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
component: PageImportCollections,
|
2024-11-06 03:12:17 +08:00
|
|
|
conditions: [(_) => ApiClient.authStore.isValid],
|
2022-08-05 11:00:38 +08:00
|
|
|
userData: { showAppSidebar: true },
|
|
|
|
}),
|
2023-05-14 03:10:14 +08:00
|
|
|
|
|
|
|
"/settings/backups": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
component: PageBackups,
|
2024-11-06 03:12:17 +08:00
|
|
|
conditions: [(_) => ApiClient.authStore.isValid],
|
2023-05-14 03:10:14 +08:00
|
|
|
userData: { showAppSidebar: true },
|
|
|
|
}),
|
2022-08-05 11:00:38 +08:00
|
|
|
|
2022-10-30 16:28:14 +08:00
|
|
|
// ---------------------------------------------------------------
|
|
|
|
// Records email confirmation actions
|
|
|
|
// ---------------------------------------------------------------
|
|
|
|
|
|
|
|
// @deprecated
|
|
|
|
"/users/confirm-password-reset/:token": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
asyncComponent: () => import("@/components/records/PageRecordConfirmPasswordReset.svelte"),
|
2022-10-30 16:28:14 +08:00
|
|
|
userData: { showAppSidebar: false },
|
|
|
|
}),
|
|
|
|
"/auth/confirm-password-reset/:token": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
asyncComponent: () => import("@/components/records/PageRecordConfirmPasswordReset.svelte"),
|
2022-10-30 16:28:14 +08:00
|
|
|
userData: { showAppSidebar: false },
|
|
|
|
}),
|
|
|
|
|
|
|
|
// @deprecated
|
|
|
|
"/users/confirm-verification/:token": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
asyncComponent: () => import("@/components/records/PageRecordConfirmVerification.svelte"),
|
2022-10-30 16:28:14 +08:00
|
|
|
userData: { showAppSidebar: false },
|
|
|
|
}),
|
|
|
|
"/auth/confirm-verification/:token": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
asyncComponent: () => import("@/components/records/PageRecordConfirmVerification.svelte"),
|
2022-10-30 16:28:14 +08:00
|
|
|
userData: { showAppSidebar: false },
|
|
|
|
}),
|
|
|
|
|
|
|
|
// @deprecated
|
|
|
|
"/users/confirm-email-change/:token": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
asyncComponent: () => import("@/components/records/PageRecordConfirmEmailChange.svelte"),
|
2022-10-30 16:28:14 +08:00
|
|
|
userData: { showAppSidebar: false },
|
|
|
|
}),
|
|
|
|
"/auth/confirm-email-change/:token": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
asyncComponent: () => import("@/components/records/PageRecordConfirmEmailChange.svelte"),
|
2022-10-30 16:28:14 +08:00
|
|
|
userData: { showAppSidebar: false },
|
|
|
|
}),
|
|
|
|
|
2024-01-20 01:14:52 +08:00
|
|
|
"/auth/oauth2-redirect-success": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
asyncComponent: () => import("@/components/records/PageOAuth2RedirectSuccess.svelte"),
|
2024-01-20 01:14:52 +08:00
|
|
|
userData: { showAppSidebar: false },
|
|
|
|
}),
|
|
|
|
|
|
|
|
"/auth/oauth2-redirect-failure": wrap({
|
2024-09-30 00:23:19 +08:00
|
|
|
asyncComponent: () => import("@/components/records/PageOAuth2RedirectFailure.svelte"),
|
2023-04-11 03:27:00 +08:00
|
|
|
userData: { showAppSidebar: false },
|
|
|
|
}),
|
|
|
|
|
2022-10-30 16:28:14 +08:00
|
|
|
// catch-all fallback
|
2022-07-07 05:19:05 +08:00
|
|
|
"*": wrap({
|
2022-07-10 16:46:21 +08:00
|
|
|
component: PageIndex,
|
|
|
|
userData: { showAppSidebar: false },
|
2022-07-07 05:19:05 +08:00
|
|
|
}),
|
|
|
|
};
|
|
|
|
|
|
|
|
export default routes;
|