Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gitcode_dev
jupyter-render
提交
0cab536e
J
jupyter-render
项目概览
gitcode_dev
/
jupyter-render
通知
2
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jupyter-render
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0cab536e
编写于
9月 24, 2021
作者:
璃白.
🌻
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix
上级
cbd39928
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
80 addition
and
28 deletion
+80
-28
index.html
index.html
+3
-2
src/App.vue
src/App.vue
+55
-6
src/assets/css/style.less
src/assets/css/style.less
+4
-0
src/main.ts
src/main.ts
+18
-20
未找到文件。
index.html
浏览文件 @
0cab536e
...
...
@@ -18,8 +18,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"
...
...
src/App.vue
浏览文件 @
0cab536e
<
template
>
<div>
<div
class=
"jupyter_container
"
>
<div
:class=
"['relative',
{ fullScreen }]"
>
<div
:class=
"['jupyter_container',
{ fullScreen }]
">
<Cell
v-for=
"item in cells"
:key=
"item.id"
:info=
"item"
/>
</div>
<button
@
click=
"fullScreen = false"
v-if=
"fullScreen"
class=
"copyButton"
>
退出全屏
</button>
<button
@
click=
"fullScreen = true"
v-else
class=
"copyButton"
>
全屏显示
</button>
<a
:href=
"linkHref"
target=
"_blank"
v-if=
"cells.length"
class=
"link"
>
点击这里去
<span>
notebook
</span>
中调试该代码
</a>
...
...
@@ -13,7 +19,8 @@
import
{
defineComponent
}
from
"
vue
"
;
import
{
CellObject
}
from
"
./assets/js/interface
"
;
import
Cell
from
"
./components/cell.vue
"
;
import
api
from
"
./api/index
"
;
import
axios
from
"
axios
"
;
// import api from "./api/index";
export
default
defineComponent
({
name
:
"
App
"
,
...
...
@@ -26,7 +33,8 @@ export default defineComponent({
components
:
{
Cell
},
data
()
{
return
{
cells
:
[]
as
any
[]
cells
:
[]
as
any
[],
fullScreen
:
false
};
},
created
()
{
...
...
@@ -50,8 +58,10 @@ export default defineComponent({
const
fetchUrl
=
`
${
urlInfo
.
prex
}
/api/v4/projects/
${
encodeURIComponent
(
urlInfo
.
project_path
)}
/repository/files/
${
urlInfo
.
path
}
/raw?ref=
${
urlInfo
.
branch
}
`
;
a
pi
.
fetchCells
(
fetchUrl
).
then
(({
data
:
res
})
=>
{
a
xios
.
get
(
fetchUrl
).
then
(({
data
:
res
})
=>
{
this
.
cells
=
this
.
getCells
(
res
);
console
.
log
(
111
,
res
);
console
.
log
(
222
,
this
.
cells
);
});
},
getCells
(
obj
:
CellObject
)
{
...
...
@@ -62,7 +72,7 @@ export default defineComponent({
obj
.
worksheets
?.
forEach
((
item
:
CellObject
)
=>
{
list
.
push
(...
item
.
cells
);
});
console
.
log
(
list
);
console
.
log
(
3333
,
list
);
return
list
;
}
}
...
...
@@ -70,13 +80,52 @@ export default defineComponent({
</
script
>
<
style
lang=
"less"
scoped
>
.relative {
&:hover {
.copyButton {
display: block;
}
}
&.fullScreen {
.jupyter_container {
position: fixed;
width: 100vw;
height: 100vh;
top: 0;
left: 0;
z-index: 9999999;
margin: 0;
max-height: unset;
}
.copyButton {
position: fixed;
right: 20px;
z-index: 9999999;
}
}
.copyButton {
display: none;
outline: none;
border: 1px solid rgba(0, 0, 0, 0.07);
position: absolute;
border-radius: 2px;
color: #000;
top: 4px;
right: 20px;
padding: 2px 8px;
margin: 8px;
cursor: pointer;
}
}
.jupyter_container {
font-size: 14px;
max-height: 320px;
overflow-y: auto;
background: #282c34;
margin: 14px 0;
position: relative;
}
.link {
cursor: pointer;
text-decoration: none;
...
...
src/assets/css/style.less
浏览文件 @
0cab536e
...
...
@@ -11,6 +11,10 @@ img {
margin: 0;
}
.relative {
position: relative;
}
.jupyter_container {
pre {
// border-left: 1px solid @color-blue;
...
...
src/main.ts
浏览文件 @
0cab536e
...
...
@@ -2,24 +2,22 @@ import { createApp } from 'vue'
import
App
from
'
./App.vue
'
import
'
./assets/css/style.less
'
;
// document.addEventListener('DOMContentLoaded', () => {
console
.
log
(
'
render jupyter
'
)
const
jupyterLinks
=
Array
.
from
(
document
.
querySelectorAll
(
'
a
'
))
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
const
jupyterLinks
=
Array
.
from
(
document
.
querySelectorAll
(
'
a
'
))
function
insertAfter
(
newNode
:
HTMLElement
,
referenceNode
:
HTMLElement
)
{
(
referenceNode
as
any
).
parentNode
.
insertBefore
(
newNode
,
referenceNode
.
nextSibling
);
}
if
(
jupyterLinks
.
length
)
{
jupyterLinks
.
forEach
(
item
=>
{
const
url
=
item
.
innerHTML
if
(
!
url
.
includes
(
'
.ipynb
'
))
return
const
targetEL
=
document
.
createElement
(
'
div
'
)
insertAfter
(
targetEL
,
item
)
// item.style.display = 'none'
createApp
(
App
,
{
url
}).
mount
(
targetEL
)
})
};
// })
function
insertAfter
(
newNode
:
HTMLElement
,
referenceNode
:
HTMLElement
)
{
(
referenceNode
as
any
).
parentNode
.
insertBefore
(
newNode
,
referenceNode
.
nextSibling
);
}
if
(
jupyterLinks
.
length
)
{
jupyterLinks
.
forEach
(
item
=>
{
const
url
=
item
.
href
if
(
!
url
?.
includes
(
'
.ipynb
'
)
||
!
item
.
className
.
includes
(
'
jupyterEl
'
))
return
const
targetEL
=
document
.
createElement
(
'
div
'
)
insertAfter
(
targetEL
,
item
)
createApp
(
App
,
{
url
}).
mount
(
targetEL
)
})
};
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录