chore: Refactor route components for better organization and consistency
This commit is contained in:
parent
79f31460f1
commit
e6cf76d270
35
src/routes/chrome.tsx
Normal file
35
src/routes/chrome.tsx
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import { Route, Routes } from "react-router-dom"
|
||||||
|
import OptionIndex from "./option-index"
|
||||||
|
import OptionSettings from "./option-settings"
|
||||||
|
import OptionModal from "./option-settings-model"
|
||||||
|
import OptionPrompt from "./option-settings-prompt"
|
||||||
|
import OptionOllamaSettings from "./options-settings-ollama"
|
||||||
|
import OptionShare from "./option-settings-share"
|
||||||
|
import OptionKnowledgeBase from "./option-settings-knowledge"
|
||||||
|
import OptionAbout from "./option-settings-about"
|
||||||
|
import SidepanelChat from "./sidepanel-chat"
|
||||||
|
import SidepanelSettings from "./sidepanel-settings"
|
||||||
|
|
||||||
|
export const OptionRoutingChrome = () => {
|
||||||
|
return (
|
||||||
|
<Routes>
|
||||||
|
<Route path="/" element={<OptionIndex />} />
|
||||||
|
<Route path="/settings" element={<OptionSettings />} />
|
||||||
|
<Route path="/settings/model" element={<OptionModal />} />
|
||||||
|
<Route path="/settings/prompt" element={<OptionPrompt />} />
|
||||||
|
<Route path="/settings/ollama" element={<OptionOllamaSettings />} />
|
||||||
|
<Route path="/settings/share" element={<OptionShare />} />
|
||||||
|
<Route path="/settings/knowledge" element={<OptionKnowledgeBase />} />
|
||||||
|
<Route path="/settings/about" element={<OptionAbout />} />
|
||||||
|
</Routes>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SidepanelRoutingChrome = () => {
|
||||||
|
return (
|
||||||
|
<Routes>
|
||||||
|
<Route path="/" element={<SidepanelChat />} />
|
||||||
|
<Route path="/settings" element={<SidepanelSettings />} />
|
||||||
|
</Routes>
|
||||||
|
)
|
||||||
|
}
|
39
src/routes/firefox.tsx
Normal file
39
src/routes/firefox.tsx
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// this is a temp fix for firefox
|
||||||
|
// because chunks getting 4mb+ and it's not working on firefox addon store
|
||||||
|
import { lazy } from "react"
|
||||||
|
import { Route , Routes} from "react-router-dom"
|
||||||
|
|
||||||
|
const SidepanelChat = lazy(() => import("./sidepanel-chat"))
|
||||||
|
const SidepanelSettings = lazy(() => import("./sidepanel-settings"))
|
||||||
|
const OptionIndex = lazy(() => import("./option-index"))
|
||||||
|
const OptionModal = lazy(() => import("./option-settings-model"))
|
||||||
|
const OptionPrompt = lazy(() => import("./option-settings-prompt"))
|
||||||
|
const OptionOllamaSettings = lazy(() => import("./options-settings-ollama"))
|
||||||
|
const OptionSettings = lazy(() => import("./option-settings"))
|
||||||
|
const OptionShare = lazy(() => import("./option-settings-share"))
|
||||||
|
const OptionKnowledgeBase = lazy(() => import("./option-settings-knowledge"))
|
||||||
|
const OptionAbout = lazy(() => import("./option-settings-about"))
|
||||||
|
|
||||||
|
export const OptionRoutingFirefox = () => {
|
||||||
|
return (
|
||||||
|
<Routes>
|
||||||
|
<Route path="/" element={<OptionIndex />} />
|
||||||
|
<Route path="/settings" element={<OptionSettings />} />
|
||||||
|
<Route path="/settings/model" element={<OptionModal />} />
|
||||||
|
<Route path="/settings/prompt" element={<OptionPrompt />} />
|
||||||
|
<Route path="/settings/ollama" element={<OptionOllamaSettings />} />
|
||||||
|
<Route path="/settings/share" element={<OptionShare />} />
|
||||||
|
<Route path="/settings/knowledge" element={<OptionKnowledgeBase />} />
|
||||||
|
<Route path="/settings/about" element={<OptionAbout />} />
|
||||||
|
</Routes>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SidepanelRoutingFirefox = () => {
|
||||||
|
return (
|
||||||
|
<Routes>
|
||||||
|
<Route path="/" element={<SidepanelChat />} />
|
||||||
|
<Route path="/settings" element={<SidepanelSettings />} />
|
||||||
|
</Routes>
|
||||||
|
)
|
||||||
|
}
|
@ -1,16 +1,9 @@
|
|||||||
import { Route, Routes } from "react-router-dom"
|
import { Suspense } from "react"
|
||||||
import { SidepanelChat } from "./sidepanel-chat"
|
|
||||||
import { useDarkMode } from "~/hooks/useDarkmode"
|
|
||||||
import { SidepanelSettings } from "./sidepanel-settings"
|
|
||||||
import { OptionIndex } from "./option-index"
|
|
||||||
import { OptionModal } from "./option-settings-model"
|
|
||||||
import { OptionPrompt } from "./option-settings-prompt"
|
|
||||||
import { OptionOllamaSettings } from "./options-settings-ollama"
|
|
||||||
import { OptionSettings } from "./option-settings"
|
|
||||||
import { OptionShare } from "./option-settings-share"
|
|
||||||
import { OptionKnowledgeBase } from "./option-settings-knowledge"
|
|
||||||
import { OptionAbout } from "./option-settings-about"
|
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
|
import { useDarkMode } from "~/hooks/useDarkmode"
|
||||||
|
import { Skeleton } from "antd"
|
||||||
|
import { OptionRoutingChrome, SidepanelRoutingChrome } from "./chrome"
|
||||||
|
import { OptionRoutingFirefox, SidepanelRoutingFirefox } from "./firefox"
|
||||||
|
|
||||||
export const OptionRouting = () => {
|
export const OptionRouting = () => {
|
||||||
const { mode } = useDarkMode()
|
const { mode } = useDarkMode()
|
||||||
@ -21,16 +14,13 @@ export const OptionRouting = () => {
|
|||||||
className={`${mode === "dark" ? "dark" : "light"} ${
|
className={`${mode === "dark" ? "dark" : "light"} ${
|
||||||
i18n.language === "ru" ? "onest" : "inter"
|
i18n.language === "ru" ? "onest" : "inter"
|
||||||
}`}>
|
}`}>
|
||||||
<Routes>
|
<Suspense fallback={<Skeleton />}>
|
||||||
<Route path="/" element={<OptionIndex />} />
|
{import.meta.env.BROWSER === "chrome" ? (
|
||||||
<Route path="/settings" element={<OptionSettings />} />
|
<OptionRoutingChrome />
|
||||||
<Route path="/settings/model" element={<OptionModal />} />
|
) : (
|
||||||
<Route path="/settings/prompt" element={<OptionPrompt />} />
|
<OptionRoutingFirefox />
|
||||||
<Route path="/settings/ollama" element={<OptionOllamaSettings />} />
|
)}
|
||||||
<Route path="/settings/share" element={<OptionShare />} />
|
</Suspense>
|
||||||
<Route path="/settings/knowledge" element={<OptionKnowledgeBase />} />
|
|
||||||
<Route path="/settings/about" element={<OptionAbout />} />
|
|
||||||
</Routes>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -44,10 +34,13 @@ export const SidepanelRouting = () => {
|
|||||||
className={`${mode === "dark" ? "dark" : "light"} ${
|
className={`${mode === "dark" ? "dark" : "light"} ${
|
||||||
i18n.language === "ru" ? "onest" : "inter"
|
i18n.language === "ru" ? "onest" : "inter"
|
||||||
}`}>
|
}`}>
|
||||||
<Routes>
|
<Suspense fallback={<Skeleton />}>
|
||||||
<Route path="/" element={<SidepanelChat />} />
|
{import.meta.env.BROWSER === "chrome" ? (
|
||||||
<Route path="/settings" element={<SidepanelSettings />} />
|
<SidepanelRoutingChrome />
|
||||||
</Routes>
|
) : (
|
||||||
|
<SidepanelRoutingFirefox />
|
||||||
|
)}
|
||||||
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import OptionLayout from "~/components/Layouts/Layout"
|
import OptionLayout from "~/components/Layouts/Layout"
|
||||||
import { Playground } from "~/components/Option/Playground/Playground"
|
import { Playground } from "~/components/Option/Playground/Playground"
|
||||||
|
|
||||||
export const OptionIndex = () => {
|
const OptionIndex = () => {
|
||||||
return (
|
return (
|
||||||
<OptionLayout>
|
<OptionLayout>
|
||||||
<Playground />
|
<Playground />
|
||||||
</OptionLayout>
|
</OptionLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default OptionIndex
|
@ -2,7 +2,7 @@ import { SettingsLayout } from "~/components/Layouts/SettingsOptionLayout"
|
|||||||
import OptionLayout from "~/components/Layouts/Layout"
|
import OptionLayout from "~/components/Layouts/Layout"
|
||||||
import { AboutApp } from "@/components/Option/Settings/about"
|
import { AboutApp } from "@/components/Option/Settings/about"
|
||||||
|
|
||||||
export const OptionAbout = () => {
|
const OptionAbout = () => {
|
||||||
return (
|
return (
|
||||||
<OptionLayout>
|
<OptionLayout>
|
||||||
<SettingsLayout>
|
<SettingsLayout>
|
||||||
@ -11,3 +11,5 @@ export const OptionAbout = () => {
|
|||||||
</OptionLayout>
|
</OptionLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default OptionAbout
|
||||||
|
@ -2,7 +2,7 @@ import { SettingsLayout } from "~/components/Layouts/SettingsOptionLayout"
|
|||||||
import OptionLayout from "~/components/Layouts/Layout"
|
import OptionLayout from "~/components/Layouts/Layout"
|
||||||
import { KnowledgeSettings } from "@/components/Option/Knowledge"
|
import { KnowledgeSettings } from "@/components/Option/Knowledge"
|
||||||
|
|
||||||
export const OptionKnowledgeBase = () => {
|
const OptionKnowledgeBase = () => {
|
||||||
return (
|
return (
|
||||||
<OptionLayout>
|
<OptionLayout>
|
||||||
<SettingsLayout>
|
<SettingsLayout>
|
||||||
@ -11,3 +11,5 @@ export const OptionKnowledgeBase = () => {
|
|||||||
</OptionLayout>
|
</OptionLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default OptionKnowledgeBase
|
@ -2,7 +2,7 @@ import { SettingsLayout } from "~/components/Layouts/SettingsOptionLayout"
|
|||||||
import OptionLayout from "~/components/Layouts/Layout"
|
import OptionLayout from "~/components/Layouts/Layout"
|
||||||
import { ModelsBody } from "~/components/Option/Models"
|
import { ModelsBody } from "~/components/Option/Models"
|
||||||
|
|
||||||
export const OptionModal = () => {
|
const OptionModal = () => {
|
||||||
return (
|
return (
|
||||||
<OptionLayout>
|
<OptionLayout>
|
||||||
<SettingsLayout>
|
<SettingsLayout>
|
||||||
@ -11,3 +11,5 @@ export const OptionModal = () => {
|
|||||||
</OptionLayout>
|
</OptionLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default OptionModal
|
||||||
|
@ -2,7 +2,7 @@ import { SettingsLayout } from "~/components/Layouts/SettingsOptionLayout"
|
|||||||
import OptionLayout from "~/components/Layouts/Layout"
|
import OptionLayout from "~/components/Layouts/Layout"
|
||||||
import { PromptBody } from "~/components/Option/Prompt"
|
import { PromptBody } from "~/components/Option/Prompt"
|
||||||
|
|
||||||
export const OptionPrompt = () => {
|
const OptionPrompt = () => {
|
||||||
return (
|
return (
|
||||||
<OptionLayout>
|
<OptionLayout>
|
||||||
<SettingsLayout>
|
<SettingsLayout>
|
||||||
@ -11,3 +11,5 @@ export const OptionPrompt = () => {
|
|||||||
</OptionLayout>
|
</OptionLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default OptionPrompt
|
@ -2,7 +2,7 @@ import { SettingsLayout } from "~/components/Layouts/SettingsOptionLayout"
|
|||||||
import OptionLayout from "~/components/Layouts/Layout"
|
import OptionLayout from "~/components/Layouts/Layout"
|
||||||
import { OptionShareBody } from "~/components/Option/Share"
|
import { OptionShareBody } from "~/components/Option/Share"
|
||||||
|
|
||||||
export const OptionShare = () => {
|
const OptionShare = () => {
|
||||||
return (
|
return (
|
||||||
<OptionLayout>
|
<OptionLayout>
|
||||||
<SettingsLayout>
|
<SettingsLayout>
|
||||||
@ -11,3 +11,5 @@ export const OptionShare = () => {
|
|||||||
</OptionLayout>
|
</OptionLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default OptionShare
|
@ -2,7 +2,7 @@ import { SettingsLayout } from "~/components/Layouts/SettingsOptionLayout"
|
|||||||
import OptionLayout from "~/components/Layouts/Layout"
|
import OptionLayout from "~/components/Layouts/Layout"
|
||||||
import { SettingOther } from "~/components/Option/Settings/other"
|
import { SettingOther } from "~/components/Option/Settings/other"
|
||||||
|
|
||||||
export const OptionSettings = () => {
|
const OptionSettings = () => {
|
||||||
return (
|
return (
|
||||||
<OptionLayout>
|
<OptionLayout>
|
||||||
<SettingsLayout>
|
<SettingsLayout>
|
||||||
@ -11,3 +11,5 @@ export const OptionSettings = () => {
|
|||||||
</OptionLayout>
|
</OptionLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default OptionSettings
|
@ -2,7 +2,7 @@ import { SettingsLayout } from "~/components/Layouts/SettingsOptionLayout"
|
|||||||
import OptionLayout from "~/components/Layouts/Layout"
|
import OptionLayout from "~/components/Layouts/Layout"
|
||||||
import { SettingsOllama } from "~/components/Option/Settings/ollama"
|
import { SettingsOllama } from "~/components/Option/Settings/ollama"
|
||||||
|
|
||||||
export const OptionOllamaSettings = () => {
|
const OptionOllamaSettings = () => {
|
||||||
return (
|
return (
|
||||||
<OptionLayout>
|
<OptionLayout>
|
||||||
<SettingsLayout>
|
<SettingsLayout>
|
||||||
@ -11,3 +11,5 @@ export const OptionOllamaSettings = () => {
|
|||||||
</OptionLayout>
|
</OptionLayout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default OptionOllamaSettings
|
@ -4,7 +4,7 @@ import { SidepanelForm } from "~/components/Sidepanel/Chat/form"
|
|||||||
import { SidepanelHeader } from "~/components/Sidepanel/Chat/header"
|
import { SidepanelHeader } from "~/components/Sidepanel/Chat/header"
|
||||||
import { useMessage } from "~/hooks/useMessage"
|
import { useMessage } from "~/hooks/useMessage"
|
||||||
|
|
||||||
export const SidepanelChat = () => {
|
const SidepanelChat = () => {
|
||||||
const drop = React.useRef<HTMLDivElement>(null)
|
const drop = React.useRef<HTMLDivElement>(null)
|
||||||
const [dropedFile, setDropedFile] = React.useState<File | undefined>()
|
const [dropedFile, setDropedFile] = React.useState<File | undefined>()
|
||||||
const [dropState, setDropState] = React.useState<
|
const [dropState, setDropState] = React.useState<
|
||||||
@ -90,3 +90,5 @@ export const SidepanelChat = () => {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default SidepanelChat
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { SettingsBody } from "~/components/Sidepanel/Settings/body"
|
import { SettingsBody } from "~/components/Sidepanel/Settings/body"
|
||||||
import { SidepanelSettingsHeader } from "~/components/Sidepanel/Settings/header"
|
import { SidepanelSettingsHeader } from "~/components/Sidepanel/Settings/header"
|
||||||
|
|
||||||
export const SidepanelSettings = () => {
|
const SidepanelSettings = () => {
|
||||||
return (
|
return (
|
||||||
<div className="flex bg-neutral-50 dark:bg-[#171717] flex-col min-h-screen mx-auto max-w-7xl">
|
<div className="flex bg-neutral-50 dark:bg-[#171717] flex-col min-h-screen mx-auto max-w-7xl">
|
||||||
<div className="sticky bg-white dark:bg-[#171717] top-0 z-10">
|
<div className="sticky bg-white dark:bg-[#171717] top-0 z-10">
|
||||||
@ -11,3 +11,5 @@ export const SidepanelSettings = () => {
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default SidepanelSettings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user