diff --git a/app/admin/controller/Login.php b/app/admin/controller/Login.php index ef8693fb9..22a69f884 100644 --- a/app/admin/controller/Login.php +++ b/app/admin/controller/Login.php @@ -43,22 +43,28 @@ class Login extends Controller if (AdminService::instance()->isLogin()) { $this->redirect(sysuri('admin/index/index')); } else { - $this->title = '系统登录'; + + // 登录验证码 $this->captchaType = 'LoginCaptcha'; $this->captchaToken = CodeExtend::uniqidDate(18); - $this->developMode = SystemService::instance()->checkRunMode(); - + // 当前运行模式 + $system = SystemService::instance(); + $this->developMode = $system->checkRunMode(); // 后台背景处理 - $images = str2arr(sysconf('login_image') ?: '', '|') ?: ['/static/theme/img/login/bg1.jpg', '/static/theme/img/login/bg2.jpg']; + $images = str2arr(sysconf('login_image') ?: '', '|') ?: [ + $system->paths('/static/theme/img/login/bg1.jpg')['__ROOT__'], + $system->paths('/static/theme/img/login/bg2.jpg')['__ROOT__'], + ]; $this->loginStyle = sprintf('style="background-image:url(%s)" data-bg-transition="%s"', $images[0], join(',', $images)); - - // 刷新当前后台域名 + // 记录后台域名 $host = "{$this->request->scheme()}://{$this->request->host()}"; if ($host !== sysconf('base.site_host')) sysconf('base.site_host', $host); // 标记登录验证令牌 if (!$this->app->session->get('LoginInputSessionError')) { $this->app->session->set($this->captchaType, $this->captchaToken); } + // 加载显示登录模板 + $this->title = '系统登录'; $this->fetch(); } } else { diff --git a/app/admin/view/login/index.html b/app/admin/view/login/index.html index 1a5ef752d..9babe29ae 100644 --- a/app/admin/view/login/index.html +++ b/app/admin/view/login/index.html @@ -1,11 +1,17 @@ {extend name="index/index"} +{block name='style'} + + + +{/block} + {block name="body"} -
+
{:sysconf('app_name')}{:sysconf('app_version')} {notempty name='developMode'} - + Fork me on Gitee {/notempty} @@ -46,12 +52,6 @@
{/block} -{block name='style'} - - - -{/block} - {block name='script'} {/block} \ No newline at end of file diff --git a/config/view.php b/config/view.php index a9c21479e..ae4c45043 100644 --- a/config/view.php +++ b/config/view.php @@ -14,6 +14,8 @@ // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin // +---------------------------------------------------------------------- +use think\admin\service\SystemService; + return [ // 模板引擎类型使用 Think 'type' => 'Think', @@ -40,9 +42,5 @@ return [ // 标签默认过滤输出方法 'default_filter' => 'htmlentities=###,ENT_QUOTES', // 定义模板替换字符串 - 'tpl_replace_string' => [ - '__APP__' => rtrim(url('@')->build(), '\\/'), - '__ROOT__' => rtrim(dirname(request()->basefile()), '\\/'), - '__FULL__' => rtrim(dirname(request()->basefile(true)), '\\/'), - ], + 'tpl_replace_string' => SystemService::instance()->paths(), ]; \ No newline at end of file