mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-07 18:42:49 +08:00
增加response的事件机制;为login增加事件;发布新版本
This commit is contained in:
@@ -14,13 +14,13 @@ use think\facade\App;
|
||||
|
||||
class Version extends Command
|
||||
{
|
||||
public const VERSION = 'v2.0.38';
|
||||
public const VERSION = 'v2.0.3';
|
||||
|
||||
public const LAYUI_VERSION = '2.8.16';
|
||||
|
||||
public const COMMENT = [
|
||||
'增加js的事件处理',
|
||||
'增加忘记密码的js替换事件',
|
||||
'增加response的事件机制',
|
||||
'为login增加事件',
|
||||
'发布新版本',
|
||||
];
|
||||
|
||||
|
||||
@@ -141,20 +141,22 @@ class AdminController extends BaseController
|
||||
return $this->app->view->assign($name, $value);
|
||||
}
|
||||
|
||||
protected function fetchJS()
|
||||
public function fetchJS($template = '')
|
||||
{
|
||||
$content_js = '';
|
||||
|
||||
try {
|
||||
$content_js .= View::layout(false)
|
||||
->config([
|
||||
'view_suffix' => 'js',
|
||||
])->fetch('_common');
|
||||
$common_template = '_common';
|
||||
|
||||
$content_js .= View::layout(false)
|
||||
->config([
|
||||
'view_suffix' => 'js',
|
||||
])->fetch();
|
||||
if (!empty($template)) {
|
||||
$template_arr = explode('/', $template);
|
||||
unset($template_arr[count($template_arr) - 1]);
|
||||
$template_arr[] = '_common';
|
||||
$common_template = implode('/', $template_arr);
|
||||
}
|
||||
|
||||
try {
|
||||
$content_js .= View::layout(false)->fetchJS($common_template);
|
||||
$content_js .= View::layout(false)->fetchJS($template);
|
||||
} catch (TemplateNotFoundException $th) {
|
||||
if (Env::get('adminsystem.strict_view_js', true)) {
|
||||
throw $th;
|
||||
@@ -174,7 +176,7 @@ class AdminController extends BaseController
|
||||
{
|
||||
$this->assign('data_brage', json_encode($this->dataBrage));
|
||||
|
||||
$vars['content_js'] = $this->fetchJS();
|
||||
$vars['content_js'] = $this->fetchJS($template);
|
||||
|
||||
$content_main = View::layout($this->layout)
|
||||
->config([
|
||||
|
||||
17
app/common/event/AdminLoginIndex/Index.php
Normal file
17
app/common/event/AdminLoginIndex/Index.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\event\AdminLoginIndex;
|
||||
|
||||
class Index
|
||||
{
|
||||
public function handle($params)
|
||||
{
|
||||
$controller = $params['controller'];
|
||||
|
||||
$controller->assign('captcha',1);
|
||||
|
||||
return [
|
||||
'response' => $controller->fetch('login/ext/index'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -48,4 +48,36 @@ class View extends ThinkView
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析和获取模板内容 用于输出.
|
||||
* @param string $template 模板文件名或者内容
|
||||
* @param array $vars 模板变量
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function fetch(string $template = '', array $vars = []): string
|
||||
{
|
||||
return $this->config([
|
||||
'view_suffix' => 'html',
|
||||
])->getContent(function () use ($vars, $template) {
|
||||
$this->engine()->fetch($template, array_merge($this->data, $vars));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析和获取模板内容 用于输出.
|
||||
* @param string $template 模板文件名或者内容
|
||||
* @param array $vars 模板变量
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function fetchJS(string $template = '', array $vars = []): string
|
||||
{
|
||||
return $this->config([
|
||||
'view_suffix' => 'js',
|
||||
])->getContent(function () use ($vars, $template) {
|
||||
$this->engine()->fetch($template, array_merge($this->data, $vars));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user