Skip to content

Commit d763bf9

Browse files
authored
refactor: split monolithic store (#1109)
1 parent bd9e479 commit d763bf9

File tree

97 files changed

+2023
-1281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2023
-1281
lines changed

apps/web/src/App.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<script setup lang="ts">
22
import { onMounted, ref } from 'vue'
33
import { Toaster } from '@/components/ui/sonner'
4+
import { useUIStore } from '@/stores/ui'
45
import CodemirrorEditor from '@/views/CodemirrorEditor.vue'
56
6-
const store = useStore()
7+
const uiStore = useUIStore()
8+
const { isDark } = storeToRefs(uiStore)
9+
710
const isUtools = ref(false)
811
912
onMounted(() => {
@@ -21,7 +24,7 @@ onMounted(() => {
2124
<Toaster
2225
rich-colors
2326
position="top-center"
24-
:theme="store.isDark ? 'dark' : 'light'"
27+
:theme="isDark ? 'dark' : 'light'"
2528
/>
2629
</template>
2730

apps/web/src/components/ai/SidebarAIToolbar.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script setup lang="ts">
22
import { Bot, Image as ImageIcon, Settings2, Wand2 } from 'lucide-vue-next'
3-
import { useDisplayStore } from '@/stores'
3+
import { useDisplayStore } from '@/stores/display'
4+
import { useEditorStore } from '@/stores/editor'
5+
import { useUIStore } from '@/stores/ui'
46
import AIAssistantPanel from './chat-box/AIAssistantPanel.vue'
57
import AIImageGeneratorPanel from './image-generator/AIImageGeneratorPanel.vue'
68
import { AIPolishPopover } from './tool-box'
@@ -14,8 +16,11 @@ const displayStore = useDisplayStore()
1416
const { aiDialogVisible, aiImageDialogVisible } = storeToRefs(displayStore)
1517
const { toggleAIDialog, toggleAIImageDialog } = displayStore
1618
17-
const store = useStore()
18-
const { editor, hasShownAIToolboxHint } = storeToRefs(store)
19+
const editorStore = useEditorStore()
20+
const { editor } = storeToRefs(editorStore)
21+
22+
const uiStore = useUIStore()
23+
const { hasShownAIToolboxHint } = storeToRefs(uiStore)
1924
2025
// 工具栏状态:false=默认(只显示贴边栏), true=展开(显示AI图标)
2126
const isExpanded = ref(false) // 默认收起状态

apps/web/src/components/ai/chat-box/AIAssistantPanel.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import type { QuickCommandRuntime } from '@/stores/useQuickCommands'
2+
import type { QuickCommandRuntime } from '@/stores/quickCommands'
33
import {
44
Check,
55
Copy,
@@ -22,16 +22,18 @@ import {
2222
DialogTitle,
2323
} from '@/components/ui/dialog'
2424
import { Textarea } from '@/components/ui/textarea'
25-
import useAIConfigStore from '@/stores/AIConfig'
26-
import { useQuickCommands } from '@/stores/useQuickCommands'
25+
import useAIConfigStore from '@/stores/aiConfig'
26+
import { useDisplayStore } from '@/stores/display'
27+
import { useEditorStore } from '@/stores/editor'
28+
import { useQuickCommands } from '@/stores/quickCommands'
2729
import { copyPlain } from '@/utils/clipboard'
2830
2931
/* ---------- 组件属性 ---------- */
3032
const props = defineProps<{ open: boolean }>()
3133
const emit = defineEmits([`update:open`])
3234
33-
const store = useStore()
34-
const { editor } = storeToRefs(store)
35+
const editorStore = useEditorStore()
36+
const { editor } = storeToRefs(editorStore)
3537
const displayStore = useDisplayStore()
3638
const { toggleAIImageDialog } = displayStore
3739

apps/web/src/components/ai/chat-box/AIConfig.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { serviceOptions } from '@md/shared/configs'
33
import { DEFAULT_SERVICE_TYPE } from '@md/shared/constants'
44
import { Info } from 'lucide-vue-next'
55
import { PasswordInput } from '@/components/ui/password-input'
6-
import useAIConfigStore from '@/stores/AIConfig'
6+
import useAIConfigStore from '@/stores/aiConfig'
77
88
/* -------------------------- 基础数据 -------------------------- */
99

apps/web/src/components/ai/chat-box/AIFixedBtn.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { Bot } from 'lucide-vue-next'
3-
import { useDisplayStore } from '@/stores'
3+
import { useDisplayStore } from '@/stores/display'
44
55
defineProps<{
66
isMobile: boolean

apps/web/src/components/ai/chat-box/QuickCommandManager.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Button } from '@/components/ui/button'
44
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
55
import { Input } from '@/components/ui/input'
66
import { Textarea } from '@/components/ui/textarea'
7-
import { useQuickCommands } from '@/stores/useQuickCommands'
7+
import { useQuickCommands } from '@/stores/quickCommands'
88
99
/* ---------- 弹窗开关 ---------- */
1010
const props = defineProps<{ open: boolean }>()

apps/web/src/components/ai/image-generator/AIImageConfig.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
SelectTrigger,
1313
SelectValue,
1414
} from '@/components/ui/select'
15-
import useAIImageConfigStore from '@/stores/AIImageConfig'
15+
import useAIImageConfigStore from '@/stores/aiImageConfig'
1616
1717
/* -------------------------- 基础数据 -------------------------- */
1818

apps/web/src/components/ai/image-generator/AIImageGeneratorBtn.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { Image as ImageIcon } from 'lucide-vue-next'
3-
import { useDisplayStore } from '@/stores'
3+
import { useDisplayStore } from '@/stores/display'
44
import AIImageGeneratorPanel from './AIImageGeneratorPanel.vue'
55
66
defineProps<{

apps/web/src/components/ai/image-generator/AIImageGeneratorPanel.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
Settings,
1010
Trash2,
1111
} from 'lucide-vue-next'
12-
import { storeToRefs } from 'pinia'
1312
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
1413
import { Button } from '@/components/ui/button'
1514
import {
@@ -20,8 +19,9 @@ import {
2019
DialogTitle,
2120
} from '@/components/ui/dialog'
2221
import { Textarea } from '@/components/ui/textarea'
23-
import { useDisplayStore, useStore } from '@/stores'
24-
import useAIImageConfigStore from '@/stores/AIImageConfig'
22+
import useAIImageConfigStore from '@/stores/aiImageConfig'
23+
import { useDisplayStore } from '@/stores/display'
24+
import { useEditorStore } from '@/stores/editor'
2525
import { copyPlain } from '@/utils/clipboard'
2626
import AIImageConfig from './AIImageConfig.vue'
2727
@@ -30,8 +30,8 @@ const props = defineProps<{ open: boolean }>()
3030
const emit = defineEmits([`update:open`])
3131
3232
/* ---------- 编辑器引用 ---------- */
33-
const store = useStore()
34-
const { editor } = storeToRefs(store)
33+
const editorStore = useEditorStore()
34+
const { editor } = storeToRefs(editorStore)
3535
const displayStore = useDisplayStore()
3636
const { toggleAIDialog } = displayStore
3737

apps/web/src/components/ai/tool-box/ToolBoxPopover.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
SelectTrigger,
1616
SelectValue,
1717
} from '@/components/ui/select'
18-
import useAIConfigStore from '@/stores/AIConfig'
18+
import useAIConfigStore from '@/stores/aiConfig'
19+
import { useEditorStore } from '@/stores/editor'
1920
2021
/* -------------------- props / emits -------------------- */
2122
const props = defineProps<{
@@ -40,7 +41,7 @@ const currentText = ref(``)
4041
const error = ref(``)
4142
4243
/* -------------------- store & refs -------------------- */
43-
const store = useStore()
44+
const editorStore = useEditorStore()
4445
const resultContainer = ref<HTMLElement | null>(null)
4546
4647
/* -------------------- dialog state sync -------------------- */
@@ -251,7 +252,7 @@ function stopAI() {
251252
252253
/* -------------------- actions -------------------- */
253254
function replaceText() {
254-
const editorView = toRaw(store.editor!)!
255+
const editorView = toRaw(editorStore.editor!)!
255256
const selection = editorView.state.selection.main
256257
editorView.dispatch(editorView.state.replaceSelection(message.value))
257258

0 commit comments

Comments
 (0)