From c5e5cace188ab4e8cd31f8ac3f7cbbb710a8f47e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BF=97=E5=BC=BA?= <357099073@qq.com> Date: Mon, 9 Jun 2025 17:36:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B5=84=E6=BA=90=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/ResourcesController.php | 20 +- app/admin/view/resources/add.php | 2 +- app/admin/view/resources/edit.php | 276 ++++++++- app/index/view/program/detail.php | 28 +- .../b3d14cddc6643d9e64445ceb5aac992a.png | Bin 0 -> 541263 bytes .../temp/606cb5a28477c3a4a33c90fc473c4624.php | 241 +++++++- .../temp/f8995f34639557c9f17f79801bc58d25.php | 541 +++++++++++++++++- 7 files changed, 1032 insertions(+), 76 deletions(-) create mode 100644 public/storage/uploads/20250609/b3d14cddc6643d9e64445ceb5aac992a.png diff --git a/app/admin/controller/ResourcesController.php b/app/admin/controller/ResourcesController.php index 0af4276..02e43a4 100644 --- a/app/admin/controller/ResourcesController.php +++ b/app/admin/controller/ResourcesController.php @@ -120,6 +120,7 @@ class ResourcesController extends BaseController 'title' => input('post.title'), 'cate' => input('post.cate'), 'icon' => input('post.icon'), + 'images' => input('post.images'), 'url' => input('post.url'), 'fileurl' => input('post.fileurl'), 'code' => input('post.code'), @@ -170,6 +171,7 @@ class ResourcesController extends BaseController 'desc' => $data['desc'], 'uploader' => $data['uploader'], 'icon' => $data['icon'], + 'images' => $data['images'], 'fileurl' => $data['fileurl'], 'url' => $data['url'], 'code' => $data['code'], @@ -201,12 +203,22 @@ class ResourcesController extends BaseController $resource = Resource::where('id', $id) ->where('delete_time', null) ->find(); - + if (!$resource) { Log::record('编辑资源', 0, '资源不存在', '资源管理'); $this->error('资源不存在'); } + // 处理图片路径 + if (!empty($resource['images'])) { + $domain = request()->domain(); + $images = explode(',', $resource['images']); + $images = array_map(function ($image) use ($domain) { + return $domain . $image; + }, $images); + $resource['images'] = implode(',', $images); + } + View::assign('resource', $resource); return View::fetch(); } @@ -248,7 +260,7 @@ class ResourcesController extends BaseController ->order('sort asc, id asc') ->select() ->toArray(); - + // 获取每个分类下的资源总数 foreach ($lists as &$item) { if ($item['cid'] == 0) { @@ -257,7 +269,7 @@ class ResourcesController extends BaseController ->where('delete_time', null) ->where('status', 1) ->column('id'); - + $item['total'] = Resource::where('cate', 'in', array_merge([$item['id']], $childIds)) ->where('delete_time', null) ->where('status', '<>', 3) @@ -270,7 +282,7 @@ class ResourcesController extends BaseController ->count(); } } - + $tree = $this->buildParentChild($lists); return json(['code' => 0, 'msg' => '获取成功', 'data' => $tree]); } diff --git a/app/admin/view/resources/add.php b/app/admin/view/resources/add.php index dcc6719..a93c6e7 100644 --- a/app/admin/view/resources/add.php +++ b/app/admin/view/resources/add.php @@ -260,7 +260,7 @@ accept: 'images', before: function (obj) { obj.preview(function (index, file, result) { - $('#imagePreview').append('
' + file.name + '

' + file.name + '

'); + $('#imagePreview').append('
' + file.name + '

' + file.name + '

'); }); element.progress('image-progress', '0%'); layer.msg('图片上传中', { icon: 16, time: 0 }); diff --git a/app/admin/view/resources/edit.php b/app/admin/view/resources/edit.php index 8ff2dd0..dda34f8 100644 --- a/app/admin/view/resources/edit.php +++ b/app/admin/view/resources/edit.php @@ -110,29 +110,42 @@
-
- -
- 预览图: -
- {if condition="$resource.images"} - {foreach name="images" item="image" explode=",", $resource.images} -
- 已上传图片 -

{$image|basename}

