-
Notifications
You must be signed in to change notification settings - Fork 4
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
fa6ec5f
commit a7cd372
Showing
7 changed files
with
202 additions
and
6 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -17,3 +17,7 @@ | |
border-radius: 6px; | ||
} | ||
|
||
.json-input{ | ||
height: calc(100vh - 100px) !important; | ||
overflow-y: auto; | ||
} |
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,32 @@ | ||
import { useState } from "react"; | ||
import { Col, Row, message } from "antd" | ||
import { Input } from 'antd'; | ||
import ReactJson from 'react-json-view' | ||
import './index.scss' | ||
|
||
const { TextArea } = Input; | ||
|
||
const JsonFormatting = () => { | ||
const [jsonData, setJsonData] = useState({}); | ||
|
||
const handleJsonData = (e:any) => { | ||
try { | ||
setJsonData(JSON.parse(e.target.value)) | ||
} catch { | ||
message.error('请检查输入的JSON格式是否正确') | ||
} | ||
} | ||
|
||
return <Row gutter={[16, 16]}> | ||
<Col span={10}> | ||
<TextArea className="json-input" onChange={(e) => handleJsonData(e)}/> | ||
</Col> | ||
<Col span={14}> | ||
<div className="json-input"> | ||
<ReactJson src={jsonData} theme={"monokai"}/> | ||
</div> | ||
</Col> | ||
</Row> | ||
} | ||
|
||
export default JsonFormatting |
Oops, something went wrong.