content-area.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import { Suspense, lazy } from "react"
  2. import { useWikiStore } from "@/stores/wiki-store"
  3. import { WritingWorkspace } from "./writing-workspace"
  4. import { SearchView } from "@/components/search/search-view"
  5. import { SkillLibraryView } from "@/components/skill-library/skill-library-view"
  6. const ChatPanel = lazy(async () => {
  7. const mod = await import("@/components/chat/chat-panel")
  8. return { default: mod.ChatPanel }
  9. })
  10. const SettingsView = lazy(async () => {
  11. const mod = await import("@/components/settings/settings-view")
  12. return { default: mod.SettingsView }
  13. })
  14. const SourcesView = lazy(async () => {
  15. const mod = await import("@/components/sources/sources-view")
  16. return { default: mod.SourcesView }
  17. })
  18. const LintView = lazy(async () => {
  19. const mod = await import("@/components/lint/lint-view")
  20. return { default: mod.LintView }
  21. })
  22. const MemoryCenterView = lazy(async () => {
  23. const mod = await import("@/components/novel/memory-center-view")
  24. return { default: mod.MemoryCenterView }
  25. })
  26. const GraphView = lazy(async () => {
  27. const mod = await import("@/components/graph/graph-view")
  28. return { default: mod.GraphView }
  29. })
  30. const SoulView = lazy(async () => {
  31. const mod = await import("@/components/novel/soul-view")
  32. return { default: mod.SoulView }
  33. })
  34. const ReviewCenterView = lazy(async () => {
  35. const mod = await import("@/components/review/review-center-view")
  36. return { default: mod.ReviewCenterView }
  37. })
  38. const BookAnalysisView = lazy(async () => {
  39. const mod = await import("@/components/novel/book-analysis-view")
  40. return { default: mod.BookAnalysisView }
  41. })
  42. const StorySimulationView = lazy(async () => {
  43. const mod = await import("@/components/novel/story-simulation/story-simulation-view")
  44. return { default: mod.StorySimulationView }
  45. })
  46. function LoadingView() {
  47. return (
  48. <div className="flex h-full items-center justify-center text-sm text-muted-foreground">
  49. Loading...
  50. </div>
  51. )
  52. }
  53. export function ContentArea() {
  54. const activeView = useWikiStore((s) => s.activeView)
  55. const novelMode = useWikiStore((s) => s.novelMode)
  56. const showWritingWorkspace = activeView === "wiki" || activeView === "trash"
  57. let content = null
  58. if (showWritingWorkspace) {
  59. content = <WritingWorkspace />
  60. } else {
  61. switch (activeView) {
  62. case "settings":
  63. content = (
  64. <Suspense fallback={<LoadingView />}>
  65. <SettingsView />
  66. </Suspense>
  67. )
  68. break
  69. case "sources":
  70. content = (
  71. <Suspense fallback={<LoadingView />}>
  72. <SourcesView />
  73. </Suspense>
  74. )
  75. break
  76. case "search":
  77. content = <SearchView />
  78. break
  79. case "soul":
  80. content = (
  81. <Suspense fallback={<LoadingView />}>
  82. <SoulView />
  83. </Suspense>
  84. )
  85. break
  86. case "skillLibrary":
  87. content = (
  88. <Suspense fallback={<LoadingView />}>
  89. <SkillLibraryView />
  90. </Suspense>
  91. )
  92. break
  93. case "lint":
  94. content = (
  95. <Suspense fallback={<LoadingView />}>
  96. {novelMode ? <MemoryCenterView /> : <LintView />}
  97. </Suspense>
  98. )
  99. break
  100. case "graph":
  101. content = (
  102. <Suspense fallback={<LoadingView />}>
  103. <GraphView />
  104. </Suspense>
  105. )
  106. break
  107. case "reviewCenter":
  108. content = (
  109. <Suspense fallback={<LoadingView />}>
  110. <ReviewCenterView />
  111. </Suspense>
  112. )
  113. break
  114. case "bookAnalysis":
  115. content = (
  116. <Suspense fallback={<LoadingView />}>
  117. <BookAnalysisView />
  118. </Suspense>
  119. )
  120. break
  121. case "storySimulation":
  122. content = (
  123. <Suspense fallback={<LoadingView />}>
  124. <StorySimulationView />
  125. </Suspense>
  126. )
  127. break
  128. default:
  129. content = (
  130. <Suspense fallback={<LoadingView />}>
  131. <ChatPanel />
  132. </Suspense>
  133. )
  134. break
  135. }
  136. }
  137. return <div className="h-full">{content}</div>
  138. }