-
@@ -70,7 +70,7 @@
+
+
+
立即下载
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
分享
@@ -203,6 +208,11 @@
margin: 30px 0;
}
+ .program-navigation a {
+ color: #333;
+ text-decoration: none;
+ }
+
.prev-program,
.next-program {
max-width: 45%;
@@ -358,25 +368,25 @@
function renderProgramDetail(data) {
// 渲染分类链接
document.getElementById('cateLink').textContent = data.cateName;
-
+
// 渲染程序标题
document.getElementById('programTitle').textContent = data.program.title;
-
+
// 渲染程序元信息
document.getElementById('programAuthor').textContent = data.program.author;
document.getElementById('programDate').textContent = formatDate(data.program.create_time);
document.getElementById('programViews').textContent = data.program.views;
document.getElementById('programDownloads').textContent = data.program.downloads;
-
+
// 渲染程序内容
document.getElementById('programContent').innerHTML = data.program.content;
-
+
// 渲染程序信息
document.getElementById('programSize').textContent = data.program.size || '未知';
document.getElementById('programEnvironment').textContent = data.program.environment || '通用';
document.getElementById('programUpdateTime').textContent = formatDate(data.program.update_time);
document.getElementById('programVersion').textContent = data.program.version || '1.0.0';
-
+
// 渲染上一个程序
const prevProgram = document.getElementById('prevProgram');
if (data.prevProgram) {
@@ -388,7 +398,7 @@
} else {
prevProgram.innerHTML = ' 没有上一个了';
}
-
+
// 渲染下一个程序
const nextProgram = document.getElementById('nextProgram');
if (data.nextProgram) {
@@ -400,7 +410,7 @@
} else {
nextProgram.innerHTML = '没有下一个了 ';
}
-
+
// 渲染相关程序
const relatedPrograms = document.getElementById('relatedPrograms');
if (data.relatedPrograms && data.relatedPrograms.length > 0) {
@@ -423,7 +433,7 @@
}
// 页面加载完成后执行
- document.addEventListener('DOMContentLoaded', function() {
+ document.addEventListener('DOMContentLoaded', function () {
// 获取程序ID
const programId = new URLSearchParams(window.location.search).get('id');
if (!programId) {
@@ -437,72 +447,63 @@
'X-Requested-With': 'XMLHttpRequest'
}
})
- .then(response => response.json())
- .then(result => {
- if (result.code === 1) {
- renderProgramDetail(result.data);
- // 更新访问次数
- updateProgramViews(programId);
- } else {
- alert(result.msg || '获取程序详情失败');
- }
- })
- .catch(error => {
- console.error('获取程序详情失败:', error);
- alert('获取程序详情失败,请检查网络连接或刷新页面重试');
- });
+ .then(response => response.json())
+ .then(result => {
+ if (result.code === 1) {
+ renderProgramDetail(result.data);
+ // 更新访问次数
+ updateProgramViews(programId);
+ // 初始化分享功能
+ initShareFunction();
+ } else {
+ alert(result.msg || '获取程序详情失败');
+ }
+ })
+ .catch(error => {
+ console.error('获取程序详情失败:', error);
+ alert('获取程序详情失败,请检查网络连接或刷新页面重试');
+ });
// 下载功能
const downloadBtn = document.getElementById('downloadBtn');
if (downloadBtn) {
- downloadBtn.addEventListener('click', function() {
+ downloadBtn.addEventListener('click', function () {
fetch('/index/program/download?id=' + programId, {
method: 'POST',
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
})
- .then(response => response.json())
- .then(data => {
- if (data.code === 1) {
- const downloadsElement = document.getElementById('programDownloads');
- let downloads = parseInt(downloadsElement.textContent);
- downloadsElement.textContent = downloads + 1;
-
- // 获取当前域名
- const domain = window.location.origin;
- // 拼接完整的下载地址
- if (data.data && data.data.fileurl) {
- const downloadUrl = domain + data.data.fileurl;
+ .then(response => response.json())
+ .then(data => {
+ if (data.code === 1 && data.data && data.data.fileurl) {
+ const downloadUrl = window.location.origin + data.data.fileurl;
window.location.href = downloadUrl;
} else {
alert('下载地址不存在');
}
- } else {
- alert('下载失败:' + data.msg);
- }
- })
- .catch(error => {
- console.error('下载请求失败:', error);
- alert('下载请求失败,请稍后重试');
- });
+ })
+ .catch(error => {
+ console.error('下载请求失败:', error);
+ alert('下载请求失败,请稍后重试');
+ });
});
}
// 返回顶部功能
const goToTop = document.getElementById('goToTop');
-
+
// 监听滚动事件
- window.addEventListener('scroll', function() {
+ window.addEventListener('scroll', function () {
if (window.pageYOffset > 300) {
goToTop.classList.add('show');
} else {
goToTop.classList.remove('show');
}
});
-
+
// 点击返回顶部
- goToTop.addEventListener('click', function() {
+ goToTop.addEventListener('click', function () {
window.scrollTo({
top: 0,
behavior: 'smooth'
@@ -522,19 +523,45 @@
id: programId
})
})
- .then(response => response.json())
- .then(result => {
- if (result.code === 1) {
- // 更新成功,更新页面上的访问次数显示
- const viewsElement = document.getElementById('programViews');
- if (viewsElement) {
- viewsElement.textContent = result.data.views;
+ .then(response => response.json())
+ .then(result => {
+ if (result.code === 1) {
+ // 更新成功,更新页面上的访问次数显示
+ const viewsElement = document.getElementById('programViews');
+ if (viewsElement) {
+ viewsElement.textContent = result.data.views;
+ }
}
- }
- })
- .catch(error => {
- console.error('更新访问次数失败:', error);
- });
+ })
+ .catch(error => {
+ console.error('更新访问次数失败:', error);
+ });
+ }
+
+ // 初始化分享功能
+ function initShareFunction() {
+ 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);
+
+ // 提示用户复制成功
+ layer.msg('链接已复制到剪贴板');
+ });
+ }
}
{include file="component/foot" /}
\ No newline at end of file
diff --git a/public/nginx.htaccess b/public/nginx.htaccess
index 89c0c28..0548c35 100644
--- a/public/nginx.htaccess
+++ b/public/nginx.htaccess
@@ -1,8 +1,11 @@
-location ~* (runtime|application)/{
- return 403;
-}
location / {
- if (!-e $request_filename){
- rewrite ^(.*)$ /index.php?s=$1 last; break;
+ if (!-e $request_filename) {
+ rewrite ^(.*)$ /index.php?s=$1 last;
+ break;
}
+}
+
+# storage Ŀ¼
+location /storage/ {
+ try_files $uri $uri/ /index.php?s=$uri&$args;
}
\ No newline at end of file
diff --git a/public/storage/uploads/files/20250516/05e554dbbe6b4ea371fccd3b65918592.zip b/public/storage/uploads/files/20250516/05e554dbbe6b4ea371fccd3b65918592.zip
deleted file mode 100644
index ecbe219..0000000
Binary files a/public/storage/uploads/files/20250516/05e554dbbe6b4ea371fccd3b65918592.zip and /dev/null differ
diff --git a/public/storage/uploads/files/20250516/08333af521200683b652f036991ea936.zip b/public/storage/uploads/files/20250516/08333af521200683b652f036991ea936.zip
deleted file mode 100644
index ecbe219..0000000
Binary files a/public/storage/uploads/files/20250516/08333af521200683b652f036991ea936.zip and /dev/null differ
diff --git a/public/storage/uploads/files/20250516/a7db74cbdb2c6bd1c240ee44b6c98c66.zip b/public/storage/uploads/files/20250516/a7db74cbdb2c6bd1c240ee44b6c98c66.zip
deleted file mode 100644
index ecbe219..0000000
Binary files a/public/storage/uploads/files/20250516/a7db74cbdb2c6bd1c240ee44b6c98c66.zip and /dev/null differ
diff --git a/runtime/admin/temp/1c825d7302c9198f86d61f24e6c74d99.php b/runtime/admin/temp/1c825d7302c9198f86d61f24e6c74d99.php
new file mode 100644
index 0000000..2cb1971
--- /dev/null
+++ b/runtime/admin/temp/1c825d7302c9198f86d61f24e6c74d99.php
@@ -0,0 +1,850 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/runtime/admin/temp/4362e65c6d8297a2ebddffccccfcd7f3.php b/runtime/admin/temp/4362e65c6d8297a2ebddffccccfcd7f3.php
new file mode 100644
index 0000000..e89bb4f
--- /dev/null
+++ b/runtime/admin/temp/4362e65c6d8297a2ebddffccccfcd7f3.php
@@ -0,0 +1,300 @@
+
+
+
+
+
+
+
+ 欢迎使用
+今天是 ,祝您工作愉快
+
+
+
+
+
+
+
+ 用户总数
+
+ 👥
+
+
+ 今日访问
+
+ 📊
+
+
+ 文章总数
+
+ 📝
+
+
+ 资源总数
+
+ 📦
+
+
+ 最近动态
+
+ $activity): $mod = ($i % 2 );++$i;?>
+
+
+
+
+
+
+
+
+
+
+
+
+ 访问趋势
+ +
+
+ 用户增长
+ +
+
+ 资源统计
+ +
+
+文章统计
+ +
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/runtime/admin/temp/606cb5a28477c3a4a33c90fc473c4624.php b/runtime/admin/temp/606cb5a28477c3a4a33c90fc473c4624.php
new file mode 100644
index 0000000..54339d7
--- /dev/null
+++ b/runtime/admin/temp/606cb5a28477c3a4a33c90fc473c4624.php
@@ -0,0 +1,426 @@
+
+
+
+
+
+
+
+
+
+ 资源列表
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/runtime/admin/temp/7013e3bcaaaa1c5a1494af79f99ce42f.php b/runtime/admin/temp/7013e3bcaaaa1c5a1494af79f99ce42f.php
new file mode 100644
index 0000000..72987fd
--- /dev/null
+++ b/runtime/admin/temp/7013e3bcaaaa1c5a1494af79f99ce42f.php
@@ -0,0 +1,425 @@
+
+
+
+
+
+
+
+
+
+
+ 编辑资源
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
- + + + 工作台 + + + + $vo): $mod = ($i % 2 );++$i;?> +
- + + onclick="menuFire('',1)" > + + + + + + + + +
+ POWER BY 云泽网
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/runtime/index/temp/745a6917c29d4d1aec94c5bc5dbce0b2.php b/runtime/index/temp/745a6917c29d4d1aec94c5bc5dbce0b2.php
index 345bf86..963a5c7 100644
--- a/runtime/index/temp/745a6917c29d4d1aec94c5bc5dbce0b2.php
+++ b/runtime/index/temp/745a6917c29d4d1aec94c5bc5dbce0b2.php
@@ -1,4 +1,4 @@
-
+
@@ -48,7 +48,7 @@
+
+
+
+
+
+ 后台管理系统
+
+
+
+
+
+
+ -
@@ -90,7 +90,7 @@
-
@@ -475,12 +475,12 @@
-
+
点赞
0
-
+
分享
@@ -932,31 +932,31 @@
function renderArticleDetail(data) {
// 渲染分类链接
document.getElementById('cateLink').textContent = data.cateName;
-
+
// 渲染文章标题
document.getElementById('articleTitle').textContent = data.article.title;
-
+
// 渲染文章元信息
document.getElementById('articleAuthor').textContent = data.article.author;
document.getElementById('articleDate').textContent = formatDate(data.article.create_time);
document.getElementById('articleViews').textContent = data.article.views;
-
+
// 渲染文章内容
document.getElementById('articleContent').innerHTML = data.article.content;
-
+
// 渲染标签
const tagsContainer = document.getElementById('articleTags');
if (data.article.tags && data.article.tags.length > 0) {
- tagsContainer.innerHTML = data.article.tags.map(tag =>
+ tagsContainer.innerHTML = data.article.tags.map(tag =>
`${tag}`
).join('');
} else {
tagsContainer.innerHTML = '暂无标签';
}
-
+
// 渲染点赞数
document.getElementById('articleLikes').textContent = data.article.likes || 0;
-
+
// 渲染上一篇
const prevArticle = document.getElementById('prevArticle');
if (data.prevArticle) {
@@ -968,7 +968,7 @@
} else {
prevArticle.innerHTML = ' 没有上一篇了';
}
-
+
// 渲染下一篇
const nextArticle = document.getElementById('nextArticle');
if (data.nextArticle) {
@@ -980,7 +980,7 @@
} else {
nextArticle.innerHTML = '没有下一篇了 ';
}
-
+
// 渲染相关文章
const relatedArticles = document.getElementById('relatedArticles');
if (data.relatedArticles && data.relatedArticles.length > 0) {
@@ -1003,7 +1003,7 @@
}
// 页面加载完成后执行
- document.addEventListener('DOMContentLoaded', function() {
+ document.addEventListener('DOMContentLoaded', function () {
// 获取文章ID
const articleId = new URLSearchParams(window.location.search).get('id');
if (!articleId) {
@@ -1018,12 +1018,12 @@
}
})
.then(response => {
- console.log('Response status:', response.status);
- console.log('Response headers:', response.headers);
+ // console.log('Response status:', response.status);
+ // console.log('Response headers:', response.headers);
return response.json();
})
.then(result => {
- console.log('API response:', result);
+ // console.log('API response:', result);
if (result.code === 1) {
renderArticleDetail(result.data);
// 更新访问次数
@@ -1043,44 +1043,69 @@
});
// 点赞功能
- const likeBtn = document.querySelector('.like-btn');
+ const likeBtn = document.getElementById('likeBtn');
if (likeBtn) {
- likeBtn.addEventListener('click', function() {
+ // 检查是否已经点赞
+ 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'
- })
- .then(response => response.json())
- .then(data => {
- if (data.code === 1) {
- const countElement = this.querySelector('.action-count');
- let count = parseInt(countElement.textContent);
- countElement.textContent = count + 1;
- this.classList.add('liked');
- this.style.color = '#f57005';
- } else {
- alert('点赞失败:' + data.msg);
+ method: 'POST',
+ headers: {
+ 'X-Requested-With': 'XMLHttpRequest'
}
})
- .catch(error => {
- console.error('点赞请求失败:', error);
- });
+ .then(response => response.json())
+ .then(data => {
+ if (data.code === 1) {
+ const countElement = document.getElementById('articlesLikes');
+ 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});
+ });
});
}
// 返回顶部功能
const goToTop = document.getElementById('goToTop');
-
+
// 监听滚动事件
- window.addEventListener('scroll', function() {
+ window.addEventListener('scroll', function () {
if (window.pageYOffset > 300) {
goToTop.classList.add('show');
} else {
goToTop.classList.remove('show');
}
});
-
+
// 点击返回顶部
- goToTop.addEventListener('click', function() {
+ goToTop.addEventListener('click', function () {
window.scrollTo({
top: 0,
behavior: 'smooth'
@@ -1099,18 +1124,42 @@
id: articleId
})
})
- .then(response => response.json())
- .then(result => {
- if (result.code === 1) {
- // 更新成功,更新页面上的访问次数显示
- const viewsElement = document.getElementById('articleViews');
- if (viewsElement) {
- viewsElement.textContent = result.data.views;
+ .then(response => response.json())
+ .then(result => {
+ if (result.code === 1) {
+ // 更新成功,更新页面上的访问次数显示
+ const viewsElement = document.getElementById('articleViews');
+ if (viewsElement) {
+ viewsElement.textContent = result.data.views;
+ }
}
- }
- })
- .catch(error => {
- console.error('更新访问次数失败:', error);
+ })
+ .catch(error => {
+ 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('链接已复制到剪贴板');
});
}
diff --git a/runtime/index/temp/f8995f34639557c9f17f79801bc58d25.php b/runtime/index/temp/f8995f34639557c9f17f79801bc58d25.php
index 7d59581..70eb30f 100644
--- a/runtime/index/temp/f8995f34639557c9f17f79801bc58d25.php
+++ b/runtime/index/temp/f8995f34639557c9f17f79801bc58d25.php
@@ -1,4 +1,4 @@
-
+
@@ -13,7 +13,7 @@
-
+
@@ -48,7 +48,7 @@
+
+
+
+
立即下载
-
+
分享
@@ -573,7 +578,7 @@
+ src="https://v6-widget.51.la/v6/KoyzaWWEcLvPzkQn/quote.js?theme=#1690FF,#FFFFFF,#999999,#FFFFFF,#FFFFFF,#1690FF,12&f=12">
@@ -703,6 +708,11 @@
margin: 30px 0;
}
+ .program-navigation a {
+ color: #333;
+ text-decoration: none;
+ }
+
.prev-program,
.next-program {
max-width: 45%;
@@ -858,25 +868,25 @@
function renderProgramDetail(data) {
// 渲染分类链接
document.getElementById('cateLink').textContent = data.cateName;
-
+
// 渲染程序标题
document.getElementById('programTitle').textContent = data.program.title;
-
+
// 渲染程序元信息
document.getElementById('programAuthor').textContent = data.program.author;
document.getElementById('programDate').textContent = formatDate(data.program.create_time);
document.getElementById('programViews').textContent = data.program.views;
document.getElementById('programDownloads').textContent = data.program.downloads;
-
+
// 渲染程序内容
document.getElementById('programContent').innerHTML = data.program.content;
-
+
// 渲染程序信息
document.getElementById('programSize').textContent = data.program.size || '未知';
document.getElementById('programEnvironment').textContent = data.program.environment || '通用';
document.getElementById('programUpdateTime').textContent = formatDate(data.program.update_time);
document.getElementById('programVersion').textContent = data.program.version || '1.0.0';
-
+
// 渲染上一个程序
const prevProgram = document.getElementById('prevProgram');
if (data.prevProgram) {
@@ -888,7 +898,7 @@
} else {
prevProgram.innerHTML = ' 没有上一个了';
}
-
+
// 渲染下一个程序
const nextProgram = document.getElementById('nextProgram');
if (data.nextProgram) {
@@ -900,7 +910,7 @@
} else {
nextProgram.innerHTML = '没有下一个了 ';
}
-
+
// 渲染相关程序
const relatedPrograms = document.getElementById('relatedPrograms');
if (data.relatedPrograms && data.relatedPrograms.length > 0) {
@@ -923,7 +933,7 @@
}
// 页面加载完成后执行
- document.addEventListener('DOMContentLoaded', function() {
+ document.addEventListener('DOMContentLoaded', function () {
// 获取程序ID
const programId = new URLSearchParams(window.location.search).get('id');
if (!programId) {
@@ -937,72 +947,63 @@
'X-Requested-With': 'XMLHttpRequest'
}
})
- .then(response => response.json())
- .then(result => {
- if (result.code === 1) {
- renderProgramDetail(result.data);
- // 更新访问次数
- updateProgramViews(programId);
- } else {
- alert(result.msg || '获取程序详情失败');
- }
- })
- .catch(error => {
- console.error('获取程序详情失败:', error);
- alert('获取程序详情失败,请检查网络连接或刷新页面重试');
- });
+ .then(response => response.json())
+ .then(result => {
+ if (result.code === 1) {
+ renderProgramDetail(result.data);
+ // 更新访问次数
+ updateProgramViews(programId);
+ // 初始化分享功能
+ initShareFunction();
+ } else {
+ alert(result.msg || '获取程序详情失败');
+ }
+ })
+ .catch(error => {
+ console.error('获取程序详情失败:', error);
+ alert('获取程序详情失败,请检查网络连接或刷新页面重试');
+ });
// 下载功能
const downloadBtn = document.getElementById('downloadBtn');
if (downloadBtn) {
- downloadBtn.addEventListener('click', function() {
+ downloadBtn.addEventListener('click', function () {
fetch('/index/program/download?id=' + programId, {
method: 'POST',
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
})
- .then(response => response.json())
- .then(data => {
- if (data.code === 1) {
- const downloadsElement = document.getElementById('programDownloads');
- let downloads = parseInt(downloadsElement.textContent);
- downloadsElement.textContent = downloads + 1;
-
- // 获取当前域名
- const domain = window.location.origin;
- // 拼接完整的下载地址
- if (data.data && data.data.fileurl) {
- const downloadUrl = domain + data.data.fileurl;
+ .then(response => response.json())
+ .then(data => {
+ if (data.code === 1 && data.data && data.data.fileurl) {
+ const downloadUrl = window.location.origin + data.data.fileurl;
window.location.href = downloadUrl;
} else {
alert('下载地址不存在');
}
- } else {
- alert('下载失败:' + data.msg);
- }
- })
- .catch(error => {
- console.error('下载请求失败:', error);
- alert('下载请求失败,请稍后重试');
- });
+ })
+ .catch(error => {
+ console.error('下载请求失败:', error);
+ alert('下载请求失败,请稍后重试');
+ });
});
}
// 返回顶部功能
const goToTop = document.getElementById('goToTop');
-
+
// 监听滚动事件
- window.addEventListener('scroll', function() {
+ window.addEventListener('scroll', function () {
if (window.pageYOffset > 300) {
goToTop.classList.add('show');
} else {
goToTop.classList.remove('show');
}
});
-
+
// 点击返回顶部
- goToTop.addEventListener('click', function() {
+ goToTop.addEventListener('click', function () {
window.scrollTo({
top: 0,
behavior: 'smooth'
@@ -1022,22 +1023,47 @@
id: programId
})
})
- .then(response => response.json())
- .then(result => {
- if (result.code === 1) {
- // 更新成功,更新页面上的访问次数显示
- const viewsElement = document.getElementById('programViews');
- if (viewsElement) {
- viewsElement.textContent = result.data.views;
+ .then(response => response.json())
+ .then(result => {
+ if (result.code === 1) {
+ // 更新成功,更新页面上的访问次数显示
+ const viewsElement = document.getElementById('programViews');
+ if (viewsElement) {
+ viewsElement.textContent = result.data.views;
+ }
}
- }
- })
- .catch(error => {
- console.error('更新访问次数失败:', error);
- });
+ })
+ .catch(error => {
+ console.error('更新访问次数失败:', error);
+ });
+ }
+
+ // 初始化分享功能
+ function initShareFunction() {
+ 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);
+
+ // 提示用户复制成功
+ layer.msg('链接已复制到剪贴板');
+ });
+ }
}
-
-
+
\ No newline at end of file


