chore(store): update CodeEditorStore for LSP config changes

This commit is contained in:
cfngc4594 2025-03-16 15:40:00 +08:00
parent ff8eff5891
commit 31c5d86f2c

View File

@ -1,19 +1,17 @@
import { create } from "zustand"; import { create } from "zustand";
import { getPath } from "@/lib/utils";
import type { editor } from "monaco-editor"; import type { editor } from "monaco-editor";
import { EditorLanguage } from "@prisma/client";
import { JudgeResultMetadata } from "@/types/judge"; import { JudgeResultMetadata } from "@/types/judge";
import { createJSONStorage, persist } from "zustand/middleware"; import { createJSONStorage, persist } from "zustand/middleware";
import { LanguageServerMetadata } from "@/types/language-server";
import { DefaultEditorOptionConfig } from "@/config/editor-option"; import { DefaultEditorOptionConfig } from "@/config/editor-option";
import { DEFAULT_EDITOR_LANGUAGE } from "@/config/editor-language"; import { DEFAULT_EDITOR_LANGUAGE } from "@/config/editor-language";
import { EditorLanguage, LanguageServerConfig } from "@prisma/client";
interface CodeEditorState { interface CodeEditorState {
hydrated: boolean; hydrated: boolean;
language: EditorLanguage; language: EditorLanguage;
path: string; path: string;
value: string; value: string;
lspConfig: LanguageServerMetadata | null; lspConfig: LanguageServerConfig | null;
isLspEnabled: boolean; isLspEnabled: boolean;
editorConfig: editor.IEditorConstructionOptions; editorConfig: editor.IEditorConstructionOptions;
editor: editor.IStandaloneCodeEditor | null; editor: editor.IStandaloneCodeEditor | null;
@ -22,7 +20,7 @@ interface CodeEditorState {
setLanguage: (language: EditorLanguage) => void; setLanguage: (language: EditorLanguage) => void;
setPath: (path: string) => void; setPath: (path: string) => void;
setValue: (value: string) => void; setValue: (value: string) => void;
setLspConfig: (lspConfig: LanguageServerMetadata) => void; setLspConfig: (lspConfig: LanguageServerConfig | null) => void;
setIsLspEnabled: (enabled: boolean) => void; setIsLspEnabled: (enabled: boolean) => void;
setEditorConfig: (editorConfig: editor.IEditorConstructionOptions) => void; setEditorConfig: (editorConfig: editor.IEditorConstructionOptions) => void;
setEditor: (editor: editor.IStandaloneCodeEditor) => void; setEditor: (editor: editor.IStandaloneCodeEditor) => void;
@ -34,7 +32,7 @@ export const useCodeEditorStore = create<CodeEditorState>()(
(set) => ({ (set) => ({
hydrated: false, hydrated: false,
language: DEFAULT_EDITOR_LANGUAGE, language: DEFAULT_EDITOR_LANGUAGE,
path: getPath(DEFAULT_EDITOR_LANGUAGE), path: "",
value: "", value: "",
lspConfig: null, lspConfig: null,
isLspEnabled: true, isLspEnabled: true,