修复文章前后端相关问题

This commit is contained in:
李志强 2025-05-28 11:19:40 +08:00
parent 187a1bb963
commit d475289530
7 changed files with 234 additions and 171 deletions

View File

@ -39,7 +39,21 @@
<label class="layui-form-label">作者</label>
<div class="layui-input-block">
<input type="text" name="author" required lay-verify="required" placeholder="请输入作者" autocomplete="off"
class="layui-input">
class="layui-input" value="{$aUser['name']}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">是否转载</label>
<div class="layui-input-block">
<input type="checkbox" name="is_trans" lay-skin="switch" lay-text="是|否" lay-filter="isTrans">
</div>
</div>
<div class="layui-form-item" id="transUrlItem" style="display: none;">
<label class="layui-form-label">转载地址</label>
<div class="layui-input-block">
<input type="text" name="transurl" placeholder="请输入转载地址" autocomplete="off" class="layui-input">
</div>
</div>
@ -92,6 +106,11 @@
var upload = layui.upload;
var element = layui.element;
// 监听转载开关
form.on('switch(isTrans)', function(data){
$('#transUrlItem')[data.elem.checked ? 'show' : 'hide']();
});
// 图片上传
var uploadInst = upload.render({
elem: '#upload-btn',

View File

@ -46,6 +46,21 @@
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">是否转载</label>
<div class="layui-input-block">
<input type="checkbox" name="is_trans" lay-skin="switch" lay-text="是|否" lay-filter="isTrans" {if $info.is_trans eq '是'}checked{/if}>
</div>
</div>
<div class="layui-form-item" id="transUrlItem" style="display: none;">
<label class="layui-form-label">转载地址</label>
<div class="layui-input-block">
<input type="text" name="transurl" placeholder="请输入转载地址" autocomplete="off" class="layui-input"
value="{$info.transurl}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">封面</label>
<div class="layui-input-block">
@ -95,6 +110,19 @@
var upload = layui.upload;
var element = layui.element;
// 页面加载时检查转载状态
var isTrans = '{$info.is_trans|default="否"}';
if(isTrans === '是') {
$('#transUrlItem').show();
} else {
$('#transUrlItem').hide();
}
// 监听转载开关
form.on('switch(isTrans)', function (data) {
$('#transUrlItem')[data.elem.checked ? 'show' : 'hide']();
});
// 图片上传
var uploadInst = upload.render({
elem: '#upload-btn',
@ -202,7 +230,7 @@
<script>
const { createEditor, createToolbar } = window.wangEditor
const editorConfig = {
const editorConfig = {
MENU_CONF: {},
placeholder: '请输入内容...',
onChange(editor) {

View File

@ -14,6 +14,7 @@
<div class="article-detail-container">
<div class="article-header">
<h1 class="article-title" id="articleTitle"></h1>
<div class="trans" id="transDiv" style="display: none;">转载至:<span id="transUrl"></span></div>
<div class="article-meta">
<span class="article-author"><i class="fa fa-user"></i> <span id="articleAuthor"></span></span>
<span class="article-date"><i class="fa fa-calendar"></i> <span id="articleDate"></span></span>
@ -532,6 +533,22 @@
} else {
relatedArticles.innerHTML = '<div class="no-related">暂无相关文章</div>';
}
// 处理转载信息
if (data.article.is_trans === 1 && data.article.transurl) {
const transDiv = document.getElementById('transDiv');
const transUrlSpan = document.getElementById('transUrl');
transUrlSpan.textContent = data.article.transurl;
transDiv.style.display = 'block';
// 添加点击事件,在新窗口打开原文章
transUrlSpan.style.cursor = 'pointer';
transUrlSpan.style.color = '#007bff';
transUrlSpan.addEventListener('click', function() {
window.open(data.article.transurl, '_blank');
});
}
}
// 页面加载完成后执行
@ -549,13 +566,8 @@
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => {
// console.log('Response status:', response.status);
// console.log('Response headers:', response.headers);
return response.json();
})
.then(response => response.json())
.then(result => {
// console.log('API response:', result);
if (result.code === 1) {
renderArticleDetail(result.data);
// 更新访问次数
@ -567,28 +579,13 @@
})
.catch(error => {
console.error('获取文章详情失败:', error);
console.error('Error details:', {
message: error.message,
stack: error.stack
});
alert('获取文章详情失败,请检查网络连接或刷新页面重试');
});
// 点赞功能
const likeBtn = document.getElementById('likeBtn');
if (likeBtn) {
// 检查是否已经点赞
if (likeBtn.classList.contains('liked')) {
likeBtn.style.pointerEvents = 'none'; // 禁用点击
likeBtn.style.cursor = 'default'; // 改变鼠标样式
return;
}
likeBtn.addEventListener('click', function () {
// 立即禁用按钮,防止重复点击
likeBtn.style.pointerEvents = 'none';
likeBtn.style.cursor = 'default';
fetch('/index/articles/like?id=' + articleId, {
method: 'POST',
headers: {
@ -598,26 +595,19 @@
.then(response => response.json())
.then(data => {
if (data.code === 1) {
const countElement = document.getElementById('articlesLikes');
const countElement = document.getElementById('articleLikes');
if (countElement) {
let count = parseInt(countElement.textContent) || 0;
countElement.textContent = count + 1;
}
// 添加点赞状态
likeBtn.classList.add('liked');
likeBtn.querySelector('i').style.color = '#f57005';
layer.msg('点赞成功', { icon: 1 });
} else {
// 如果请求失败,恢复按钮状态
likeBtn.style.pointerEvents = 'auto';
likeBtn.style.cursor = 'pointer';
layer.msg('点赞失败:' + data.msg, { icon: 2 });
}
})
.catch(error => {
// 如果请求失败,恢复按钮状态
likeBtn.style.pointerEvents = 'auto';
likeBtn.style.cursor = 'pointer';
console.error('点赞请求失败:', error);
layer.msg('点赞失败,请稍后重试', { icon: 2 });
});
@ -626,8 +616,6 @@
// 返回顶部功能
const goToTop = document.getElementById('goToTop');
// 监听滚动事件
window.addEventListener('scroll', function () {
if (window.pageYOffset > 300) {
goToTop.classList.add('show');
@ -636,13 +624,27 @@
}
});
// 点击返回顶部
goToTop.addEventListener('click', function () {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
// 分享功能
const shareBtn = document.getElementById('shareBtn');
if (shareBtn) {
shareBtn.addEventListener('click', function () {
const currentUrl = window.location.href;
const tempInput = document.createElement('input');
tempInput.value = currentUrl;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand('copy');
document.body.removeChild(tempInput);
layer.msg('链接已复制到剪贴板', { icon: 1 });
});
}
});
// 更新文章访问次数
@ -659,7 +661,6 @@
.then(response => response.json())
.then(result => {
if (result.code === 1) {
// 更新成功,更新页面上的访问次数显示
const viewsElement = document.getElementById('articleViews');
if (viewsElement) {
viewsElement.textContent = result.data.views;
@ -670,29 +671,5 @@
console.error('更新访问次数失败:', error);
});
}
// 分享功能
const shareBtn = document.getElementById('shareBtn');
if (shareBtn) {
shareBtn.addEventListener('click', function () {
// 获取当前页面URL
const currentUrl = window.location.href;
// 创建临时输入框
const tempInput = document.createElement('input');
tempInput.value = currentUrl;
document.body.appendChild(tempInput);
// 选择并复制文本
tempInput.select();
document.execCommand('copy');
// 移除临时输入框
document.body.removeChild(tempInput);
// 提示用户复制成功
alert('链接已复制到剪贴板');
});
}
</script>
{include file="component/foot" /}

View File

@ -211,7 +211,8 @@ pre code {
position: relative;
}
.main-menu .container .main-menu__right .layui-btn-primary:hover,.sticky-nav .container .main-menu__right .layui-btn-primary:hover {
.main-menu .container .main-menu__right .layui-btn-primary:hover,
.sticky-nav .container .main-menu__right .layui-btn-primary:hover {
color: #3492ed;
}
@ -326,7 +327,6 @@ pre code {
/* 轮播动画 */
@keyframes slide {
0%,
33% {
transform: translateX(0);
@ -576,4 +576,66 @@ pre code {
.game-content img {
width: 100%;
margin: 20px auto;
}
}
.article-detail-container {
}
.article-detail-container .article-header .trans {
margin-bottom: 10px;
color: #aaa;
font-size: 12px;
}
.article-detail-container .article-content h1,
.article-detail-container .article-content h2,
.article-detail-container .article-content h3,
.article-detail-container .article-content h4,
.article-detail-container .article-content h5 {
font-weight: 700;
margin-bottom: 20px;
}
.article-detail-container .article-content h1 {
font-size: 2rem;
}
.article-detail-container .article-content h2 {
font-size: 1.75rem;
}
.article-detail-container .article-content h3 {
font-size: 1.45rem;
}
.article-detail-container .article-content h4 {
font-size: 1.25rem;
}
.article-detail-container .article-content h5 {
font-size: 1rem;
}
.article-detail-container .article-content video {
width: 100%;
margin: 10px auto;
}
.article-detail-container .article-content span {
margin: 0 5px;
padding: 2px 6px;
border-radius: 4px;
}
.article-detail-container .article-content pre {
margin-bottom: 2.5rem;
}
.article-detail-container .article-content pre code {
white-space: pre-wrap;
word-wrap: break-word;
}
.article-detail-container .article-content hr {
margin: 40px auto;
}

View File

@ -2095,7 +2095,7 @@ a cite {
margin-bottom: 10px;
padding: 15px;
line-height: 1.8;
border-left: 5px solid #16b777;
border-left: 5px solid #0081ff;
border-radius: 0 2px 2px 0;
background-color: #fafafa
}
@ -2150,7 +2150,7 @@ a cite {
height: 6px;
border-radius: 20px;
text-align: right;
background-color: #16b777;
background-color: #0081ff;
transition: all .3s;
-webkit-transition: all .3s
}
@ -2685,7 +2685,7 @@ hr.layui-border-red {
}
.layui-btn-checked {
background-color: #16b777
background-color: #0081ff
}
.layui-btn-disabled,
@ -2803,7 +2803,7 @@ hr.layui-border-red {
.layui-input:focus,
.layui-textarea:focus {
border-color: #16b777 !important;
border-color: #0081ff !important;
box-shadow: 0 0 0 3px rgba(22, 183, 119, .08)
}
@ -3020,7 +3020,7 @@ hr.layui-border-red {
}
.layui-input-wrap .layui-input:focus+.layui-input-split {
border-color: #16b777
border-color: #0081ff
}
.layui-input-wrap .layui-input.layui-form-danger:focus+.layui-input-split {
@ -3186,7 +3186,7 @@ hr.layui-border-red {
.layui-form-select dl dd.layui-this {
background-color: #f8f8f8;
color: #16b777;
color: #0081ff;
font-weight: 700
}
@ -3305,17 +3305,17 @@ hr.layui-border-red {
.layui-form-checked,
.layui-form-checked:hover {
border-color: #16b777
border-color: #0081ff
}
.layui-form-checked:hover>div,
.layui-form-checked>div {
background-color: #16b777
background-color: #0081ff
}
.layui-form-checked:hover>i,
.layui-form-checked>i {
color: #16b777
color: #0081ff
}
.layui-form-item .layui-form-checkbox {
@ -3366,13 +3366,13 @@ hr.layui-border-red {
}
.layui-form-checkbox[lay-skin=primary]:hover>i {
border-color: #16b777;
border-color: #0081ff;
color: #fff
}
.layui-form-checked[lay-skin=primary]>i {
border-color: #16b777 !important;
background-color: #16b777;
border-color: #0081ff !important;
background-color: #0081ff;
color: #fff
}
@ -3394,7 +3394,7 @@ hr.layui-border-red {
}
.layui-form-checkbox[lay-skin=primary]>.layui-icon-indeterminate {
border-color: #16b777
border-color: #0081ff
}
.layui-form-checkbox[lay-skin=primary]>.layui-icon-indeterminate:before {
@ -3405,7 +3405,7 @@ hr.layui-border-red {
width: 50%;
height: 1px;
margin: -1px auto 0;
background-color: #16b777
background-color: #0081ff
}
.layui-form-switch {
@ -3450,8 +3450,8 @@ hr.layui-border-red {
}
.layui-form-onswitch {
border-color: #16b777;
background-color: #16b777
border-color: #0081ff;
background-color: #0081ff
}
.layui-form-onswitch>i {
@ -3551,7 +3551,7 @@ hr.layui-border-red {
.layui-form-radio:hover>*,
.layui-form-radioed,
.layui-form-radioed>i {
color: #16b777
color: #0081ff
}
.layui-radio-disabled>i {
@ -4083,7 +4083,7 @@ hr.layui-border-red {
width: 100%;
height: 100%;
box-sizing: border-box;
border: 1px solid #16b777;
border: 1px solid #0081ff;
pointer-events: none;
content: ""
}
@ -4517,7 +4517,7 @@ hr.layui-border-red {
}
.layui-table-edit:focus {
border-color: #16b777 !important
border-color: #0081ff !important
}
input.layui-input.layui-table-edit {
@ -4609,7 +4609,7 @@ select.layui-table-edit {
}
.layui-table-cell-c:hover {
border-color: #16b777
border-color: #0081ff
}
.layui-table-expanded td:hover .layui-table-cell {
@ -4874,12 +4874,12 @@ body .layui-table-tips .layui-layer-content {
.layui-menu .layui-menu-item-checked,
.layui-menu .layui-menu-item-checked2 {
background-color: #f8f8f8 !important;
color: #16b777
color: #0081ff
}
.layui-menu .layui-menu-item-checked a,
.layui-menu .layui-menu-item-checked2 a {
color: #16b777
color: #0081ff
}
.layui-menu .layui-menu-item-checked:after {
@ -4887,7 +4887,7 @@ body .layui-table-tips .layui-layer-content {
right: -1px;
top: 0;
bottom: 0;
border-right: 3px solid #16b777;
border-right: 3px solid #0081ff;
content: ""
}
@ -4964,7 +4964,7 @@ body .layui-table-tips .layui-layer-content {
.layui-menu-lg .layui-menu-body-title a:hover,
.layui-menu-lg li:hover {
background: 0 0;
color: #16b777
color: #0081ff
}
.layui-menu-lg li .layui-menu-body-panel {
@ -5220,7 +5220,7 @@ body .layui-table-tips .layui-layer-content {
top: 0;
width: 0;
height: 3px;
background-color: #16b777;
background-color: #0081ff;
transition: all .2s;
-webkit-transition: all .2s;
pointer-events: none
@ -5434,7 +5434,7 @@ body .layui-table-tips .layui-layer-content {
}
.layui-nav.layui-bg-gray .layui-this a {
color: #16b777
color: #0081ff
}
.layui-nav-tree.layui-bg-gray .layui-nav-child {
@ -5447,12 +5447,12 @@ body .layui-table-tips .layui-layer-content {
.layui-nav-tree.layui-bg-gray .layui-this,
.layui-nav-tree.layui-bg-gray .layui-this>a {
background: 0 0 !important;
color: #16b777 !important;
color: #0081ff !important;
font-weight: 700
}
.layui-nav-tree.layui-bg-gray .layui-nav-bar {
background-color: #16b777
background-color: #0081ff
}
.layui-breadcrumb {
@ -5469,7 +5469,7 @@ body .layui-table-tips .layui-layer-content {
}
.layui-breadcrumb a:hover {
color: #16b777 !important
color: #0081ff !important
}
.layui-breadcrumb a cite {
@ -5645,7 +5645,7 @@ body .layui-table-tips .layui-layer-content {
.layui-tab-brief>.layui-tab-title .layui-this:after {
border: none;
border-radius: 0;
border-bottom: 2px solid #16b777
border-bottom: 2px solid #0081ff
}
.layui-tab-card {
@ -5684,7 +5684,7 @@ body .layui-table-tips .layui-layer-content {
.layui-tab-card>.layui-tab-more .layui-this {
background: 0 0;
color: #16b777
color: #0081ff
}
.layui-tab-card>.layui-tab-more .layui-this:after {
@ -5709,7 +5709,7 @@ body .layui-table-tips .layui-layer-content {
height: 20px;
line-height: 20px;
background-color: #fff;
color: #16b777;
color: #0081ff;
border-radius: 50%;
text-align: center;
cursor: pointer
@ -6221,8 +6221,8 @@ body .layui-util-face .layui-layer-content {
display: block;
margin: 0;
padding: 0 15px;
background-color: #16b777;
border-color: #16b777;
background-color: #0081ff;
border-color: #0081ff;
color: #fff
}
@ -7322,7 +7322,7 @@ html #layuicss-skincodecss {
}
.layui-code-fixbar>span:hover {
color: #16b777
color: #0081ff
}
.layui-code-copy {
@ -7412,7 +7412,7 @@ html #layuicss-skincodecss {
}
.layui-code-tools>i:hover {
color: #16b777
color: #0081ff
}
.layui-code-full {
@ -7699,7 +7699,7 @@ html #layuicss-laydate {
}
.layui-laydate-footer span:hover {
color: #16b777
color: #0081ff
}
.layui-laydate-footer span.layui-laydate-preview {
@ -7883,7 +7883,7 @@ html #layuicss-laydate {
.layui-laydate-header i:hover,
.layui-laydate-header span:hover {
color: #16b777
color: #0081ff
}
.layui-laydate-content {
@ -7900,7 +7900,7 @@ html #layuicss-laydate {
}
.layui-laydate-content td.laydate-day-now {
color: #16b777
color: #0081ff
}
.layui-laydate-content td.laydate-day-now:after {
@ -7910,7 +7910,7 @@ html #layuicss-laydate {
height: 30px;
left: 0;
top: 0;
border: 1px solid #16b777;
border: 1px solid #0081ff;
box-sizing: border-box
}
@ -7970,7 +7970,7 @@ html #layuicss-laydate {
}
.laydate-day-mark::after {
background-color: #16b777
background-color: #0081ff
}
.layui-laydate-content td.layui-this .laydate-day-mark::after {
@ -7978,12 +7978,12 @@ html #layuicss-laydate {
}
.layui-laydate-footer span[lay-type=date] {
color: #16b777
color: #0081ff
}
.layui-laydate .layui-this,
.layui-laydate .layui-this>div {
background-color: #16b777 !important;
background-color: #0081ff !important;
color: #fff !important
}
@ -8832,7 +8832,7 @@ html #layuicss-layer {
}
.layui-layer-dialog .layui-layer-content .layui-icon-success {
color: #16b777
color: #0081ff
}
.layui-layer-dialog .layui-layer-content .layui-icon-error {
@ -8853,7 +8853,7 @@ html #layuicss-layer {
}
.layui-layer-dialog .layui-layer-content .layui-icon-face-smile {
color: #16b777
color: #0081ff
}
.layui-layer-rim {

View File

@ -1,4 +1,4 @@
<?php /*a:5:{s:63:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\articles\detail.php";i:1747818914;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\head.php";i:1747617129;s:71:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header-simple.php";i:1748316508;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1747617266;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\foot.php";i:1747616844;}*/ ?>
<?php /*a:5:{s:63:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\articles\detail.php";i:1748400078;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\head.php";i:1747617129;s:71:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header-simple.php";i:1748316508;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1747617266;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\foot.php";i:1747616844;}*/ ?>
<!DOCTYPE html>
<html>
@ -632,6 +632,7 @@ $loginStatus = [
<div class="article-detail-container">
<div class="article-header">
<h1 class="article-title" id="articleTitle"></h1>
<div class="trans" id="transDiv" style="display: none;">转载至:<span id="transUrl"></span></div>
<div class="article-meta">
<span class="article-author"><i class="fa fa-user"></i> <span id="articleAuthor"></span></span>
<span class="article-date"><i class="fa fa-calendar"></i> <span id="articleDate"></span></span>
@ -1205,6 +1206,22 @@ $loginStatus = [
} else {
relatedArticles.innerHTML = '<div class="no-related">暂无相关文章</div>';
}
// 处理转载信息
if (data.article.is_trans === 1 && data.article.transurl) {
const transDiv = document.getElementById('transDiv');
const transUrlSpan = document.getElementById('transUrl');
transUrlSpan.textContent = data.article.transurl;
transDiv.style.display = 'block';
// 添加点击事件,在新窗口打开原文章
transUrlSpan.style.cursor = 'pointer';
transUrlSpan.style.color = '#007bff';
transUrlSpan.addEventListener('click', function() {
window.open(data.article.transurl, '_blank');
});
}
}
// 页面加载完成后执行
@ -1222,13 +1239,8 @@ $loginStatus = [
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => {
// console.log('Response status:', response.status);
// console.log('Response headers:', response.headers);
return response.json();
})
.then(response => response.json())
.then(result => {
// console.log('API response:', result);
if (result.code === 1) {
renderArticleDetail(result.data);
// 更新访问次数
@ -1240,28 +1252,13 @@ $loginStatus = [
})
.catch(error => {
console.error('获取文章详情失败:', error);
console.error('Error details:', {
message: error.message,
stack: error.stack
});
alert('获取文章详情失败,请检查网络连接或刷新页面重试');
});
// 点赞功能
const likeBtn = document.getElementById('likeBtn');
if (likeBtn) {
// 检查是否已经点赞
if (likeBtn.classList.contains('liked')) {
likeBtn.style.pointerEvents = 'none'; // 禁用点击
likeBtn.style.cursor = 'default'; // 改变鼠标样式
return;
}
likeBtn.addEventListener('click', function () {
// 立即禁用按钮,防止重复点击
likeBtn.style.pointerEvents = 'none';
likeBtn.style.cursor = 'default';
fetch('/index/articles/like?id=' + articleId, {
method: 'POST',
headers: {
@ -1271,26 +1268,19 @@ $loginStatus = [
.then(response => response.json())
.then(data => {
if (data.code === 1) {
const countElement = document.getElementById('articlesLikes');
const countElement = document.getElementById('articleLikes');
if (countElement) {
let count = parseInt(countElement.textContent) || 0;
countElement.textContent = count + 1;
}
// 添加点赞状态
likeBtn.classList.add('liked');
likeBtn.querySelector('i').style.color = '#f57005';
layer.msg('点赞成功', { icon: 1 });
} else {
// 如果请求失败,恢复按钮状态
likeBtn.style.pointerEvents = 'auto';
likeBtn.style.cursor = 'pointer';
layer.msg('点赞失败:' + data.msg, { icon: 2 });
}
})
.catch(error => {
// 如果请求失败,恢复按钮状态
likeBtn.style.pointerEvents = 'auto';
likeBtn.style.cursor = 'pointer';
console.error('点赞请求失败:', error);
layer.msg('点赞失败,请稍后重试', { icon: 2 });
});
@ -1299,8 +1289,6 @@ $loginStatus = [
// 返回顶部功能
const goToTop = document.getElementById('goToTop');
// 监听滚动事件
window.addEventListener('scroll', function () {
if (window.pageYOffset > 300) {
goToTop.classList.add('show');
@ -1309,13 +1297,27 @@ $loginStatus = [
}
});
// 点击返回顶部
goToTop.addEventListener('click', function () {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
// 分享功能
const shareBtn = document.getElementById('shareBtn');
if (shareBtn) {
shareBtn.addEventListener('click', function () {
const currentUrl = window.location.href;
const tempInput = document.createElement('input');
tempInput.value = currentUrl;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand('copy');
document.body.removeChild(tempInput);
layer.msg('链接已复制到剪贴板', { icon: 1 });
});
}
});
// 更新文章访问次数
@ -1332,7 +1334,6 @@ $loginStatus = [
.then(response => response.json())
.then(result => {
if (result.code === 1) {
// 更新成功,更新页面上的访问次数显示
const viewsElement = document.getElementById('articleViews');
if (viewsElement) {
viewsElement.textContent = result.data.views;
@ -1343,30 +1344,6 @@ $loginStatus = [
console.error('更新访问次数失败:', error);
});
}
// 分享功能
const shareBtn = document.getElementById('shareBtn');
if (shareBtn) {
shareBtn.addEventListener('click', function () {
// 获取当前页面URL
const currentUrl = window.location.href;
// 创建临时输入框
const tempInput = document.createElement('input');
tempInput.value = currentUrl;
document.body.appendChild(tempInput);
// 选择并复制文本
tempInput.select();
document.execCommand('copy');
// 移除临时输入框
document.body.removeChild(tempInput);
// 提示用户复制成功
alert('链接已复制到剪贴板');
});
}
</script>
</body>

View File

@ -1,4 +1,4 @@
<?php /*a:4:{s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\index\index.php";i:1746865108;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header.php";i:1748316235;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\main.php";i:1747817496;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1747617266;}*/ ?>
<?php /*a:4:{s:59:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\index\index.php";i:1746865108;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\header.php";i:1748316235;s:62:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\main.php";i:1748398948;s:64:"E:\Demos\DemoOwns\PHP\yunzer\app\index\view\component\footer.php";i:1747617266;}*/ ?>
<!DOCTYPE html>
<html>
@ -702,7 +702,7 @@ $loginStatus = [
</div>
</div>
</div>
<div class="more-btn">更多</div>
<div class="more-btn" onclick="window.open('/index/articles/index?cateid=1', '_blank')">更多</div>
</div>
<div class="product-list" id="webArticlesList">
<!-- 文章将通过JavaScript动态加载 -->
@ -723,7 +723,7 @@ $loginStatus = [
</div>
</div>
</div>
<div class="more-btn">更多</div>
<div class="more-btn" onclick="window.open('/index/articles/index?cateid=3', '_blank')">更多</div>
</div>
<div class="product-list" id="techArticlesList">
<!-- 文章将通过JavaScript动态加载 -->
@ -744,7 +744,7 @@ $loginStatus = [
</div>
</div>
</div>
<div class="more-btn">更多</div>
<div class="more-btn" onclick="window.open('/index/program/index?cateid=2', '_blank')">更多</div>
</div>
<div class="product-list" id="resourcesDownloadList">
<!-- 文章将通过JavaScript动态加载 -->
@ -765,7 +765,7 @@ $loginStatus = [
</div>
</div>
</div>
<div class="more-btn">更多</div>
<div class="more-btn" onclick="window.open('/index/program/index?cateid=1', '_blank')">更多</div>
</div>
<div class="product-list" id="programDownloadList">
<!-- 程序将通过JavaScript动态加载 -->
@ -786,7 +786,7 @@ $loginStatus = [
</div>
</div>
</div>
<div class="more-btn">更多</div>
<div class="more-btn" onclick="window.open('/index/game/index?cateid=8', '_blank')">更多</div>
</div>
<div class="product-list" id="gameDownloadList">
<!-- 游戏将通过JavaScript动态加载 -->