!657 修复表单构建页面,json显示和复制问题,调整highlight废弃的方法

Merge pull request !657 from SamllNorth_Lee/form-build/dev
pull/655/MERGE
芋道源码 2025-01-15 12:42:49 +00:00 committed by Gitee
commit ece0ccd6df
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 6 additions and 4 deletions

View File

@ -135,7 +135,8 @@ const makeTemplate = () => {
/** 复制 **/
const copy = async (text: string) => {
const { copy, copied, isSupported } = useClipboard({ source: text })
const textToCopy = JSON.stringify(text, null, 2)
const { copy, copied, isSupported } = useClipboard({ source: textToCopy })
if (!isSupported) {
message.error(t('common.copyError'))
} else {
@ -149,17 +150,18 @@ const copy = async (text: string) => {
/**
* 代码高亮
*/
const highlightedCode = (code) => {
const highlightedCode = (code: string) => {
//
let language = 'json'
if (formType.value === 2) {
language = 'xml'
}
// debugger
if (!isString(code)) {
code = JSON.stringify(code)
code = JSON.stringify(code, null, 2)
}
//
const result = hljs.highlight(language, code, true)
const result = hljs.highlight(code, { language: language, ignoreIllegals: true })
return result.value || ' '
}