🎉 feat: initialization
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import { TanStackDevtools } from "@tanstack/react-devtools";
|
||||
import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
|
||||
import { TanStackRouterDevtoolsPanel } from "@tanstack/react-router-devtools";
|
||||
import { Toaster } from "@workspace/ui/components/sonner";
|
||||
import { NavigationProgress } from "@workspace/ui/composed/navigation-progress";
|
||||
import { TanStackQueryDevtools } from "@workspace/ui/integrations/tanstack-query-devtools";
|
||||
import { getCookie } from "@workspace/ui/lib/cookies";
|
||||
import { getGlobalConfig } from "@workspace/ui/services/common/common";
|
||||
import { isBrowser } from "@workspace/ui/utils/index";
|
||||
import { useEffect } from "react";
|
||||
import { Helmet, HelmetProvider } from "react-helmet-async";
|
||||
import { useGlobalStore } from "@/stores/global";
|
||||
|
||||
export const Route = createRootRouteWithContext()({
|
||||
component: () => {
|
||||
const { common, setCommon, getUserInfo } = useGlobalStore();
|
||||
useEffect(() => {
|
||||
const initializeApp = async () => {
|
||||
try {
|
||||
const configResponse = await getGlobalConfig();
|
||||
if (configResponse.data?.data) {
|
||||
setCommon(configResponse.data.data);
|
||||
}
|
||||
try {
|
||||
if (getCookie("Authorization")) {
|
||||
await getUserInfo();
|
||||
}
|
||||
} catch {
|
||||
/* empty */
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to initialize app:", error);
|
||||
}
|
||||
};
|
||||
|
||||
initializeApp();
|
||||
}, []);
|
||||
|
||||
const { site } = common;
|
||||
const title = site.site_name || "Loading...";
|
||||
const description = site.site_desc || "";
|
||||
const keywords = site.keywords || "";
|
||||
const logo = site.site_logo || "";
|
||||
const url = isBrowser() ? window.location.href : "";
|
||||
|
||||
return (
|
||||
<HelmetProvider>
|
||||
<Helmet>
|
||||
<title>{title}</title>
|
||||
<meta content={description} name="description" />
|
||||
<meta content={keywords} name="keywords" />
|
||||
<link href={url} rel="canonical" />
|
||||
<link href={logo} rel="icon" type="image/svg+xml" />
|
||||
<link href={logo} rel="apple-touch-icon" sizes="180x180" />
|
||||
<link href="/site.webmanifest" rel="manifest" />
|
||||
</Helmet>
|
||||
<NavigationProgress />
|
||||
<Outlet />
|
||||
<Toaster closeButton richColors />
|
||||
<div
|
||||
dangerouslySetInnerHTML={{ __html: common?.site.custom_html || "" }}
|
||||
id="custom_html"
|
||||
/>
|
||||
<TanStackDevtools
|
||||
config={{
|
||||
position: "bottom-right",
|
||||
}}
|
||||
plugins={[
|
||||
{
|
||||
name: "Tanstack Router",
|
||||
render: <TanStackRouterDevtoolsPanel />,
|
||||
},
|
||||
TanStackQueryDevtools,
|
||||
]}
|
||||
/>
|
||||
</HelmetProvider>
|
||||
);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Ads from "@/sections/ads";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/ads/")({
|
||||
component: Ads,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Announcement from "@/sections/announcement";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/announcement/")({
|
||||
component: Announcement,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import AuthControl from "@/sections/auth-control";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/auth-control/")({
|
||||
component: AuthControl,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Coupon from "@/sections/coupon";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/coupon/")({
|
||||
component: Coupon,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Document from "@/sections/document";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/document/")({
|
||||
component: Document,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Dashboard from "@/sections/dashboard";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/")({
|
||||
component: Dashboard,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import BalanceLogPage from "@/sections/log/balance";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/balance")({
|
||||
component: BalanceLogPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import CommissionLogPage from "@/sections/log/commission";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/commission")({
|
||||
component: CommissionLogPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import EmailLogPage from "@/sections/log/email";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/email")({
|
||||
component: EmailLogPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import GiftLogPage from "@/sections/log/gift";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/gift")({
|
||||
component: GiftLogPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import LoginLogPage from "@/sections/log/login";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/login")({
|
||||
component: LoginLogPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import MobileLogPage from "@/sections/log/mobile";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/mobile")({
|
||||
component: MobileLogPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import RegisterLogPage from "@/sections/log/register";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/register")({
|
||||
component: RegisterLogPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import ResetSubscribeLogPage from "@/sections/log/reset-subscribe";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/reset-subscribe")({
|
||||
component: ResetSubscribeLogPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import ServerTrafficLogPage from "@/sections/log/server-traffic";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/server-traffic")({
|
||||
component: ServerTrafficLogPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import SubscribeTrafficLogPage from "@/sections/log/subscribe-traffic";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/subscribe-traffic")({
|
||||
component: SubscribeTrafficLogPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import SubscribeLogPage from "@/sections/log/subscribe";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/subscribe")({
|
||||
component: SubscribeLogPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import TrafficDetailsPage from "@/sections/log/traffic-details";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/log/traffic-details")({
|
||||
component: TrafficDetailsPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import MarketingPage from "@/sections/marketing";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/marketing/")({
|
||||
component: MarketingPage,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Nodes from "@/sections/nodes";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/nodes")({
|
||||
component: Nodes,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Order from "@/sections/order";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/order/")({
|
||||
component: Order,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Payment from "@/sections/payment";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/payment/")({
|
||||
component: Payment,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Product from "@/sections/product";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/product/")({
|
||||
component: Product,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import DashboardLayout from "@/layout";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard")({
|
||||
component: DashboardLayout,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Servers from "@/sections/servers";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/servers")({
|
||||
component: Servers,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Subscribe from "@/sections/subscribe";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/subscribe/")({
|
||||
component: Subscribe,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import System from "@/sections/system";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/system/")({
|
||||
component: System,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Ticket from "@/sections/ticket";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/ticket/")({
|
||||
component: Ticket,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import User from "@/sections/user";
|
||||
|
||||
export const Route = createLazyFileRoute("/dashboard/user/")({
|
||||
component: User,
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import Auth from "@/sections/auth";
|
||||
|
||||
export const Route = createLazyFileRoute("/")({
|
||||
component: Auth,
|
||||
});
|
||||
Reference in New Issue
Block a user