Skip to content

Commit cd53634

Browse files
committed
内置产品手册文章内部链接跳转
1 parent c96a6ad commit cd53634

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

web/src/apps/workspace/module/managementPlatform/component/library/index.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export default {
5252
});
5353
},
5454
saveContent(value, render) {
55+
/**
56+
* 备注:因为mavonEditor在把md转换为html时会自动给链接加上target="_blank",但如果链接本身href是以#开头,则忽略
57+
* 所以,如果需要在文章内部继续做链接跳转其他内置文章,可以把href设置为#id的形式
58+
*/
5559
SaveChapter({
5660
id: this.$route.query.id,
5761
content: value,

web/src/dss/module/footer/libraryDetail.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,13 @@ export default {
3535
handleAnchor(e) {
3636
// 文章内部链接跳转处理
3737
if (e.target.tagName == "A" && e.target.target != "_blank") {
38-
const match = e.target.href.match(/\/\d+\.html/g); // 暂定/17.html的格式
38+
/**
39+
* 备注:因为mavonEditor在把md转换为html时会自动给链接加上target="_blank",但如果链接本身href是以#开头,则忽略
40+
* 所以,如果需要在文章内部继续做链接跳转其他内置文章,可以把href设置为#id的形式
41+
*/
42+
const match = e.target.href.match(/#\d+/g); // id的格式为#id
3943
if (match && match[0]) {
40-
const id = match[0].match(/\d+/g)[0];
44+
const id = match[0].replace("#", "");
4145
GetChapterDetail(id).then((res) => {
4246
this.$emit("on-chapter-click", res.result)
4347
});

0 commit comments

Comments
 (0)