提交 73f3a026 编写于 作者: 郭维嘉

fix

上级 faf4316f
流水线 #3420 已失败 ,包含阶段
......@@ -547,9 +547,9 @@ export default {
},
addTocClickToBody() {
document.querySelector("body").addEventListener("click", function(e) {
if (!e.target?.className.includes("md_toc_item")) return;
if (!e.target.className.includes("md_toc_item")) return;
const targetEl = document.getElementById(
e.target?.getAttribute("href")
e.target.getAttribute("href")
);
if (!targetEl) return;
targetEl.scrollIntoView({
......
......@@ -184,7 +184,7 @@ export function isNotFalse(val) {
}
export function pick(list, ...arg) {
if (!list.length || !arg?.length) return;
if (!list.length || !(arg && arg.length)) return;
return list.filter(item => {
return arg.find(key => key === item.name);
});
......
......@@ -59,7 +59,7 @@ export default {
},
computed: {
topList() {
return this.dirTags.map(item => Math.abs(item?.top));
return this.dirTags.map(item => Math.abs(item && item.top));
}
},
created() {
......@@ -92,7 +92,9 @@ export default {
// ).scrollTop = targetOffsetTop;
},
dirItemActive(item) {
const itemScrollTop = document.getElementById(item.id)?.offsetTop;
const targetEl = document.getElementById(item.id);
if (!targetEl) return;
const itemScrollTop = targetEl.offsetTop;
const top = this.scrollBarTop - itemScrollTop;
this.$set(item, "top", top);
return Math.abs(top) === Math.min(...this.topList);
......
......@@ -142,7 +142,7 @@ export default {
return "<h" + level + ">" + text + "</h" + level + ">\n";
},
link(href, title, text) {
if (text?.toLowerCase() === "toc") {
if (text && text.toLowerCase() === "toc") {
return `
<h1 class="toc_title">${href}</h1>
<div class="tocEl"></div>`;
......
......@@ -4,10 +4,6 @@ import Vtip from "vtip";
import "vtip/lib/index.min.css";
import { initStyle, setzIndex, isNotEmpty } from "@/assets/js/utils";
import "@/assets/style/global.less";
// import "@/assets/jupyter-render/dist/index.js";
// import "@/assets/jupyter-render/dist/assets/index.css";
Vue.use(Vtip.directive);
function initMdEditor(obj) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册