优化文章seo声明;导出面板新增版权声明功能;

This commit is contained in:
2022-05-26 10:12:25 +08:00
parent efe2013a9c
commit 0284f6f2b8
6 changed files with 127 additions and 59 deletions

View File

@@ -37,6 +37,12 @@
display: block;
margin-bottom: 15px;
}
.article-body.show-copyright-inner .copyright-inner {
background-color: #e8e8e8;
color: #333;
font-size: 12px;
}
</style>
</head>
@@ -46,7 +52,11 @@
<div id="post-desc">
{$post.desc}
</div>
<article id="post-content" class="ul-content">{$post->content_html|raw}</article>
<article id="post-content" class="ul-content">
{$post->content_html|raw}
{:\\app\\common\\tools\\PostBlock::copyright($post)}
</article>
</div>
<div class="options-box layui-btn-container">
@@ -55,6 +65,8 @@
<a class="copy-option layui-btn layui-btn-sm" href="#post-title">选中标题</a>
<a class="copy-option layui-btn layui-btn-sm" href="#post-desc">选中描述</a>
<a class="copy-option layui-btn layui-btn-sm select-content" href="#post-content">选中内容</a>
<a class=" layui-btn layui-btn-sm build-copyright" href="#post-content">插入声明</a>
<a class=" layui-btn layui-btn-sm show-copyright" href="#post-content">显示声明</a>
<div class="layui-btn layui-btn-sm code2base64">
代码转临时图片
</div>
@@ -104,6 +116,30 @@
copyContent($(this).attr('href'))
})
$('.build-copyright').click(function () {
var copyElem = $('.copyright').find('p').last();
var html = copyElem.html();
$('#post-content > p').not('.copyright-inner').each(function (index, elem) {
if (index > 0 && index % 8 == 0) {
if (!$(elem).next().hasClass('copyright-inner')) {
$('<blockquote>' + html + '</blockquote>').insertAfter(elem).addClass('copyright-inner')
}
}
})
})
$('.show-copyright').click(function () {
if ($('.article-body').hasClass('show-copyright-inner')) {
$('.article-body').removeClass('show-copyright-inner')
} else {
$('.article-body').addClass('show-copyright-inner')
}
})
function copyContent(id) {
var content = $(id)[0];
@@ -113,7 +149,7 @@
// Range 起始位置在段落2
range.selectNode(content);
console.log(range);
// 获取 selection 对象
const selection = window.getSelection();
selection.removeAllRanges()