mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
更多样的bing suno生成
This commit is contained in:
parent
991c63bb26
commit
b20a3db006
6 changed files with 208 additions and 69 deletions
|
|
@ -1242,3 +1242,36 @@ function maskString (str) {
|
|||
|
||||
return firstThreeChars + maskedChars + lastThreeChars
|
||||
}
|
||||
|
||||
/**
|
||||
* generated by ai
|
||||
* @param text
|
||||
* @returns {array}
|
||||
*/
|
||||
export function extractMarkdownJson(text) {
|
||||
const lines = text.split('\n')
|
||||
const mdJson = []
|
||||
let currentObj = null
|
||||
|
||||
lines.forEach(line => {
|
||||
if (line.startsWith('```json') && !currentObj) {
|
||||
// 开始一个新的JSON对象
|
||||
currentObj = { json: '' }
|
||||
} else if (line.startsWith('```') && currentObj) {
|
||||
// 结束当前的JSON对象
|
||||
try {
|
||||
// 尝试将JSON字符串转换为对象
|
||||
currentObj.json = JSON.parse(currentObj.json)
|
||||
mdJson.push(currentObj)
|
||||
currentObj = null
|
||||
} catch (e) {
|
||||
console.error('JSON解析错误:', e)
|
||||
}
|
||||
} else if (currentObj) {
|
||||
// 将行添加到当前的JSON对象
|
||||
currentObj.json += line
|
||||
}
|
||||
})
|
||||
|
||||
return mdJson.map(obj => obj.json)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue