arch-design-agent-skill-das.../frontend/src/modules/editor/composables/useEditor.ts
openclaw ce4f474472 feat(fe-editor): add CSV table editor and Markdown editor components
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 17:20:38 +00:00

41 lines
1.2 KiB
TypeScript

import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { EditableFile, ImpactResult } from '@/shared/types/api'
import * as editorApi from '../api'
export const useEditorStore = defineStore('editor', () => {
const currentFile = ref<EditableFile | null>(null)
const impactResult = ref<ImpactResult | null>(null)
const saving = ref(false)
const error = ref<string | null>(null)
async function loadFile(projectId: string, path: string) {
try {
currentFile.value = await editorApi.getFile(projectId, path)
} catch (e: any) {
error.value = e.message
}
}
async function saveFile(projectId: string, path: string, content: string) {
saving.value = true
try {
await editorApi.saveFile(projectId, path, content)
} catch (e: any) {
error.value = e.message
} finally {
saving.value = false
}
}
async function analyzeImpact(projectId: string, path: string) {
try {
impactResult.value = await editorApi.getFileImpact(projectId, path)
} catch (e: any) {
error.value = e.message
}
}
return { currentFile, impactResult, saving, error, loadFile, saveFile, analyzeImpact }
})