fix(code-editor): ensure localStorage access is safe in non-browser environments

This commit is contained in:
cfngc4594 2025-03-02 14:39:04 +08:00
parent 8be38cee1d
commit 524cce5a73

View File

@ -197,7 +197,9 @@ export default function CodeEditor() {
};
function handleEditorChange(value: string | undefined) {
localStorage.setItem(`code-editor-value-${language}`, value ?? "");
if (typeof window !== "undefined") {
localStorage.setItem(`code-editor-value-${language}`, value ?? "");
}
}
const editorValue =