From e176ed19e59021a2365096e3446fc1d978630fab Mon Sep 17 00:00:00 2001 From: augushong Date: Sat, 23 Sep 2023 11:47:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0js=E7=9A=84=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=9B=E5=A2=9E=E5=8A=A0=E5=BF=98=E8=AE=B0?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E7=9A=84js=E6=9B=BF=E6=8D=A2=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=EF=BC=9B=E5=8F=91=E5=B8=83=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/view/login/index.html | 1 + app/admin/view/login/index.js | 9 ++++++--- app/common.php | 16 +++++++++++++--- app/common/command/admin/Version.php | 7 +++---- public/static/plugs/ulthon-admin/ulthon-admin.js | 10 +++++++++- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/app/admin/view/login/index.html b/app/admin/view/login/index.html index 2287833..1a19096 100644 --- a/app/admin/view/login/index.html +++ b/app/admin/view/login/index.html @@ -33,6 +33,7 @@ 保持登录 {:event_view_replace('忘记密码?','AdminLoginForget')} + {:event_view_replace_js('AdminLoginForget')}
diff --git a/app/admin/view/login/index.js b/app/admin/view/login/index.js index 1c7a4fe..b9e1e4a 100644 --- a/app/admin/view/login/index.js +++ b/app/admin/view/login/index.js @@ -38,8 +38,11 @@ $(function () { }); }); - - $('.forget-password').click(function () { - layer.msg('可以使用重置密码命令设置:
php think admin:reset:password
参考文档'); + ua.triggerEventReplaceJs('AdminLoginForget', () => { + $('.forget-password').click(function () { + layer.msg('可以使用重置密码命令设置:
php think admin:reset:password
参考文档'); + }); + }, (code) => { + eval(code); }); }); \ No newline at end of file diff --git a/app/common.php b/app/common.php index db61ced..4f772b5 100644 --- a/app/common.php +++ b/app/common.php @@ -230,7 +230,7 @@ function build_upload_url($url, $upload_type = null) return Filesystem::disk($upload_type)->url($url); } -function event_handle_result($name, $key, $type = 'all') +function event_handle_result($name, $key, $type = 'all') : array { $list_result = Event::trigger($name); @@ -246,9 +246,10 @@ function event_handle_result($name, $key, $type = 'all') if ($type == 'all') { $result[] = $value_event[$key]; } elseif ($type == 'last') { - $result = $value_event[$key]; + $result = []; + $result[] = $value_event[$key]; } elseif ($type == 'first') { - $result = $value_event[$key]; + $result[] = $value_event[$key]; break; } } @@ -277,3 +278,12 @@ function event_view_replace($content, $name) return $content_event; } + +function event_view_replace_js($name) +{ + $list_result = event_handle_result($name, 'view_replace_js'); + + $content_event = implode('', $list_result); + + return ""; +} diff --git a/app/common/command/admin/Version.php b/app/common/command/admin/Version.php index d351e3a..3c81bd9 100644 --- a/app/common/command/admin/Version.php +++ b/app/common/command/admin/Version.php @@ -14,14 +14,13 @@ use think\facade\App; class Version extends Command { - public const VERSION = 'v2.0.37'; + public const VERSION = 'v2.0.38'; public const LAYUI_VERSION = '2.8.16'; public const COMMENT = [ - '修改事件处理函数的逻辑', - '修改忘记密码提示', - '忘记密码增加view_replace事件', + '增加js的事件处理', + '增加忘记密码的js替换事件', '发布新版本', ]; diff --git a/public/static/plugs/ulthon-admin/ulthon-admin.js b/public/static/plugs/ulthon-admin/ulthon-admin.js index 6607300..de91253 100644 --- a/public/static/plugs/ulthon-admin/ulthon-admin.js +++ b/public/static/plugs/ulthon-admin/ulthon-admin.js @@ -2470,8 +2470,16 @@ return num + u; } return '0B'; - } + }, + triggerEventReplaceJs(name, defaultCallback, replaceCallback) { + var code = $('#event-replace-js-' + name).html(); + if (admin.empty(code)) { + defaultCallback(); + } else { + replaceCallback(code); + } + } }; window.ulAdmin = window.ua = admin;