diff --git a/package-lock.json b/package-lock.json index 8c1eeed..dcb0654 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,6 +72,7 @@ "turndown": "^7.1.2", "typescript": "5.0.4", "xlsx": "^0.18.5", + "xml-formatter": "^3.6.0", "xml2js": "^0.6.2", "xmorse": "^1.0.0", "yarn": "^1.22.21" @@ -1748,6 +1749,21 @@ "glob": "7.1.7" } }, + "node_modules/@next/swc-darwin-arm64": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.0.4.tgz", + "integrity": "sha512-mF05E/5uPthWzyYDyptcwHptucf/jj09i2SXBPwNzbgBNc+XnwzrL0U6BmPjQeOL+FiB+iG1gwBeq7mlDjSRPg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@next/swc-darwin-x64": { "version": "14.0.4", "resolved": "https://registry.npmmirror.com/@next/swc-darwin-x64/-/swc-darwin-x64-14.0.4.tgz", @@ -1763,6 +1779,111 @@ "node": ">= 10" } }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.0.4.tgz", + "integrity": "sha512-VwwZKrBQo/MGb1VOrxJ6LrKvbpo7UbROuyMRvQKTFKhNaXjUmKTu7wxVkIuCARAfiI8JpaWAnKR+D6tzpCcM4w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.0.4.tgz", + "integrity": "sha512-8QftwPEW37XxXoAwsn+nXlodKWHfpMaSvt81W43Wh8dv0gkheD+30ezWMcFGHLI71KiWmHK5PSQbTQGUiidvLQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.0.4.tgz", + "integrity": "sha512-/s/Pme3VKfZAfISlYVq2hzFS8AcAIOTnoKupc/j4WlvF6GQ0VouS2Q2KEgPuO1eMBwakWPB1aYFIA4VNVh667A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.0.4.tgz", + "integrity": "sha512-m8z/6Fyal4L9Bnlxde5g2Mfa1Z7dasMQyhEhskDATpqr+Y0mjOBZcXQ7G5U+vgL22cI4T7MfvgtrM2jdopqWaw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.0.4.tgz", + "integrity": "sha512-7Wv4PRiWIAWbm5XrGz3D8HUkCVDMMz9igffZG4NB1p4u1KoItwx9qjATHz88kwCEal/HXmbShucaslXCQXUM5w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.0.4.tgz", + "integrity": "sha512-zLeNEAPULsl0phfGb4kdzF/cAVIfaC7hY+kt0/d+y9mzcZHsMS3hAS829WbJ31DkSlVKQeHEjZHIdhN+Pg7Gyg==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.0.4.tgz", + "integrity": "sha512-yEh2+R8qDlDCjxVpzOTEpBLQTEFAcP2A8fUFLaWNap9GitYKkKv1//y2S6XY6zsR4rCOPRpU7plYDR+az2n30A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmmirror.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -9291,6 +9412,25 @@ "node": ">=0.8" } }, + "node_modules/xml-formatter": { + "version": "3.6.0", + "resolved": "https://registry.npmmirror.com/xml-formatter/-/xml-formatter-3.6.0.tgz", + "integrity": "sha512-Wic80ENNLF/5mLcc82hVLmoOWQlLDJtVv+N1/hkP4hBuVXPLKrXo92/4V23QYPKfUxvCU6Y2AcdpHCIA/xexFw==", + "dependencies": { + "xml-parser-xo": "^4.1.0" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/xml-parser-xo": { + "version": "4.1.1", + "resolved": "https://registry.npmmirror.com/xml-parser-xo/-/xml-parser-xo-4.1.1.tgz", + "integrity": "sha512-Ggf2y90+Y6e9IK5hoPuembVHJ03PhDSdhldEmgzbihzu9k0XBo0sfcFxaSi4W1PlUSSI1ok+MJ0JCXUn+U4Ilw==", + "engines": { + "node": ">= 14" + } + }, "node_modules/xml2js": { "version": "0.6.2", "resolved": "https://registry.npmmirror.com/xml2js/-/xml2js-0.6.2.tgz", @@ -9443,126 +9583,6 @@ "version": "2.0.4", "resolved": "https://registry.npmmirror.com/zwitch/-/zwitch-2.0.4.tgz", "integrity": "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==" - }, - "node_modules/@next/swc-darwin-arm64": { - "version": "14.0.4", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.0.4.tgz", - "integrity": "sha512-mF05E/5uPthWzyYDyptcwHptucf/jj09i2SXBPwNzbgBNc+XnwzrL0U6BmPjQeOL+FiB+iG1gwBeq7mlDjSRPg==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-gnu": { - "version": "14.0.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.0.4.tgz", - "integrity": "sha512-VwwZKrBQo/MGb1VOrxJ6LrKvbpo7UbROuyMRvQKTFKhNaXjUmKTu7wxVkIuCARAfiI8JpaWAnKR+D6tzpCcM4w==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-arm64-musl": { - "version": "14.0.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.0.4.tgz", - "integrity": "sha512-8QftwPEW37XxXoAwsn+nXlodKWHfpMaSvt81W43Wh8dv0gkheD+30ezWMcFGHLI71KiWmHK5PSQbTQGUiidvLQ==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-gnu": { - "version": "14.0.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.0.4.tgz", - "integrity": "sha512-/s/Pme3VKfZAfISlYVq2hzFS8AcAIOTnoKupc/j4WlvF6GQ0VouS2Q2KEgPuO1eMBwakWPB1aYFIA4VNVh667A==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-linux-x64-musl": { - "version": "14.0.4", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.0.4.tgz", - "integrity": "sha512-m8z/6Fyal4L9Bnlxde5g2Mfa1Z7dasMQyhEhskDATpqr+Y0mjOBZcXQ7G5U+vgL22cI4T7MfvgtrM2jdopqWaw==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-arm64-msvc": { - "version": "14.0.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.0.4.tgz", - "integrity": "sha512-7Wv4PRiWIAWbm5XrGz3D8HUkCVDMMz9igffZG4NB1p4u1KoItwx9qjATHz88kwCEal/HXmbShucaslXCQXUM5w==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-ia32-msvc": { - "version": "14.0.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.0.4.tgz", - "integrity": "sha512-zLeNEAPULsl0phfGb4kdzF/cAVIfaC7hY+kt0/d+y9mzcZHsMS3hAS829WbJ31DkSlVKQeHEjZHIdhN+Pg7Gyg==", - "cpu": [ - "ia32" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } - }, - "node_modules/@next/swc-win32-x64-msvc": { - "version": "14.0.4", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.0.4.tgz", - "integrity": "sha512-yEh2+R8qDlDCjxVpzOTEpBLQTEFAcP2A8fUFLaWNap9GitYKkKv1//y2S6XY6zsR4rCOPRpU7plYDR+az2n30A==", - "cpu": [ - "x64" - ], - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 10" - } } } } diff --git a/package.json b/package.json index 6632747..ffeeb02 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "turndown": "^7.1.2", "typescript": "5.0.4", "xlsx": "^0.18.5", + "xml-formatter": "^3.6.0", "xml2js": "^0.6.2", "xmorse": "^1.0.0", "yarn": "^1.22.21" diff --git a/src/components/Formater/index.tsx b/src/components/Formater/index.tsx new file mode 100644 index 0000000..26c0ef6 --- /dev/null +++ b/src/components/Formater/index.tsx @@ -0,0 +1,305 @@ +import alert from '@/components/Alert'; +import React, { useCallback, useEffect, useState } from 'react'; +import { Box, Grid, Button } from '@mui/material'; +import { CopyToClipboard } from 'react-copy-to-clipboard'; +import ContentCopyIcon from '@mui/icons-material/ContentCopy'; +import DownloadIcon from '@mui/icons-material/Download'; +import DeleteIcon from '@mui/icons-material/Delete'; +import FileUploadIcon from '@mui/icons-material/FileUpload'; +import MenuItem from '@mui/material/MenuItem'; +import FormControl from '@mui/material/FormControl'; +import Select from '@mui/material/Select'; +import AceEditor from 'react-ace'; +import xmlFormat from 'xml-formatter'; +import * as prettier from 'prettier/standalone'; +import babelPlugin from 'prettier/plugins/babel'; +import yamlPlugin from 'prettier/plugins/yaml'; +import htmlPlugin from 'prettier/plugins/html'; +import cssPlugin from 'prettier/plugins/postcss'; +import tsPlugin from 'prettier/plugins/typescript'; +import estree from 'prettier/plugins/estree'; + +import 'ace-builds/src-noconflict/ext-language_tools'; +import 'ace-builds/src-noconflict/mode-javascript'; +import 'ace-builds/src-noconflict/mode-css'; +import 'ace-builds/src-noconflict/mode-typescript'; +import 'ace-builds/src-noconflict/mode-html'; +import 'ace-builds/src-noconflict/mode-yaml'; +import 'ace-builds/src-noconflict/mode-xml'; +import 'ace-builds/src-noconflict/mode-json'; +import 'ace-builds/src-noconflict/theme-monokai'; + +export enum Mode { + CSS = 'css', + JavaScript = 'javascript', + TypeScript = 'typescript', + HTML = 'html', + YAML = 'yaml', + XML = 'xml', + JSON = 'json', +} + +interface FormaterProps { + mock: string; + mode: Mode; + accept: string; +} + +const Formater: React.FC = ({ mock, mode, accept }) => { + const [cnt, setCnt] = useState(''); + const [fcnt, setFmtCnt] = useState(''); + const [indent, setIndent] = useState(2); + + const handleCopy = useCallback(() => { + alert.success('复制成功'); + }, []); + + const handleFileChange = (event: any) => { + const file = event.target.files[0]; + + if (file) { + const reader = new FileReader(); + reader.onload = (e: any) => { + const content = e.target.result; + format(content, indent); + }; + reader.readAsText(file); + } + }; + + const handleUploadClick = () => { + const fileInput = document.getElementById('fileInput'); + fileInput?.click(); + }; + + const getFileExt = () => { + switch (mode) { + case Mode.CSS: + return '.css'; + case Mode.JavaScript: + return '.js'; + case Mode.TypeScript: + return '.ts'; + case Mode.HTML: + return '.html'; + case Mode.YAML: + return '.yaml'; + case Mode.XML: + return '.xml'; + case Mode.JSON: + return '.json'; + } + }; + + const downloadFile = () => { + const blob = new Blob([fcnt]); + const link = document.createElement('a'); + link.href = window.URL.createObjectURL(blob); + const t = new Date().getTime(); + link.download = t.toString() + getFileExt(); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + }; + + const getParser = () => { + switch (mode) { + case Mode.CSS: + return 'css'; + case Mode.JavaScript: + return 'babel'; + case Mode.TypeScript: + return 'typescript'; + case Mode.HTML: + return 'html'; + case Mode.YAML: + return 'yaml'; + } + }; + + const getPlugin = () => { + switch (mode) { + case Mode.CSS: + return [cssPlugin]; + case Mode.JavaScript: + return [babelPlugin, estree]; + case Mode.TypeScript: + return [tsPlugin, estree]; + case Mode.HTML: + return [htmlPlugin]; + case Mode.YAML: + return [yamlPlugin]; + } + }; + + const format = (s: string, indent: number) => { + setCnt(s); + if (s.length == 0) { + setFmtCnt(''); + return; + } + + try { + switch (mode) { + case Mode.XML: + const fmt = xmlFormat(s, { + indentation: ' '.repeat(indent), + }); + setFmtCnt(fmt); + break; + + case Mode.JSON: + let a = JSON.parse(s); + setFmtCnt(JSON.stringify(a, null, indent)); + break; + + default: + prettier + .format(s, { + parser: getParser(), + plugins: getPlugin(), + tabWidth: indent, + embeddedLanguageFormatting: 'auto', + endOfLine: 'auto', + }) + .then((s) => { + setFmtCnt(s); + }); + } + } catch (error) { + setFmtCnt('无效的内容'); + } + }; + + useEffect(() => { + format(mock, 2); + }, []); + + return ( + + + +
输入
+ + + + +
+ + { + format(s, indent); + }} + tabSize={2} + /> + +
+ + + +
输出
+ + + + + + + + + + + +
+ + +
+
+ ); +}; + +export default Formater; diff --git a/src/pages/cssfmt.tsx b/src/pages/cssfmt.tsx new file mode 100644 index 0000000..460659f --- /dev/null +++ b/src/pages/cssfmt.tsx @@ -0,0 +1,16 @@ +import MainContent from '@/components/MainContent'; +import Formater, { Mode } from '@/components/Formater'; +import React from 'react'; + +const mock = + '.a{position:absolute;box-sizing:border-box;min-width:100%;contain:style size layout;font-variant-ligatures:no-common-ligatures;}.a:focus{box-shadow:inset 0 0 0 2px #5E9ED6;outline:none;}'; + +const CSSFmt: React.FC = () => { + return ( + + + + ); +}; + +export default CSSFmt; diff --git a/src/pages/htmlfmt.tsx b/src/pages/htmlfmt.tsx new file mode 100644 index 0000000..b5b0d47 --- /dev/null +++ b/src/pages/htmlfmt.tsx @@ -0,0 +1,15 @@ +import MainContent from '@/components/MainContent'; +import Formater, { Mode } from '@/components/Formater'; +import React from 'react'; + +const mock = '

