|
@@ -6,6 +6,9 @@ import { replaceKeywordWithRichText } from '@jy/util'
|
|
|
const thirdPartyVerify = useThirdPartyVerifyModel()
|
|
|
|
|
|
class ContentModel extends BaseModel {
|
|
|
+ // 引流关键词组
|
|
|
+ _highlightGuideKeyMaps = {}
|
|
|
+
|
|
|
constructor(config) {
|
|
|
super(config)
|
|
|
}
|
|
@@ -18,7 +21,15 @@ class ContentModel extends BaseModel {
|
|
|
summary: false
|
|
|
},
|
|
|
content: useCommonTitleModel().createModel(),
|
|
|
- summary: useSummaryModel().createModel()
|
|
|
+ summary: useSummaryModel().createModel(),
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 关键词组替换
|
|
|
+ addGuideKey (desc, keys, fn) {
|
|
|
+ this._highlightGuideKeyMaps[desc] = {
|
|
|
+ keys,
|
|
|
+ fn
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -45,7 +56,7 @@ class ContentModel extends BaseModel {
|
|
|
} catch (error) {
|
|
|
console.log(error)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
try {
|
|
|
result.content.contentHighlighted = this.highlightContentHTML(result.content.content, data, result)
|
|
|
} catch (error) {
|
|
@@ -131,6 +142,22 @@ class ContentModel extends BaseModel {
|
|
|
if (content) {
|
|
|
content = thirdPartyVerify.replaceKeysAndInsertMark(content)
|
|
|
}
|
|
|
+
|
|
|
+ // 插入画像引流关键词
|
|
|
+ if (content && baseInfo) {
|
|
|
+ for (const guideKey in this._highlightGuideKeyMaps) {
|
|
|
+ const guideKeyItem = this._highlightGuideKeyMaps[guideKey]
|
|
|
+ if (Array.isArray(guideKeyItem?.keys)) {
|
|
|
+ for (let i = 0; i < guideKeyItem.keys.length; i++) {
|
|
|
+ const rKey = guideKeyItem.keys[i]
|
|
|
+ const rRich = typeof guideKeyItem.fn === 'function' ? guideKeyItem.fn({ rKey, guideKey, buyer: summary.originMap.buyer }) : '<span class="highlight-text">$1</span>'
|
|
|
+ content = replaceKeywordWithRichText(content, rKey, rRich)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// ------------------
|
|
|
// 关键词高亮
|
|
|
let highlightKeys = []
|