-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c477d9e
commit 650ebcd
Showing
11 changed files
with
98 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export { default as IconFont } from "./icon-font/index"; | ||
export { default as Tabbar } from "./tabbar"; | ||
export { default as MainEmpty } from "./main-empty"; | ||
export { default as Slider } from "./slider"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export default {}; | ||
export { default as useKeyboardEnter } from "./useKeyboardEnter"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useRef } from "react"; | ||
|
||
export default function useKeyboardEnter(callback: () => void) { | ||
const ref = useRef<HTMLDivElement>(null); | ||
|
||
const handleKeyboardEnter = (e: React.KeyboardEvent<HTMLDivElement>) => { | ||
console.log(e.key); | ||
if (e.key === "Enter") { | ||
callback?.(); | ||
} | ||
}; | ||
|
||
return handleKeyboardEnter; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { useFileContent } from "@/store/useFileContent.store"; | ||
import MonacoEditor from "@monaco-editor/react"; | ||
export default function Editor() { | ||
const fileContent = useFileContent((state) => state.fileContent); | ||
const selectedFileInfo = useFileContent((state) => state.selectedFileInfo); | ||
const handleEditorMount = (editor: any, monaco: any) => { | ||
console.log("Editor mounted", editor, monaco); | ||
}; | ||
// 检查类型 | ||
const isTypescript = | ||
selectedFileInfo.name.endsWith(".ts") || | ||
selectedFileInfo.name.endsWith(".tsx"); | ||
const isJs = | ||
selectedFileInfo.name.endsWith(".js") || | ||
selectedFileInfo.name.endsWith(".jsx"); | ||
const isCss = | ||
selectedFileInfo.name.endsWith(".css") || | ||
selectedFileInfo.name.endsWith(".scss") || | ||
selectedFileInfo.name.endsWith(".less"); | ||
const isHtml = | ||
selectedFileInfo.name.endsWith(".html") || | ||
selectedFileInfo.name.endsWith(".razor") || | ||
selectedFileInfo.name.endsWith(".handlebars"); | ||
const isJson = selectedFileInfo.name.endsWith(".json"); | ||
|
||
const language = isTypescript | ||
? "typescript" | ||
: isJs | ||
? "javascript" | ||
: isCss | ||
? "css" | ||
: isHtml | ||
? "html" | ||
: isJson | ||
? "json" | ||
: "text"; | ||
|
||
return ( | ||
<div className="h-full w-full"> | ||
{selectedFileInfo.id ? ( | ||
<MonacoEditor | ||
height="100%" | ||
width="100%" | ||
language={language} | ||
theme="vs-dark" | ||
value={fileContent} | ||
onMount={handleEditorMount} | ||
/> | ||
) : null} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters