chore: restructure
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
<title>Lume</title>
|
<title>Lume</title>
|
||||||
</head>
|
</head>
|
||||||
<body
|
<body
|
||||||
class="relative h-screen w-screen cursor-default select-none overflow-hidden font-sans text-neutral-950 antialiased dark:text-neutral-50"
|
class="relative w-screen h-screen overflow-hidden font-sans antialiased cursor-default select-none text-neutral-950 dark:text-neutral-50"
|
||||||
>
|
>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script type="module" src="./src/main.jsx"></script>
|
<script type="module" src="./src/main.jsx"></script>
|
||||||
|
|||||||
@@ -1,270 +1,23 @@
|
|||||||
import { useStorage } from "@lume/ark";
|
import { LumeProvider } from "@lume/ark";
|
||||||
import { LoaderIcon } from "@lume/icons";
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
import { AppLayout, AuthLayout, HomeLayout, SettingsLayout } from "@lume/ui";
|
import { Toaster } from "sonner";
|
||||||
import { fetch } from "@tauri-apps/plugin-http";
|
import Router from "./router";
|
||||||
import {
|
|
||||||
RouterProvider,
|
const queryClient = new QueryClient({
|
||||||
createBrowserRouter,
|
defaultOptions: {
|
||||||
defer,
|
queries: {
|
||||||
redirect,
|
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 10000), // 10 seconds
|
||||||
} from "react-router-dom";
|
},
|
||||||
import { ErrorScreen } from "./routes/error";
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const storage = useStorage();
|
|
||||||
|
|
||||||
const router = createBrowserRouter([
|
|
||||||
{
|
|
||||||
element: <AppLayout platform={storage.platform} />,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "/",
|
|
||||||
element: <HomeLayout />,
|
|
||||||
errorElement: <ErrorScreen />,
|
|
||||||
loader: async () => {
|
|
||||||
if (!storage.account) return redirect("auth/welcome");
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
index: true,
|
|
||||||
async lazy() {
|
|
||||||
const { HomeScreen } = await import("./routes/home");
|
|
||||||
return { Component: HomeScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "nwc",
|
|
||||||
async lazy() {
|
|
||||||
const { NWCScreen } = await import("./routes/nwc");
|
|
||||||
return { Component: NWCScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "relays",
|
|
||||||
async lazy() {
|
|
||||||
const { RelaysScreen } = await import("./routes/relays");
|
|
||||||
return { Component: RelaysScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "relays/:url",
|
|
||||||
loader: async ({ params }) => {
|
|
||||||
return defer({
|
|
||||||
relay: fetch(`https://${params.url}`, {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
Accept: "application/nostr+json",
|
|
||||||
},
|
|
||||||
}).then((res) => res.json()),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
async lazy() {
|
|
||||||
const { RelayScreen } = await import("./routes/relays/relay");
|
|
||||||
return { Component: RelayScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "settings",
|
|
||||||
element: <SettingsLayout />,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
index: true,
|
|
||||||
async lazy() {
|
|
||||||
const { UserSettingScreen } = await import(
|
|
||||||
"./routes/settings"
|
|
||||||
);
|
|
||||||
return { Component: UserSettingScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "edit-profile",
|
|
||||||
async lazy() {
|
|
||||||
const { EditProfileScreen } = await import(
|
|
||||||
"./routes/settings/editProfile"
|
|
||||||
);
|
|
||||||
return { Component: EditProfileScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "edit-contact",
|
|
||||||
async lazy() {
|
|
||||||
const { EditContactScreen } = await import(
|
|
||||||
"./routes/settings/editContact"
|
|
||||||
);
|
|
||||||
return { Component: EditContactScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "general",
|
|
||||||
async lazy() {
|
|
||||||
const { GeneralSettingScreen } = await import(
|
|
||||||
"./routes/settings/general"
|
|
||||||
);
|
|
||||||
return { Component: GeneralSettingScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "backup",
|
|
||||||
async lazy() {
|
|
||||||
const { BackupSettingScreen } = await import(
|
|
||||||
"./routes/settings/backup"
|
|
||||||
);
|
|
||||||
return { Component: BackupSettingScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "advanced",
|
|
||||||
async lazy() {
|
|
||||||
const { AdvancedSettingScreen } = await import(
|
|
||||||
"./routes/settings/advanced"
|
|
||||||
);
|
|
||||||
return { Component: AdvancedSettingScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "about",
|
|
||||||
async lazy() {
|
|
||||||
const { AboutScreen } = await import(
|
|
||||||
"./routes/settings/about"
|
|
||||||
);
|
|
||||||
return { Component: AboutScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "depot",
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
index: true,
|
|
||||||
loader: () => {
|
|
||||||
const depot = storage.checkDepot();
|
|
||||||
if (!depot) return redirect("/depot/onboarding/");
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
async lazy() {
|
|
||||||
const { DepotScreen } = await import("./routes/depot");
|
|
||||||
return { Component: DepotScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "onboarding",
|
|
||||||
async lazy() {
|
|
||||||
const { DepotOnboardingScreen } = await import(
|
|
||||||
"./routes/depot/onboarding"
|
|
||||||
);
|
|
||||||
return { Component: DepotOnboardingScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "auth",
|
|
||||||
element: <AuthLayout platform={storage.platform} />,
|
|
||||||
errorElement: <ErrorScreen />,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "welcome",
|
|
||||||
async lazy() {
|
|
||||||
const { WelcomeScreen } = await import("./routes/auth/welcome");
|
|
||||||
return { Component: WelcomeScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "create",
|
|
||||||
async lazy() {
|
|
||||||
const { CreateAccountScreen } = await import(
|
|
||||||
"./routes/auth/create"
|
|
||||||
);
|
|
||||||
return { Component: CreateAccountScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "import",
|
|
||||||
async lazy() {
|
|
||||||
const { ImportAccountScreen } = await import(
|
|
||||||
"./routes/auth/import"
|
|
||||||
);
|
|
||||||
return { Component: ImportAccountScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "onboarding",
|
|
||||||
async lazy() {
|
|
||||||
const { OnboardingScreen } = await import(
|
|
||||||
"./routes/auth/onboarding"
|
|
||||||
);
|
|
||||||
return { Component: OnboardingScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "follow",
|
|
||||||
async lazy() {
|
|
||||||
const { FollowScreen } = await import("./routes/auth/follow");
|
|
||||||
return { Component: FollowScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "finish",
|
|
||||||
async lazy() {
|
|
||||||
const { FinishScreen } = await import("./routes/auth/finish");
|
|
||||||
return { Component: FinishScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "tutorials/note",
|
|
||||||
async lazy() {
|
|
||||||
const { TutorialNoteScreen } = await import(
|
|
||||||
"./routes/auth/tutorials/note"
|
|
||||||
);
|
|
||||||
return { Component: TutorialNoteScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "tutorials/widget",
|
|
||||||
async lazy() {
|
|
||||||
const { TutorialWidgetScreen } = await import(
|
|
||||||
"./routes/auth/tutorials/widget"
|
|
||||||
);
|
|
||||||
return { Component: TutorialWidgetScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "tutorials/posting",
|
|
||||||
async lazy() {
|
|
||||||
const { TutorialPostingScreen } = await import(
|
|
||||||
"./routes/auth/tutorials/posting"
|
|
||||||
);
|
|
||||||
return { Component: TutorialPostingScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "tutorials/finish",
|
|
||||||
async lazy() {
|
|
||||||
const { TutorialFinishScreen } = await import(
|
|
||||||
"./routes/auth/tutorials/finish"
|
|
||||||
);
|
|
||||||
return { Component: TutorialFinishScreen };
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RouterProvider
|
<QueryClientProvider client={queryClient}>
|
||||||
router={router}
|
<Toaster position="top-center" theme="system" closeButton />
|
||||||
fallbackElement={
|
<LumeProvider>
|
||||||
<div className="flex items-center justify-center w-full h-full">
|
<Router />
|
||||||
<LoaderIcon className="w-6 h-6 animate-spin" />
|
</LumeProvider>
|
||||||
</div>
|
</QueryClientProvider>
|
||||||
}
|
|
||||||
future={{ v7_startTransition: true }}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,8 @@
|
|||||||
import { LumeProvider } from '@lume/ark';
|
import { createRoot } from "react-dom/client";
|
||||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
import App from "./app";
|
||||||
import { createRoot } from 'react-dom/client';
|
import "./app.css";
|
||||||
import { Toaster } from 'sonner';
|
|
||||||
import App from './app';
|
|
||||||
import './app.css';
|
|
||||||
|
|
||||||
const queryClient = new QueryClient({
|
const container = document.getElementById("root");
|
||||||
defaultOptions: {
|
|
||||||
queries: {
|
|
||||||
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 10000), // 10 seconds
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const container = document.getElementById('root');
|
|
||||||
const root = createRoot(container);
|
const root = createRoot(container);
|
||||||
|
|
||||||
root.render(
|
root.render(<App />);
|
||||||
<QueryClientProvider client={queryClient}>
|
|
||||||
<Toaster position="top-center" theme="system" closeButton />
|
|
||||||
<LumeProvider>
|
|
||||||
<App />
|
|
||||||
</LumeProvider>
|
|
||||||
</QueryClientProvider>
|
|
||||||
);
|
|
||||||
|
|||||||
272
apps/desktop/src/router.tsx
Normal file
272
apps/desktop/src/router.tsx
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
import { useArk, useStorage } from "@lume/ark";
|
||||||
|
import { LoaderIcon } from "@lume/icons";
|
||||||
|
import { AppLayout, AuthLayout, HomeLayout, SettingsLayout } from "@lume/ui";
|
||||||
|
import { NDKKind } from "@nostr-dev-kit/ndk";
|
||||||
|
import { fetch } from "@tauri-apps/plugin-http";
|
||||||
|
import {
|
||||||
|
RouterProvider,
|
||||||
|
createBrowserRouter,
|
||||||
|
defer,
|
||||||
|
redirect,
|
||||||
|
} from "react-router-dom";
|
||||||
|
import { ErrorScreen } from "./routes/error";
|
||||||
|
|
||||||
|
export default function Router() {
|
||||||
|
const ark = useArk();
|
||||||
|
const storage = useStorage();
|
||||||
|
|
||||||
|
const router = createBrowserRouter([
|
||||||
|
{
|
||||||
|
element: <AppLayout platform={storage.platform} />,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "/",
|
||||||
|
element: <HomeLayout />,
|
||||||
|
errorElement: <ErrorScreen />,
|
||||||
|
loader: async () => {
|
||||||
|
if (!storage.account) return redirect("auth/welcome");
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
index: true,
|
||||||
|
async lazy() {
|
||||||
|
const { HomeScreen } = await import("./routes/home");
|
||||||
|
return { Component: HomeScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "nwc",
|
||||||
|
async lazy() {
|
||||||
|
const { NWCScreen } = await import("./routes/nwc");
|
||||||
|
return { Component: NWCScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "relays",
|
||||||
|
async lazy() {
|
||||||
|
const { RelaysScreen } = await import("./routes/relays");
|
||||||
|
return { Component: RelaysScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "relays/:url",
|
||||||
|
loader: async ({ params }) => {
|
||||||
|
return defer({
|
||||||
|
relay: fetch(`https://${params.url}`, {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
Accept: "application/nostr+json",
|
||||||
|
},
|
||||||
|
}).then((res) => res.json()),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async lazy() {
|
||||||
|
const { RelayScreen } = await import("./routes/relays/relay");
|
||||||
|
return { Component: RelayScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "settings",
|
||||||
|
element: <SettingsLayout />,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
index: true,
|
||||||
|
async lazy() {
|
||||||
|
const { UserSettingScreen } = await import(
|
||||||
|
"./routes/settings"
|
||||||
|
);
|
||||||
|
return { Component: UserSettingScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "edit-profile",
|
||||||
|
async lazy() {
|
||||||
|
const { EditProfileScreen } = await import(
|
||||||
|
"./routes/settings/editProfile"
|
||||||
|
);
|
||||||
|
return { Component: EditProfileScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "edit-contact",
|
||||||
|
async lazy() {
|
||||||
|
const { EditContactScreen } = await import(
|
||||||
|
"./routes/settings/editContact"
|
||||||
|
);
|
||||||
|
return { Component: EditContactScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "general",
|
||||||
|
async lazy() {
|
||||||
|
const { GeneralSettingScreen } = await import(
|
||||||
|
"./routes/settings/general"
|
||||||
|
);
|
||||||
|
return { Component: GeneralSettingScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "backup",
|
||||||
|
async lazy() {
|
||||||
|
const { BackupSettingScreen } = await import(
|
||||||
|
"./routes/settings/backup"
|
||||||
|
);
|
||||||
|
return { Component: BackupSettingScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "advanced",
|
||||||
|
async lazy() {
|
||||||
|
const { AdvancedSettingScreen } = await import(
|
||||||
|
"./routes/settings/advanced"
|
||||||
|
);
|
||||||
|
return { Component: AdvancedSettingScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "about",
|
||||||
|
async lazy() {
|
||||||
|
const { AboutScreen } = await import(
|
||||||
|
"./routes/settings/about"
|
||||||
|
);
|
||||||
|
return { Component: AboutScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "depot",
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
index: true,
|
||||||
|
loader: () => {
|
||||||
|
const depot = storage.checkDepot();
|
||||||
|
if (!depot) return redirect("/depot/onboarding/");
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
async lazy() {
|
||||||
|
const { DepotScreen } = await import("./routes/depot");
|
||||||
|
return { Component: DepotScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "onboarding",
|
||||||
|
async lazy() {
|
||||||
|
const { DepotOnboardingScreen } = await import(
|
||||||
|
"./routes/depot/onboarding"
|
||||||
|
);
|
||||||
|
return { Component: DepotOnboardingScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "auth",
|
||||||
|
element: <AuthLayout platform={storage.platform} />,
|
||||||
|
errorElement: <ErrorScreen />,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "welcome",
|
||||||
|
async lazy() {
|
||||||
|
const { WelcomeScreen } = await import("./routes/auth/welcome");
|
||||||
|
return { Component: WelcomeScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "create",
|
||||||
|
async lazy() {
|
||||||
|
const { CreateAccountScreen } = await import(
|
||||||
|
"./routes/auth/create"
|
||||||
|
);
|
||||||
|
return { Component: CreateAccountScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "import",
|
||||||
|
async lazy() {
|
||||||
|
const { ImportAccountScreen } = await import(
|
||||||
|
"./routes/auth/import"
|
||||||
|
);
|
||||||
|
return { Component: ImportAccountScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "onboarding",
|
||||||
|
async lazy() {
|
||||||
|
const { OnboardingScreen } = await import(
|
||||||
|
"./routes/auth/onboarding"
|
||||||
|
);
|
||||||
|
return { Component: OnboardingScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "follow",
|
||||||
|
async lazy() {
|
||||||
|
const { FollowScreen } = await import("./routes/auth/follow");
|
||||||
|
return { Component: FollowScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "finish",
|
||||||
|
async lazy() {
|
||||||
|
const { FinishScreen } = await import("./routes/auth/finish");
|
||||||
|
return { Component: FinishScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "tutorials/note",
|
||||||
|
async lazy() {
|
||||||
|
const { TutorialNoteScreen } = await import(
|
||||||
|
"./routes/auth/tutorials/note"
|
||||||
|
);
|
||||||
|
return { Component: TutorialNoteScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "tutorials/widget",
|
||||||
|
async lazy() {
|
||||||
|
const { TutorialWidgetScreen } = await import(
|
||||||
|
"./routes/auth/tutorials/widget"
|
||||||
|
);
|
||||||
|
return { Component: TutorialWidgetScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "tutorials/posting",
|
||||||
|
async lazy() {
|
||||||
|
const { TutorialPostingScreen } = await import(
|
||||||
|
"./routes/auth/tutorials/posting"
|
||||||
|
);
|
||||||
|
return { Component: TutorialPostingScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "tutorials/finish",
|
||||||
|
async lazy() {
|
||||||
|
const { TutorialFinishScreen } = await import(
|
||||||
|
"./routes/auth/tutorials/finish"
|
||||||
|
);
|
||||||
|
return { Component: TutorialFinishScreen };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RouterProvider
|
||||||
|
router={router}
|
||||||
|
fallbackElement={
|
||||||
|
<div className="flex items-center justify-center w-full h-full">
|
||||||
|
<LoaderIcon className="w-6 h-6 animate-spin" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
future={{ v7_startTransition: true }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user