feat(ai-house): 支持 Markdown 并优化找房交互

This commit is contained in:
2026-08-08 06:48:09 +08:00
parent d6861ab8c4
commit 87890a10ed
8 changed files with 138 additions and 241 deletions
@@ -0,0 +1,34 @@
/**
* @fileoverview markdown 插件
* Include marked (https://github.com/markedjs/marked)
* Include github-markdown-css (https://github.com/sindresorhus/github-markdown-css)
*/
const marked = require('./marked.min')
let index = 0
function Markdown (vm) {
this.vm = vm
vm._ids = {}
}
Markdown.prototype.onUpdate = function (content) {
if (this.vm.markdown) {
return marked(content)
}
}
Markdown.prototype.onParse = function (node, vm) {
if (vm.options.markdown) {
// 中文 id 需要转换,否则无法跳转
if (vm.options.useAnchor && node.attrs && /[\u4e00-\u9fa5]/.test(node.attrs.id)) {
const id = 't' + index++
this.vm._ids[node.attrs.id] = id
node.attrs.id = id
}
if (node.name === 'p' || node.name === 'table' || node.name === 'tr' || node.name === 'th' || node.name === 'td' || node.name === 'blockquote' || node.name === 'pre' || node.name === 'code') {
node.attrs.class = `md-${node.name} ${node.attrs.class || ''}`
}
}
}
module.exports = Markdown
File diff suppressed because one or more lines are too long
@@ -39,7 +39,7 @@
// #ifndef APP-PLUS-NVUE
import node from './node/node'
// #endif
const plugins=[]
const plugins=[require('./markdown/index.js')]
const Parser = require('./parser')
// #ifdef APP-PLUS-NVUE
const dom = weex.requireModule('dom')
@@ -55,6 +55,7 @@ export default {
}
},
props: {
markdown: Boolean,
containerStyle: {
type: String,
default: ''
@@ -152,6 +153,7 @@ export default {
* @returns {Promise}
*/
navigateTo (id, offset) {
id = this._ids[decodeURI(id)] || id
return new Promise((resolve, reject) => {
if (!this.useAnchor) {
reject(Error('Anchor is disabled'))