Hello Chaitin

'; + +const HTMLFmt: React.FC = () => { + return ( + + + + ); +}; + +export default HTMLFmt; diff --git a/src/pages/jsfmt.tsx b/src/pages/jsfmt.tsx new file mode 100644 index 0000000..5a1863e --- /dev/null +++ b/src/pages/jsfmt.tsx @@ -0,0 +1,16 @@ +import MainContent from '@/components/MainContent'; +import Formater, { Mode } from '@/components/Formater'; +import React from 'react'; + +const mock = + 'function fibonacci(n){if(n<=1){return n}else{return fibonacci(n-1)+fibonacci(n-2)}}for(let i=0;i<10;i++){console.log(fibonacci(i))}'; + +const JSFmt: React.FC = () => { + return ( + + + + ); +}; + +export default JSFmt; diff --git a/src/pages/jsonfmt.tsx b/src/pages/jsonfmt.tsx index 6c38da9..41211ce 100644 --- a/src/pages/jsonfmt.tsx +++ b/src/pages/jsonfmt.tsx @@ -1,187 +1,13 @@ -import alert from '@/components/Alert'; import MainContent from '@/components/MainContent'; -import React, { useCallback, useEffect, useState } from 'react'; -import { Box, Grid, Button } from '@mui/material'; -import { CopyToClipboard } from 'react-copy-to-clipboard'; -import ContentCopyIcon from '@mui/icons-material/ContentCopy'; -import DownloadIcon from '@mui/icons-material/Download'; -import DeleteIcon from '@mui/icons-material/Delete'; -import FileUploadIcon from '@mui/icons-material/FileUpload'; -import AceEditor from 'react-ace'; - -import 'ace-builds/src-noconflict/ext-language_tools'; -import 'ace-builds/src-noconflict/mode-json'; -import 'ace-builds/src-noconflict/theme-monokai'; +import Formater, { Mode } from '@/components/Formater'; +import React from 'react'; const mock = '{"id": 1, "name": "test"}'; const JsonFmt: React.FC = () => { - const [json, setJson] = useState(''); - const [fjson, setFjson] = useState(''); - - const handleCopy = useCallback(() => { - alert.success('复制成功'); - }, []); - - const handleFileChange = (event: any) => { - const file = event.target.files[0]; - - if (file) { - if (file.type === 'application/json') { - const reader = new FileReader(); - - reader.onload = (e: any) => { - const content = e.target.result; - fmtJson(content); - }; - - reader.readAsText(file); - } else { - setJson(''); - alert.error('无效的文件'); - } - } - }; - - const handleUploadClick = () => { - const fileInput = document.getElementById('fileInput'); - fileInput?.click(); - }; - - const downloadFile = () => { - const blob = new Blob([fjson], { type: 'application/json;charset=utf-8;' }); - const link = document.createElement('a'); - link.href = window.URL.createObjectURL(blob); - const t = new Date().getTime(); - link.download = t.toString() + '.json'; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); - }; - - const fmtJson = (s: string) => { - setJson(s); - if (s.length == 0) { - setFjson(''); - return; - } - - try { - let a = JSON.parse(s); - setFjson(JSON.stringify(a, null, 2)); - } catch (error) { - setFjson('无效的 JSON'); - } - }; - - useEffect(() => { - fmtJson(mock); - }, []); - return ( - - - -
输入
- - - - -
- - - -
- - - -
输出
- - - - - - - -
- - -
-
+
); }; diff --git a/src/pages/tsfmt.tsx b/src/pages/tsfmt.tsx new file mode 100644 index 0000000..6f46291 --- /dev/null +++ b/src/pages/tsfmt.tsx @@ -0,0 +1,16 @@ +import MainContent from '@/components/MainContent'; +import Formater, { Mode } from '@/components/Formater'; +import React from 'react'; + +const mock = + "interface MyInterface {\n foo(): string,\n bar: Array,\n}\n\nexport abstract class Foo implements MyInterface {\n foo() {\n // TODO: return an actual value here\n return 'hello'\n }\n get bar() {\n return [ 1,\n\n 2, 3,\n ]\n }\n}\n\ntype RequestType = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'OPTIONS' | 'CONNECT' | 'DELETE' | 'TRACE'\n"; + +const TSFmt: React.FC = () => { + return ( + + + + ); +}; + +export default TSFmt; diff --git a/src/pages/xmlfmt.tsx b/src/pages/xmlfmt.tsx new file mode 100644 index 0000000..a615032 --- /dev/null +++ b/src/pages/xmlfmt.tsx @@ -0,0 +1,15 @@ +import MainContent from '@/components/MainContent'; +import Formater, { Mode } from '@/components/Formater'; +import React from 'react'; + +const mock = 'Chaitin'; + +const XMLFmt: React.FC = () => { + return ( + + + + ); +}; + +export default XMLFmt; diff --git a/src/pages/yamlfmt.tsx b/src/pages/yamlfmt.tsx new file mode 100644 index 0000000..c36a002 --- /dev/null +++ b/src/pages/yamlfmt.tsx @@ -0,0 +1,15 @@ +import MainContent from '@/components/MainContent'; +import Formater, { Mode } from '@/components/Formater'; +import React from 'react'; + +const mock = 'a : test\nb:\n- b1\n- b2'; + +const YamlFmt: React.FC = () => { + return ( + + + + ); +}; + +export default YamlFmt; diff --git a/src/utils/tags.ts b/src/utils/tags.ts index 3f2ec8f..574bc26 100644 --- a/src/utils/tags.ts +++ b/src/utils/tags.ts @@ -29,6 +29,7 @@ export enum Tags { BINARY = 'binary', SECURITY = 'security', OFFICIAL = 'official', + FORMAT = 'format', } const tagColor = [ ['rgba(245, 117, 130, 1)', 'rgba(245, 117, 130, 0.2)'], @@ -154,6 +155,14 @@ export const allTags: Tag[] = [ bg_color: '', avatar_color: '', }, + { + name: Tags.FORMAT, + icon: icon_encode, + icon_check: icon_encode_check, + label: '格式化', + bg_color: '', + avatar_color: '', + }, { name: Tags.SECURITY, icon: icon_encode, diff --git a/src/utils/tools.ts b/src/utils/tools.ts index 7329b81..72aa575 100644 --- a/src/utils/tools.ts +++ b/src/utils/tools.ts @@ -170,7 +170,7 @@ export const allTools: Tool[] = [ }, { label: 'JSON 格式化', - tags: [Tags.JSON], + tags: [Tags.JSON, Tags.FORMAT], path: '/jsonfmt', subTitle: 'JSON 格式化小工具。', key: [], @@ -416,4 +416,46 @@ export const allTools: Tool[] = [ key: [], subTitle: '视频提取音频小工具', }, + { + label: 'HTML 格式化', + tags: [Tags.FORMAT], + path: '/htmlfmt', + key: [], + subTitle: 'HTML 格式化小工具', + }, + { + label: 'XML 格式化', + tags: [Tags.FORMAT], + path: '/xmlfmt', + key: [], + subTitle: 'XML 格式化小工具', + }, + { + label: 'CSS 格式化', + tags: [Tags.FORMAT], + path: '/cssfmt', + key: [], + subTitle: 'CSS 格式化小工具', + }, + { + label: 'YAML 格式化', + tags: [Tags.FORMAT], + path: '/yamlfmt', + key: [], + subTitle: 'YAML 格式化小工具', + }, + { + label: 'JavaScript 格式化', + tags: [Tags.FORMAT], + path: '/jsfmt', + key: [], + subTitle: 'JavaScript 格式化小工具', + }, + { + label: 'TypeScript 格式化', + tags: [Tags.FORMAT], + path: '/tsfmt', + key: [], + subTitle: 'TypeScript 格式化小工具', + }, ];