mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 09:08:32 +02:00
Code split <Workspace> and <Settings> routes
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
|
import { lazy } from 'react';
|
||||||
import { createBrowserRouter, Navigate, RouterProvider, useParams } from 'react-router-dom';
|
import { createBrowserRouter, Navigate, RouterProvider, useParams } from 'react-router-dom';
|
||||||
import { routePaths, useAppRoutes } from '../hooks/useAppRoutes';
|
import { routePaths, useAppRoutes } from '../hooks/useAppRoutes';
|
||||||
import { DefaultLayout } from './DefaultLayout';
|
import { DefaultLayout } from './DefaultLayout';
|
||||||
import { RedirectToLatestWorkspace } from './RedirectToLatestWorkspace';
|
import { RedirectToLatestWorkspace } from './RedirectToLatestWorkspace';
|
||||||
import RouteError from './RouteError';
|
import RouteError from './RouteError';
|
||||||
import { Settings } from './Settings/Settings';
|
|
||||||
import Workspace from './Workspace';
|
const LazyWorkspace = lazy(() => import('./Workspace'));
|
||||||
|
const LazySettings = lazy(() => import('./Settings/Settings'));
|
||||||
|
|
||||||
const router = createBrowserRouter([
|
const router = createBrowserRouter([
|
||||||
{
|
{
|
||||||
@@ -24,14 +26,14 @@ const router = createBrowserRouter([
|
|||||||
path: routePaths.workspace({
|
path: routePaths.workspace({
|
||||||
workspaceId: ':workspaceId',
|
workspaceId: ':workspaceId',
|
||||||
}),
|
}),
|
||||||
element: <Workspace />,
|
element: <LazyWorkspace />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: routePaths.request({
|
path: routePaths.request({
|
||||||
workspaceId: ':workspaceId',
|
workspaceId: ':workspaceId',
|
||||||
requestId: ':requestId',
|
requestId: ':requestId',
|
||||||
}),
|
}),
|
||||||
element: <Workspace />,
|
element: <LazyWorkspace />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/workspaces/:workspaceId/environments/:environmentId/requests/:requestId',
|
path: '/workspaces/:workspaceId/environments/:environmentId/requests/:requestId',
|
||||||
@@ -41,7 +43,7 @@ const router = createBrowserRouter([
|
|||||||
path: routePaths.workspaceSettings({
|
path: routePaths.workspaceSettings({
|
||||||
workspaceId: ':workspaceId',
|
workspaceId: ':workspaceId',
|
||||||
}),
|
}),
|
||||||
element: <Settings />,
|
element: <LazySettings />,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ enum Tab {
|
|||||||
|
|
||||||
const tabs = [Tab.General, Tab.Appearance, Tab.Plugins];
|
const tabs = [Tab.General, Tab.Appearance, Tab.Plugins];
|
||||||
|
|
||||||
export const Settings = () => {
|
export default function Settings() {
|
||||||
const osInfo = useOsInfo();
|
const osInfo = useOsInfo();
|
||||||
const [tab, setTab] = useState<string>(Tab.General);
|
const [tab, setTab] = useState<string>(Tab.General);
|
||||||
|
|
||||||
@@ -66,4 +66,4 @@ export const Settings = () => {
|
|||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -2,14 +2,15 @@ import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
|
|||||||
import { type } from '@tauri-apps/plugin-os';
|
import { type } from '@tauri-apps/plugin-os';
|
||||||
import { StrictMode } from 'react';
|
import { StrictMode } from 'react';
|
||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
import { pdfjs } from 'react-pdf';
|
|
||||||
import { App } from './components/App';
|
import { App } from './components/App';
|
||||||
import './main.css';
|
import './main.css';
|
||||||
|
|
||||||
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
|
import('react-pdf').then(({ pdfjs }) => {
|
||||||
'pdfjs-dist/build/pdf.worker.min.mjs',
|
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
|
||||||
import.meta.url,
|
'pdfjs-dist/build/pdf.worker.min.mjs',
|
||||||
).toString();
|
import.meta.url,
|
||||||
|
).toString();
|
||||||
|
});
|
||||||
|
|
||||||
// Hide decorations here because it doesn't work in Rust for some reason (bug?)
|
// Hide decorations here because it doesn't work in Rust for some reason (bug?)
|
||||||
const osType = type();
|
const osType = type();
|
||||||
|
|||||||
Reference in New Issue
Block a user