From 12db90d9c1dce9fc09d67398e1172d0f78fe4426 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Thu, 22 May 2025 23:31:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E5=87=A0=E4=B8=AA=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E4=B8=BA=E7=A9=BA=E7=9A=84=E8=85=BE=E8=AE=AF=E4=BA=91?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controllers/UploadController.php | 22 ---------- app/Http/Home/Views/help/show.volt | 17 +++---- app/Http/Home/Views/page/show.volt | 17 +++---- app/Http/Home/Views/user/console/profile.volt | 3 +- db/migrations/20210403184518.php | 12 ++--- public/static/admin/js/avatar.upload.js | 44 ------------------- public/static/home/js/help.show.js | 12 +++++ public/static/home/js/page.show.js | 12 +++++ public/static/home/js/user.avatar.upload.js | 44 ------------------- public/static/home/js/user.console.profile.js | 44 ++++++++++++++++++- 10 files changed, 83 insertions(+), 144 deletions(-) delete mode 100644 public/static/admin/js/avatar.upload.js create mode 100644 public/static/home/js/help.show.js create mode 100644 public/static/home/js/page.show.js delete mode 100644 public/static/home/js/user.avatar.upload.js diff --git a/app/Http/Admin/Controllers/UploadController.php b/app/Http/Admin/Controllers/UploadController.php index 432e5129..ca020f3b 100644 --- a/app/Http/Admin/Controllers/UploadController.php +++ b/app/Http/Admin/Controllers/UploadController.php @@ -71,28 +71,6 @@ class UploadController extends Controller return $this->jsonSuccess(['data' => $data]); } - /** - * @Post("/avatar/img", name="admin.upload.avatar_img") - */ - public function uploadAvatarImageAction() - { - $service = new StorageService(); - - $file = $service->uploadAvatarImage(); - - if (!$file) { - return $this->jsonError(['msg' => '上传文件失败']); - } - - $data = [ - 'id' => $file->id, - 'name' => $file->name, - 'url' => $service->getImageUrl($file->path), - ]; - - return $this->jsonSuccess(['data' => $data]); - } - /** * @Post("/content/img", name="admin.upload.content_img") */ diff --git a/app/Http/Home/Views/help/show.volt b/app/Http/Home/Views/help/show.volt index 6c48660d..d513b031 100644 --- a/app/Http/Home/Views/help/show.volt +++ b/app/Http/Home/Views/help/show.volt @@ -31,17 +31,10 @@ {% endblock %} -{% block inline_js %} +{% block include_js %} - + {{ js_include('lib/clipboard.min.js') }} + {{ js_include('home/js/help.show.js') }} + {{ js_include('home/js/copy.js') }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/Http/Home/Views/page/show.volt b/app/Http/Home/Views/page/show.volt index 654c19aa..b824f461 100644 --- a/app/Http/Home/Views/page/show.volt +++ b/app/Http/Home/Views/page/show.volt @@ -30,17 +30,10 @@ {% endblock %} -{% block inline_js %} +{% block include_js %} - + {{ js_include('lib/clipboard.min.js') }} + {{ js_include('home/js/page.show.js') }} + {{ js_include('home/js/copy.js') }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/app/Http/Home/Views/user/console/profile.volt b/app/Http/Home/Views/user/console/profile.volt index 1574d1fd..8a47b597 100644 --- a/app/Http/Home/Views/user/console/profile.volt +++ b/app/Http/Home/Views/user/console/profile.volt @@ -79,7 +79,6 @@ {% block include_js %} - {{ js_include('home/js/user.avatar.upload.js') }} {{ js_include('home/js/user.console.profile.js') }} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/db/migrations/20210403184518.php b/db/migrations/20210403184518.php index 3186f788..b06c86bd 100644 --- a/db/migrations/20210403184518.php +++ b/db/migrations/20210403184518.php @@ -497,17 +497,17 @@ final class V20210403184518 extends AbstractMigration [ 'section' => 'secret', 'item_key' => 'secret_key', - 'item_value' => '', + 'item_value' => 'xxx', ], [ 'section' => 'secret', 'item_key' => 'secret_id', - 'item_value' => '', + 'item_value' => 'xxx', ], [ 'section' => 'secret', 'item_key' => 'app_id', - 'item_value' => '', + 'item_value' => 'xxx', ], [ 'section' => 'site', @@ -619,12 +619,12 @@ final class V20210403184518 extends AbstractMigration [ 'section' => 'cos', 'item_key' => 'bucket', - 'item_value' => '', + 'item_value' => 'course-1255691183', ], [ 'section' => 'cos', 'item_key' => 'region', - 'item_value' => '', + 'item_value' => 'ap-guangzhou', ], [ 'section' => 'cos', @@ -634,7 +634,7 @@ final class V20210403184518 extends AbstractMigration [ 'section' => 'cos', 'item_key' => 'domain', - 'item_value' => '', + 'item_value' => 'course-1255691183.file.myqcloud.com', ], [ 'section' => 'vod', diff --git a/public/static/admin/js/avatar.upload.js b/public/static/admin/js/avatar.upload.js deleted file mode 100644 index 6f235d29..00000000 --- a/public/static/admin/js/avatar.upload.js +++ /dev/null @@ -1,44 +0,0 @@ -layui.use(['jquery', 'layer', 'upload'], function () { - - var $ = layui.jquery; - var layer = layui.layer; - var upload = layui.upload; - - upload.render({ - elem: '#change-avatar', - url: '/admin/upload/avatar/img', - accept: 'images', - acceptMime: 'image/*', - size: 512, - auto: false, - before: function () { - layer.load(); - }, - choose: function (obj) { - var flag = true; - obj.preview(function (index, file, result) { - var img = new Image(); - img.src = result; - img.onload = function () { - if (img.width < 1000 && img.height < 1000) { - obj.upload(index, file); - } else { - flag = false; - layer.msg("图片尺寸必须小于 1000 * 1000"); - return false; - } - }; - return flag; - }); - }, - done: function (res, index, upload) { - $('#img-avatar').attr('src', res.data.url); - $('input[name=avatar]').val(res.data.url); - layer.closeAll('loading'); - }, - error: function (index, upload) { - layer.msg('上传文件失败', {icon: 2}); - } - }); - -}); \ No newline at end of file diff --git a/public/static/home/js/help.show.js b/public/static/home/js/help.show.js new file mode 100644 index 00000000..2e9a7403 --- /dev/null +++ b/public/static/home/js/help.show.js @@ -0,0 +1,12 @@ +layui.use(['jquery', 'helper'], function () { + + var $ = layui.jquery; + var helper = layui.helper; + + var $courseList = $('#course-list'); + + if ($courseList.length > 0) { + helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id')); + } + +}); diff --git a/public/static/home/js/page.show.js b/public/static/home/js/page.show.js new file mode 100644 index 00000000..2e9a7403 --- /dev/null +++ b/public/static/home/js/page.show.js @@ -0,0 +1,12 @@ +layui.use(['jquery', 'helper'], function () { + + var $ = layui.jquery; + var helper = layui.helper; + + var $courseList = $('#course-list'); + + if ($courseList.length > 0) { + helper.ajaxLoadHtml($courseList.data('url'), $courseList.attr('id')); + } + +}); diff --git a/public/static/home/js/user.avatar.upload.js b/public/static/home/js/user.avatar.upload.js deleted file mode 100644 index 2e468127..00000000 --- a/public/static/home/js/user.avatar.upload.js +++ /dev/null @@ -1,44 +0,0 @@ -layui.use(['jquery', 'layer', 'upload'], function () { - - var $ = layui.jquery; - var layer = layui.layer; - var upload = layui.upload; - - upload.render({ - elem: '#change-avatar', - url: '/upload/avatar/img', - accept: 'images', - acceptMime: 'image/*', - size: 512, - auto: false, - before: function () { - layer.load(); - }, - choose: function (obj) { - var flag = true; - obj.preview(function (index, file, result) { - var img = new Image(); - img.src = result; - img.onload = function () { - if (img.width < 1000 && img.height < 1000) { - obj.upload(index, file); - } else { - flag = false; - layer.msg("图片尺寸必须小于 1000 * 1000"); - return false; - } - }; - return flag; - }); - }, - done: function (res, index, upload) { - $('#img-avatar').attr('src', res.data.url); - $('input[name=avatar]').val(res.data.url); - layer.closeAll('loading'); - }, - error: function (index, upload) { - layer.msg('上传文件失败', {icon: 2}); - } - }); - -}); \ No newline at end of file diff --git a/public/static/home/js/user.console.profile.js b/public/static/home/js/user.console.profile.js index 6aa2f380..558813e4 100644 --- a/public/static/home/js/user.console.profile.js +++ b/public/static/home/js/user.console.profile.js @@ -1,7 +1,47 @@ -layui.use(['layarea'], function () { +layui.use(['jquery', 'upload', 'layer', 'layarea'], function () { + var $ = layui.jquery; + var layer = layui.layer; + var upload = layui.upload; var layarea = layui.layarea; + upload.render({ + elem: '#change-avatar', + url: '/upload/avatar/img', + accept: 'images', + acceptMime: 'image/*', + size: 512, + auto: false, + before: function () { + layer.load(); + }, + choose: function (obj) { + var flag = true; + obj.preview(function (index, file, result) { + var img = new Image(); + img.src = result; + img.onload = function () { + if (img.width < 1000 && img.height < 1000) { + obj.upload(index, file); + } else { + flag = false; + layer.msg("图片尺寸必须小于 1000 * 1000"); + return false; + } + }; + return flag; + }); + }, + done: function (res) { + $('#img-avatar').attr('src', res.data.url); + $('input[name=avatar]').val(res.data.url); + layer.closeAll('loading'); + }, + error: function () { + layer.msg('上传文件失败', {icon: 2}); + } + }); + layarea.render({ elem: '#area-picker', change: function (res) { @@ -9,4 +49,4 @@ layui.use(['layarea'], function () { } }); -}); \ No newline at end of file +});