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

fix

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