Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
雪碧有白泡泡
可视化 csdn 数据
提交
855fc5f2
可
可视化 csdn 数据
项目概览
雪碧有白泡泡
/
可视化 csdn 数据
与 Fork 源项目一致
Fork自
yma16 / 可视化 csdn 数据
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
可
可视化 csdn 数据
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
855fc5f2
编写于
1月 08, 2024
作者:
Q
qq_38870145
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Auto Commit
上级
b25b7d37
变更
6
展开全部
显示空白变更内容
内联
并排
Showing
6 changed file
with
596 addition
and
68 deletion
+596
-68
core.128338
core.128338
+0
-0
public/htmlContent.html
public/htmlContent.html
+474
-0
src/App.vue
src/App.vue
+4
-1
src/components/visualHtml/html/data.js
src/components/visualHtml/html/data.js
+41
-0
src/components/visualHtml/html/index.vue
src/components/visualHtml/html/index.vue
+65
-58
src/components/visualHtml/index.vue
src/components/visualHtml/index.vue
+12
-9
未找到文件。
core.128338
0 → 100644
浏览文件 @
855fc5f2
文件已添加
public/htmlContent.html
0 → 100644
浏览文件 @
855fc5f2
此差异已折叠。
点击以展开。
src/App.vue
浏览文件 @
855fc5f2
...
...
@@ -5,12 +5,13 @@ import Draw from './components/draw/Draw.vue'
import
Commit
from
'
./components/commit/Commit.vue
'
import
Drag
from
'
./components/drag/Drag.vue
'
import
Visual
from
'
./components/visual/index.vue
'
import
VisualHtml
from
'
./components/visualHtml/index.vue
'
import
{
reactive
,
onBeforeMount
,
onMounted
}
from
'
vue
'
;
import
html2canvas
from
'
html2canvas
'
;
// state
const
state
=
reactive
({
current
:
'
grade查询分数
'
current
:
'
VisualHtml
'
})
/** 下载图片 */
...
...
@@ -102,6 +103,7 @@ onBeforeMount(() => {
<a-radio
value=
"评论"
>
csdn分析评论
</a-radio>
<a-radio
value=
"拖拽"
>
拼图
</a-radio>
<a-radio
value=
"Visual"
>
可视化 2023 编码之旅
</a-radio>
<a-radio
value=
"VisualHtml"
>
可视化 html
</a-radio>
</a-radio-group>
<a-button
type=
"primary"
@
click=
"shotAction"
>
截图
...
...
@@ -113,6 +115,7 @@ onBeforeMount(() => {
<Commit
v-else-if=
"state.current === '评论'"
/>
<Drag
v-else-if=
"state.current === '拖拽'"
/>
<Visual
v-else-if=
"state.current === 'Visual'"
/>
<VisualHtml
v-else-if=
"state.current === 'VisualHtml'"
/>
<Draw
v-else
/>
</div>
</div>
...
...
src/components/visualHtml/html/data.js
浏览文件 @
855fc5f2
import
axios
from
'
axios
'
const
getHtmlDoc
=
(
htmlString
)
=>
{
const
parser
=
new
DOMParser
();
const
doc
=
parser
.
parseFromString
(
htmlString
,
'
text/html
'
);
return
doc
}
function
traverse
(
node
)
{
const
children
=
[]
const
name
=
node
.
nodeName
// 遍历当前节点的子节点
for
(
let
i
=
0
;
i
<
node
.
childNodes
.
length
;
i
++
)
{
const
child
=
node
.
childNodes
[
i
];
// 如果是元素节点,打印节点名称,并递归遍历子节点
if
(
child
.
nodeType
===
1
)
{
const
childItem
=
traverse
(
child
)
children
.
push
(
childItem
);
}
}
return
{
name
,
children
}
}
const
genTreeData
=
async
(
htmlHref
)
=>
{
// 请求 html 内容
const
{
data
:
htmlContent
}
=
await
axios
.
get
(
htmlHref
)
console
.
log
(
'
htmlContent
'
,
htmlContent
)
const
htmlDoc
=
getHtmlDoc
(
htmlContent
)
const
treeData
=
traverse
(
htmlDoc
.
body
)
console
.
log
(
'
treeData
'
,
treeData
)
return
treeData
}
export
const
treeData
=
genTreeData
\ No newline at end of file
src/components/visualHtml/html/index.vue
浏览文件 @
855fc5f2
<
template
>
<div
id=
"treeChartId"
style=
"width:100%;height:300px;margin: 0 auto"
></div>
<div>
<a-input-search
v-model:value=
"state.htmlHref"
placeholder=
"输入html链接"
style=
"width: 100%;margin:10px;"
@
search=
"onSearch"
/>
<div
id=
"treeChartId"
style=
"width:100%;height:600px;margin: 0 auto"
></div>
</div>
</
template
>
<
script
setup
>
import
*
as
echarts
from
'
echarts
'
;
import
{
defineProps
,
reactive
,
watch
,
nextTick
,
onUnmounted
,
onMounted
}
from
'
vue
'
;
import
{
treeData
}
from
'
./data.js
'
import
*
as
echarts
from
'
echarts
'
;
import
{
reactive
,
onUnmounted
,
onMounted
}
from
'
vue
'
;
import
{
treeData
}
from
'
./data.js
'
const
state
=
reactive
({
exportLoading
:
false
,
echartInstance
:
undefined
,
hubData
:[],
treeData
:
[],
htmlHref
:
'
htmlContent.html
'
})
function
renderEchartLine
()
{
// 基于准备好的dom,初始化echarts实例
const
domInstance
=
document
.
getElementById
(
'
treeChartId
'
)
if
(
domInstance
)
{
const
domInstance
=
document
.
getElementById
(
'
treeChartId
'
)
if
(
domInstance
)
{
domInstance
.
removeAttribute
(
'
_echarts_instance_
'
)
}
else
{
else
{
return
}
const
myChart
=
echarts
.
init
(
domInstance
);
const
seriesItem
=
{
name
:
'
Access From
'
,
type
:
'
pie
'
,
// radius: [20, 50],
center
:
[
'
50%
'
,
'
50%
'
],
// roseType: 'area',
// itemStyle: {
// borderRadius: 1
// },
data
:
state
.
hubData
,
label
:{
color
:
'
#ffffff
'
},
emphasis
:
{
itemStyle
:
{
shadowBlur
:
10
,
shadowOffsetX
:
0
,
shadowColor
:
'
rgba(0, 0, 0, 0.5)
'
}
}
}
const
seriesData
=
[
seriesItem
]
const
data
=
state
.
treeData
const
option
=
{
title
:
{
text
:
'
社区文章数量占比
'
,
textStyle
:{
color
:
'
#ffffff
'
}
},
toolbox
:
{
show
:
true
,
feature
:
{
saveAsImage
:
{}
text
:
'
html可视化
'
,
textStyle
:
{
color
:
'
#ffffff
'
}
},
tooltip
:
{
trigger
:
'
axis
'
,
trigger
:
'
item
'
,
triggerOn
:
'
mousemove
'
},
xAxis
:
{
axisLabel
:{
color
:
'
#ffffff
'
}
series
:
[
{
type
:
'
tree
'
,
id
:
0
,
name
:
'
html tree
'
,
data
:
[
data
],
top
:
'
10%
'
,
left
:
'
8%
'
,
bottom
:
'
22%
'
,
right
:
'
20%
'
,
symbolSize
:
7
,
edgeShape
:
'
polyline
'
,
edgeForkPosition
:
'
63%
'
,
initialTreeDepth
:
3
,
lineStyle
:
{
width
:
2
},
label
:
{
backgroundColor
:
'
#fff
'
,
position
:
'
left
'
,
verticalAlign
:
'
middle
'
,
align
:
'
right
'
},
yAxis
:
{
axisLabel
:{
color
:
'
#ffffff
'
leaves
:
{
label
:
{
position
:
'
right
'
,
verticalAlign
:
'
middle
'
,
align
:
'
left
'
}
},
grid
:
{
x
:
60
,
x2
:
100
emphasis
:
{
focus
:
'
descendant
'
},
series
:
seriesData
expandAndCollapse
:
true
,
animationDuration
:
550
,
animationDurationUpdate
:
750
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart
.
setOption
(
option
,
true
);
...
...
@@ -84,15 +86,20 @@ function renderEchartLine() {
window
.
onresize
=
myChart
.
resize
;
}
const
onSearch
=
async
(
htmlHref
)
=>
{
state
.
treeData
=
await
treeData
(
htmlHref
)
renderEchartLine
()
}
onUnmounted
(()
=>
{
window
.
onresize
=
null
})
const
getHubConfig
=
()
=>
{
state
.
hubData
=
[...
treeData
]
const
getHubConfig
=
async
()
=>
{
state
.
treeData
=
await
treeData
(
state
.
htmlHref
)
renderEchartLine
()
}
onMounted
(()
=>
{
onMounted
(()
=>
{
getHubConfig
()
})
</
script
>
\ No newline at end of file
src/components/visualHtml/index.vue
浏览文件 @
855fc5f2
<
script
setup
>
import
{
reactive
,
onMounted
}
from
'
vue
'
import
VisualHtml
from
'
./html/index.vue
'
import
Author
from
'
../Author.vue
'
const
state
=
reactive
({
title
:
''
,
})
import
{
reactive
,
onMounted
}
from
'
vue
'
import
VisualHtml
from
'
./html/index.vue
'
import
Author
from
'
../Author.vue
'
const
state
=
reactive
({
title
:
''
,
})
</
script
>
<
template
>
<div
style=
"padding:20px;"
>
<Author/>
<Author
/>
<div>
{{
state
.
title
}}
{{
state
.
title
}}
<div>
<div>
</div>
<VisualHtml
/>
</div>
</div>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录