提交 ba243d20 编写于 作者: 璃白.'s avatar 璃白. 🌻

feat:添加视频时长

上级 2074afcd
...@@ -443,6 +443,25 @@ export default { ...@@ -443,6 +443,25 @@ export default {
html: this.html html: this.html
}); });
}, },
getVideoList(callback) {
const virtualDom = document.createElement("div");
virtualDom.style.height = 0;
virtualDom.innerHTML = this.html;
document.body.appendChild(virtualDom);
const vEls = Array.from(virtualDom.getElementsByTagName("video"));
const list = vEls.map(item => {
item.preload = true;
return new Promise((res, rej) => {
item.oncanplay = function() {
res(item.duration);
};
});
});
document.body.removeChild(virtualDom);
Promise.all(list).then(res => {
callback(res);
});
},
queryUserList(keyWord) { queryUserList(keyWord) {
const _this = this; const _this = this;
this.$emit("queryUserList", { this.$emit("queryUserList", {
...@@ -491,6 +510,9 @@ export default { ...@@ -491,6 +510,9 @@ export default {
item.linkType = linkEl.getAttribute("data-type"); item.linkType = linkEl.getAttribute("data-type");
linkEl.setAttribute("target", "_blank"); linkEl.setAttribute("target", "_blank");
linkEl.setAttribute("href", url); linkEl.setAttribute("href", url);
if (item.url.includes(".ipynb")) {
linkEl.className = "jupyterEl";
}
const title = getLinkTitle(linkEl, item); const title = getLinkTitle(linkEl, item);
linkEl.innerHTML = renderLinkCard(title, item); linkEl.innerHTML = renderLinkCard(title, item);
}); });
......
...@@ -401,7 +401,7 @@ export function renderLinkCard(title, item) { ...@@ -401,7 +401,7 @@ export function renderLinkCard(title, item) {
content = `<span class="md_link_url">${item.url}</span>`; content = `<span class="md_link_url">${item.url}</span>`;
break; break;
case "3": case "3":
content = `<span class="jupyter jupyterEl">${item.url}</span>`; content = `<span class="">${item.url}</span>`;
break; break;
default: default:
content = `<div class="md_link_card"> content = `<div class="md_link_card">
......
jupyter-render @ 0f667900
Subproject commit cbd3992899f157f8804ef8c2720c7f3d56cff03b Subproject commit 0f667900bbbc48bbe5dbd34ae2cc421f7566259e
...@@ -57,7 +57,6 @@ export default { ...@@ -57,7 +57,6 @@ export default {
" ------ |", " ------ |",
col col
)}\n${this.createStr("|" + this.createStr(" 单元格 |", col) + "\n", row)}`; )}\n${this.createStr("|" + this.createStr(" 单元格 |", col) + "\n", row)}`;
console.log(str);
this.$emit("select", str); this.$emit("select", str);
}, },
......
...@@ -14,6 +14,7 @@ function initMdEditor(obj) { ...@@ -14,6 +14,7 @@ function initMdEditor(obj) {
html: "" html: ""
}; };
this.vEl = ""; this.vEl = "";
this.videoList = [];
let { let {
el, el,
onLoad = () => {}, onLoad = () => {},
...@@ -144,6 +145,10 @@ function initMdEditor(obj) { ...@@ -144,6 +145,10 @@ function initMdEditor(obj) {
}) })
}).$mount(el); }).$mount(el);
this.getVideoList = function(callback) {
this.vEl.$children[0].getVideoList(callback);
};
this.getValue = function(callback) { this.getValue = function(callback) {
if (callback) { if (callback) {
callback(this.value); callback(this.value);
......
...@@ -8,7 +8,6 @@ module.exports = { ...@@ -8,7 +8,6 @@ module.exports = {
}, },
devServer: { devServer: {
contentBase: path.resolve(__dirname, "dist"), contentBase: path.resolve(__dirname, "dist"),
host: "live.csdn.net",
open: true open: true
}, },
resolve: { resolve: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册