Commit 7210f85a authored by 徐一鸣's avatar 徐一鸣

开发文档fixed

parent d7e9ff18
...@@ -65,57 +65,60 @@ export default { ...@@ -65,57 +65,60 @@ export default {
}, },
methods: { methods: {
translate() { translate() {
let content = this.richText; let content = this.richText || "";
let titles =
content.match(
/<h1(([\s\S])*?)<\/h1>|<h2(([\s\S])*?)<\/h2>|<h3(([\s\S])*?)<\/h3>/g
) || [];
let time = new Date().getTime();
let pre_h1_index = 0;
let pre_h2_index = 0;
let pre_h3_index = 0;
let newTitles = titles
.map((title, index) => {
let newTitle = title;
let level = 0;
let id = "";
if (title.match(/<h1(([\s\S])*?)<\/h1>/g)) { if (content) {
pre_h1_index++; let titles =
pre_h2_index = 0; content.match(
pre_h3_index = 0; /<h1(([\s\S])*?)<\/h1>|<h2(([\s\S])*?)<\/h2>|<h3(([\s\S])*?)<\/h3>/g
level = 1; ) || [];
id = `nav_${pre_h1_index}` + "_" + time; let time = new Date().getTime();
let pre_h1_index = 0;
let pre_h2_index = 0;
let pre_h3_index = 0;
let newTitles = titles
.map((title, index) => {
let newTitle = title;
let level = 0;
let id = "";
newTitle = title.replace(/<h1/g, `<h1 id="${id}"`); if (title.match(/<h1(([\s\S])*?)<\/h1>/g)) {
} else if (title.match(/<h2(([\s\S])*?)<\/h2>/g)) { pre_h1_index++;
pre_h2_index++; pre_h2_index = 0;
pre_h3_index = 0; pre_h3_index = 0;
level = 2; level = 1;
id = `nav_${pre_h1_index}_${pre_h2_index}` + "_" + time; id = `nav_${pre_h1_index}` + "_" + time;
newTitle = title.replace(/<h2/g, `<h2 id="${id}"`); newTitle = title.replace(/<h1/g, `<h1 id="${id}"`);
} else if (title.match(/<h3(([\s\S])*?)<\/h3>/g)) { } else if (title.match(/<h2(([\s\S])*?)<\/h2>/g)) {
pre_h3_index++; pre_h2_index++;
level = 3; pre_h3_index = 0;
id = `nav_${pre_h1_index}_${pre_h2_index}_${pre_h3_index}`; level = 2;
id = `nav_${pre_h1_index}_${pre_h2_index}` + "_" + time;
newTitle = title.replace(/<h3/g, `<h3 id="${id}"`) + "_" + time; newTitle = title.replace(/<h2/g, `<h2 id="${id}"`);
} } else if (title.match(/<h3(([\s\S])*?)<\/h3>/g)) {
pre_h3_index++;
level = 3;
id = `nav_${pre_h1_index}_${pre_h2_index}_${pre_h3_index}`;
content = content.replace(new RegExp(title), newTitle); newTitle = title.replace(/<h3/g, `<h3 id="${id}"`) + "_" + time;
}
return { content = content.replace(new RegExp(title), newTitle);
level,
id,
title: title.replace(/<\/?.+?>/g, ""),
};
})
.filter((item) => item.title);
this.content = content; return {
this.navTree = newTitles; level,
this.curNav = (newTitles[0] && newTitles[0].id) || ""; id,
title: title.replace(/<\/?.+?>/g, ""),
};
})
.filter((item) => item.title);
this.content = content;
this.navTree = newTitles;
this.curNav = (newTitles[0] && newTitles[0].id) || "";
}
}, },
clickNav(item) { clickNav(item) {
let target = document.querySelector(`#${item.id}`); let target = document.querySelector(`#${item.id}`);
......
...@@ -272,6 +272,7 @@ export default { ...@@ -272,6 +272,7 @@ export default {
this.$http this.$http
.get("/apaas/support/document/list", { .get("/apaas/support/document/list", {
params: { params: {
search: fullFilter.name,
style: fullFilter.type, style: fullFilter.type,
start: fullFilter.time && fullFilter.time[0], start: fullFilter.time && fullFilter.time[0],
end: fullFilter.time && fullFilter.time[1], end: fullFilter.time && fullFilter.time[1],
...@@ -350,6 +351,7 @@ export default { ...@@ -350,6 +351,7 @@ export default {
style: 0, style: 0,
title: "", title: "",
}; };
this.$refs.addForm && this.$refs.addForm.clearValidate();
this.$refs.addDialog.show(); this.$refs.addDialog.show();
}, },
AddCancelAction() { AddCancelAction() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment