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

feat:添加全屏按钮

上级 0cab536e
此差异已折叠。
import{d as e,l as t,m as n,p as s,a as r,c as l,b as o,e as i,f as a,w as u,T as c,o as d,F as p,_ as h,r as g,g as f,h as m,i as v,j as y}from"./vendor.js";!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver((e=>{for(const n of e)if("childList"===n.type)for(const e of n.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)})).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerpolicy&&(t.referrerPolicy=e.referrerpolicy),"use-credentials"===e.crossorigin?t.credentials="include":"anonymous"===e.crossorigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}();var b=e({name:"HelloWorld",props:{info:{type:Object,default:{cell_type:"",source:[],outputs:[]}}},computed:{input(){const e=this.info,n=(e.input?e.input.join(""):"")+(e.source?e.source.join(""):"");switch(e.cell_type){case"heading":const s=e.level;return`<h${s}>${n}</h${s}>`;case"markdown":return this.marked(n);case"code":return`<code class="hljs">${this.generateCodeLineNum(n?t.highlightAuto(n).value:"")}</code>`;default:return n}},output(){var e;const n=null==(e=this.info.outputs)?void 0:e.map((e=>(e.text?e.text.join(""):"")+(e.png?`<img src="data:image/png;base64,${e.png}" />`:"")+(e.svg?e.svg.join(""):""))).join("");return n?/[img|svg]/.test(n)?n:t.highlightAuto(n).value:""}},data:()=>({showResult:!1,loading:!1,timeObj:""}),methods:{run(){this.loading=!0,this.showResult=!0;const e=this.loadTime();this.timeObj=setTimeout((()=>{this.loading=!1,clearTimeout(this.timeObj)}),e)},loadTime:()=>Math.floor(500*Math.random()+500),marked(e){if(!e)return"";n.setOptions({breaks:!1,gfm:!0,langPrefix:"hljs language-",highlight:e=>this.generateCodeLineNum(t.highlightAuto(e).value)});return n(e)},generateCodeLineNum:e=>e?`<ul class="code_line_num"><li>${e.replace(/\n/g,"\n</li><li>")}\n</li></ul>`:""}});s("data-v-57ea04c9");const j={class:"jupyter_input"},k={key:1,class:"stop_btn"},_={class:"jupyter_code"},C=["innerHTML"],L={key:0,class:"jupyter_output"},w={key:0,class:"loading"},T=["innerHTML"];r(),b.render=function(e,t,n,s,r,h){return d(),l("div",null,[o("div",j,[e.output&&!e.loading?(d(),l("div",{key:0,class:"run_btn",onClick:t[0]||(t[0]=(...t)=>e.run&&e.run(...t))})):i("",!0),e.output&&e.loading?(d(),l("div",k)):i("",!0),o("div",_,[o("pre",null,[o("p",{innerHTML:e.input},null,8,C)])])]),a(c,{name:"fade"},{default:u((()=>[e.showResult?(d(),l("div",L,[e.loading?(d(),l("div",w)):(d(),l(p,{key:1},[o("div",{class:"close_btn",onClick:t[1]||(t[1]=t=>e.showResult=!1)}),o("div",{class:"jupyter_result",innerHTML:e.output},null,8,T)],64))])):i("",!0)])),_:1})])},b.__scopeId="data-v-57ea04c9";var $=(e,t)=>h.get(e,{params:t}),H=e({name:"App",props:{url:{type:String,default:""}},components:{Cell:b},data:()=>({cells:[]}),created(){this.fetchCells()},computed:{linkHref(){return this.url.replace(/\/blob\//,"/jupyter/")}},methods:{fetchCells(){const e=this.url;if(!e)return;const{groups:t}=/(?<prex>^https?:\/\/\S+.net)\/(?<project_path>\S*)\/\-\/blob\/(?<branch>\S+?)\/(?<path>\S*)/.exec(e),n=`${t.prex}/api/v4/projects/${encodeURIComponent(t.project_path)}/repository/files/${t.path}/raw?ref=${t.branch}`;$(n).then((({data:e})=>{this.cells=this.getCells(e)}))},getCells(e){var t;const n=[];return e.cells&&n.push(...e.cells),null==(t=e.worksheets)||t.forEach((e=>{n.push(...e.cells)})),console.log(n),n}}});s("data-v-fbd29500");const M={class:"jupyter_container"},S=["href"],x=[v(" 点击这里去"),o("span",null,"notebook",-1),v("中调试该代码 ")];r(),H.render=function(e,t,n,s,r,a){const u=g("Cell");return d(),l("div",null,[o("div",M,[(d(!0),l(p,null,f(e.cells,(e=>(d(),m(u,{key:e.id,info:e},null,8,["info"])))),128))]),e.cells.length?(d(),l("a",{key:0,href:e.linkHref,target:"_blank",class:"link"},x,8,S)):i("",!0)])},H.__scopeId="data-v-fbd29500";console.log("render jupyter");const A=Array.from(document.querySelectorAll("a"));A.length&&A.forEach((e=>{const t=e.innerHTML;if(!t.includes(".ipynb"))return;const n=document.createElement("div");var s,r;s=n,(r=e).parentNode.insertBefore(s,r.nextSibling),y(H,{url:t}).mount(n)}));
import{d as e,l as t,m as n,c as l,a as s,b as o,e as r,w as i,T as a,o as c,F as u,_ as d,r as p,f as h,n as f,g,h as m,p as v,i as y,j as b}from"./vendor.js";!function(){const e=document.createElement("link").relList;if(!(e&&e.supports&&e.supports("modulepreload"))){for(const e of document.querySelectorAll('link[rel="modulepreload"]'))t(e);new MutationObserver((e=>{for(const n of e)if("childList"===n.type)for(const e of n.addedNodes)"LINK"===e.tagName&&"modulepreload"===e.rel&&t(e)})).observe(document,{childList:!0,subtree:!0})}function t(e){if(e.ep)return;e.ep=!0;const t=function(e){const t={};return e.integrity&&(t.integrity=e.integrity),e.referrerpolicy&&(t.referrerPolicy=e.referrerpolicy),"use-credentials"===e.crossorigin?t.credentials="include":"anonymous"===e.crossorigin?t.credentials="omit":t.credentials="same-origin",t}(e);fetch(e.href,t)}}();var k=(e,t)=>{for(const[n,l]of t)e[n]=l;return e};const j=e({name:"HelloWorld",props:{info:{type:Object,default:{cell_type:"",source:[],outputs:[]}}},computed:{input(){const e=this.info,n=(e.input?e.input.join(""):"")+(e.source?e.source.join(""):"");switch(e.cell_type){case"heading":const l=e.level;return`<h${l}>${n}</h${l}>`;case"markdown":return this.marked(n);case"code":return`<code class="hljs">${this.generateCodeLineNum(n?t.highlightAuto(n).value:"")}</code>`;default:return n}},output(){var e;const n=null==(e=this.info.outputs)?void 0:e.map((e=>(e.text?e.text.join(""):"")+(e.png?`<img src="data:image/png;base64,${e.png}" />`:"")+(e.svg?e.svg.join(""):""))).join("");return n?/[img|svg]/.test(n)?n:t.highlightAuto(n).value:""}},data:()=>({showResult:!1,loading:!1,timeObj:""}),methods:{run(){this.loading=!0,this.showResult=!0;const e=this.loadTime();this.timeObj=setTimeout((()=>{this.loading=!1,clearTimeout(this.timeObj)}),e)},loadTime:()=>Math.floor(500*Math.random()+500),marked(e){if(!e)return"";n.setOptions({breaks:!1,gfm:!0,langPrefix:"hljs language-",highlight:e=>this.generateCodeLineNum(t.highlightAuto(e).value)});return n(e)},generateCodeLineNum:e=>e?`<ul class="code_line_num"><li>${e.replace(/\n/g,"\n</li><li>")}\n</li></ul>`:""}}),_={class:"jupyter_input"},S={key:1,class:"stop_btn"},C={class:"jupyter_code"},L=["innerHTML"],w={key:0,class:"jupyter_output"},$={key:0,class:"loading"},T=["innerHTML"];const M=e({name:"App",props:{url:{type:String,default:""}},components:{Cell:k(j,[["render",function(e,t,n,d,p,h){return c(),l("div",null,[s("div",_,[e.output&&!e.loading?(c(),l("div",{key:0,class:"run_btn",onClick:t[0]||(t[0]=(...t)=>e.run&&e.run(...t))})):o("",!0),e.output&&e.loading?(c(),l("div",S)):o("",!0),s("div",C,[s("pre",null,[s("p",{innerHTML:e.input},null,8,L)])])]),r(a,{name:"fade"},{default:i((()=>[e.showResult?(c(),l("div",w,[e.loading?(c(),l("div",$)):(c(),l(u,{key:1},[s("div",{class:"close_btn",onClick:t[1]||(t[1]=t=>e.showResult=!1)}),s("div",{class:"jupyter_result",innerHTML:e.output},null,8,T)],64))])):o("",!0)])),_:1})])}],["__scopeId","data-v-57ea04c9"]])},data:()=>({cells:[],fullScreen:!1}),created(){this.fetchCells()},computed:{linkHref(){return this.url.replace(/\/blob\//,"/jupyter/")}},methods:{fetchCells(){const e=this.url;if(!e)return;const{groups:t}=/(?<prex>^https?:\/\/\S+.net)\/(?<project_path>\S*)\/\-\/blob\/(?<branch>\S+?)\/(?<path>\S*)/.exec(e),n=`${t.prex}/api/v4/projects/${encodeURIComponent(t.project_path)}/repository/files/${t.path}/raw?ref=${t.branch}`;d.get(n).then((({data:e})=>{this.cells=this.getCells(e),console.log(111,e),console.log(222,this.cells)}))},getCells(e){var t;const n=[];return e.cells&&n.push(...e.cells),null==(t=e.worksheets)||t.forEach((e=>{n.push(...e.cells)})),console.log(3333,n),n}}}),N=e=>(v("data-v-0054616b"),e=e(),y(),e),x=["href"],A=[m(" 点击这里去"),N((()=>s("span",null,"notebook",-1))),m("中调试该代码 ")];var H=k(M,[["render",function(e,t,n,r,i,a){const d=p("Cell");return c(),l("div",{class:f(["relative",{fullScreen:e.fullScreen}])},[s("div",{class:f(["jupyter_container",{fullScreen:e.fullScreen}])},[(c(!0),l(u,null,h(e.cells,(e=>(c(),g(d,{key:e.id,info:e},null,8,["info"])))),128))],2),e.fullScreen?(c(),l("button",{key:0,onClick:t[0]||(t[0]=t=>e.fullScreen=!1),class:"copyButton"}," 退出全屏 ")):(c(),l("button",{key:1,onClick:t[1]||(t[1]=t=>e.fullScreen=!0),class:"copyButton"}," 全屏显示 ")),e.cells.length?(c(),l("a",{key:2,href:e.linkHref,target:"_blank",class:"link"},A,8,x)):o("",!0)],2)}],["__scopeId","data-v-0054616b"]]);document.addEventListener("DOMContentLoaded",(()=>{const e=Array.from(document.querySelectorAll("a"));e.length&&e.forEach((e=>{const t=e.href;if(!(null==t?void 0:t.includes(".ipynb"))||!e.className.includes("jupyterEl"))return;const n=document.createElement("div");var l,s;l=n,(s=e).parentNode.insertBefore(l,s.nextSibling),b(H,{url:t}).mount(n)}))}));
此差异已折叠。
......@@ -21,8 +21,9 @@
<div class="app"></div> -->
<a
data-type="jupyter"
data-url="http://test-code.csdn.net/cpongo6/ipynb-test/-/blob/master/Cell%20Magics.ipynb"
>http://test-code.csdn.net/cpongo6/ipynb-test/-/blob/master/Cell%20Magics.ipynb</a
class="jupyterEl"
href="https://codechina.csdn.net/xiongjiamu/jupyter-101/-/blob/master/002-demo.ipynb"
>https://codechina.csdn.net/xiongjiamu/jupyter-101/-/blob/master/002-demo.ipynb</a
>
<!-- <div
data-type="jupyter"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册