diff --git a/frontend/src/modules/editor/api/index.ts b/frontend/src/modules/editor/api/index.ts index e69de29..e7ebf37 100644 --- a/frontend/src/modules/editor/api/index.ts +++ b/frontend/src/modules/editor/api/index.ts @@ -0,0 +1,19 @@ +import api from '@/shared/api' +import type { EditableFile, ImpactResult, ScanResult } from '@/shared/types/api' + +export async function getFile(projectId: string, path: string): Promise { + const { data } = await api.get(`/projects/${projectId}/files/${path}`) + return data +} + +export async function saveFile(projectId: string, path: string, content: string): Promise { + const { data } = await api.put(`/projects/${projectId}/files/${path}`, content, { + headers: { 'Content-Type': 'text/plain' }, + }) + return data +} + +export async function getFileImpact(projectId: string, path: string): Promise { + const { data } = await api.get(`/projects/${projectId}/files/${path}/impact`) + return data +} diff --git a/frontend/src/modules/editor/components/CsvEditor.vue b/frontend/src/modules/editor/components/CsvEditor.vue index e69de29..2fa3a10 100644 --- a/frontend/src/modules/editor/components/CsvEditor.vue +++ b/frontend/src/modules/editor/components/CsvEditor.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/frontend/src/modules/editor/components/EditorPage.vue b/frontend/src/modules/editor/components/EditorPage.vue new file mode 100644 index 0000000..5956af1 --- /dev/null +++ b/frontend/src/modules/editor/components/EditorPage.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/frontend/src/modules/editor/components/MdEditor.vue b/frontend/src/modules/editor/components/MdEditor.vue index e69de29..de3be8f 100644 --- a/frontend/src/modules/editor/components/MdEditor.vue +++ b/frontend/src/modules/editor/components/MdEditor.vue @@ -0,0 +1,39 @@ + + + + + diff --git a/frontend/src/modules/editor/composables/useEditor.ts b/frontend/src/modules/editor/composables/useEditor.ts index e69de29..5a6f046 100644 --- a/frontend/src/modules/editor/composables/useEditor.ts +++ b/frontend/src/modules/editor/composables/useEditor.ts @@ -0,0 +1,40 @@ +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(null) + const impactResult = ref(null) + const saving = ref(false) + const error = ref(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 } +}) diff --git a/frontend/src/modules/editor/types/index.ts b/frontend/src/modules/editor/types/index.ts index e69de29..0c6cc0d 100644 --- a/frontend/src/modules/editor/types/index.ts +++ b/frontend/src/modules/editor/types/index.ts @@ -0,0 +1 @@ +export type { EditableFile, ImpactResult, ImplProgress } from '@/shared/types/api'