- +
+ +
+ {if condition="isset($resource.images) && !empty($resource.images)"} + {if condition="strpos($resource.images, ',') !== false"} + {volist name="resource.images|explode=',',true" id="image"} +
+ 已上传图片 +
+
- {/foreach} - {/if} +

{$image|basename}

-
+ {/volist} + {else} +
+ 已上传图片 +
+ +
+

{$resource.images|basename}

+
+ {/if} + {/if} +
+ +
-
-
-
-
@@ -266,7 +279,7 @@ accept: 'images', before: function (obj) { obj.preview(function (index, file, result) { - $('#imagePreview').append('
' + file.name + '

' + file.name + '

'); + $('#imagePreview').append('
' + file.name + '

' + file.name + '

'); }); element.progress('image-progress', '0%'); layer.msg('图片上传中', { icon: 16, time: 0 }); @@ -564,4 +577,223 @@ function goBack() { window.location.href = '{:url("resources/lists")}'; } - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/app/index/view/program/detail.php b/app/index/view/program/detail.php index 16963d3..b42030e 100644 --- a/app/index/view/program/detail.php +++ b/app/index/view/program/detail.php @@ -29,10 +29,21 @@ + +
- {volist name="program.images" id="image"} + {php} + // 强制统一处理:无论 images 是数组还是字符串,都转为数组 + $images = isset($program['images']) ? $program['images'] : []; + if (is_string($images)) { + $images = explode(',', $images); // 按逗号分隔字符串 + } + $images = array_filter($images); // 移除空值 + {/php} + + {volist name="images" id="image"}
+
资源简介
+
{$program.content|raw}
@@ -505,7 +518,9 @@ line-height: 1.8; color: #333; font-size: 16px; - margin-bottom: 30px; + margin: 30px 0; + padding-top: 30px; + border-top: 1px solid #eee; border-bottom: 1px solid #eee; } @@ -923,6 +938,7 @@ .program-show { margin: 20px 0; + margin-bottom: 60px; background: #fff; border-radius: 8px; padding: 20px; @@ -992,7 +1008,7 @@ font-weight: 900; font-size: 30px; color: #fff; - text-shadow: 0 0 3px rgba(0,0,0,0.5); + text-shadow: 0 0 3px rgba(0, 0, 0, 0.5); } .lb-nav a.lb-next:after { @@ -1001,7 +1017,7 @@ font-weight: 900; font-size: 30px; color: #fff; - text-shadow: 0 0 3px rgba(0,0,0,0.5); + text-shadow: 0 0 3px rgba(0, 0, 0, 0.5); } .lb-closeContainer { @@ -1022,7 +1038,7 @@ font-weight: 900; font-size: 30px; color: #fff; - text-shadow: 0 0 3px rgba(0,0,0,0.5); + text-shadow: 0 0 3px rgba(0, 0, 0, 0.5); } .lb-close:hover { @@ -1042,7 +1058,7 @@ \ No newline at end of file + + + + + \ No newline at end of file diff --git a/runtime/index/temp/f8995f34639557c9f17f79801bc58d25.php b/runtime/index/temp/f8995f34639557c9f17f79801bc58d25.php index daeb8cd..d7a6eef 100644 --- a/runtime/index/temp/f8995f34639557c9f17f79801bc58d25.php +++ b/runtime/index/temp/f8995f34639557c9f17f79801bc58d25.php @@ -1,4 +1,4 @@ - + @@ -18,7 +18,29 @@ + + + + +
- + + 阅读 - 下载 + + 下载 +
+
+ +
+
@@ -935,7 +983,7 @@ $loginStatus = [
-
+ + +
+
+
免责声明:
+
+ +
+
@@ -1016,25 +1064,25 @@ $loginStatus = [
-
关于作者
+
- 作者头像 + 作者头像
-
+
资源
- +
文章
- +
粉丝
@@ -1052,6 +1100,55 @@ $loginStatus = [
+ +
+ +
+
+
+
+ 软件编码: + +
+
+ 软件大小: + +
+
+ 更新时间: + +
+ +
+
+
+
+
+
下载
+ 点击下载 +
+
+
分享码
+ + + - + +
+
+
解压密码
+ + + + - + +
+
+
+
+
@@ -1189,6 +1286,66 @@ $loginStatus = [ }); + + + \ No newline at end of file