getConfig(); if ($config['is_origin']) return true; Service::error(); } static $isViewFilter = false; public function moduleInit() { $config = $this->getConfig(); // 如果使用原登录路径 if ($config['is_origin']) { // 放到第一个执行,只执行一次 Hook::add('view_filter', function (&$content) { if (self::$isViewFilter) return true; self::$isViewFilter = true; $auth = new Auth(); if ($auth->isLogin()) return true; $config = $this->getConfig(); $request = Request::instance(); $module = strtolower($request->module()); $controller = strtolower($request->controller()); $action = strtolower($request->action()); if ($module == 'admin' && $controller == 'index' && $action == 'login') { $templateTypeList = []; $type = $config['type']; if (true == $config['dev']) { $type = input('type') ? input('type') : $type; $templateTypeList = get_addon_fullconfig('adminlogin')[0]['content']; $i = 1; foreach ($templateTypeList as &$item) { $item = "{$i}、{$item}"; $i++; } } $type = $type > 1 ? $type : ''; $path = APP_PATH. 'admin/view/adminlogin/login'.$type.'.html'; $temp = file_get_contents($path); $background = Config::get('fastadmin.login_background'); $background = $background ? (stripos($background, 'http') === 0 ? $background : config('site.cdnurl') . $background) : ''; $data = [ 'templateTypeList' => $templateTypeList, 'hasCaptcha' => 1, 'background' => $background ]; $content = (View::instance())->display($temp, $data); } return false; }, true); return true; } // 判断是否关闭fast自带登录 $addonConfig = get_addon_config('adminlogin'); $is = $addonConfig['close_fast']; if (!$is) { return true; } if (request()->module() != 'admin') { return true; } $controllername = Loader::parseName(request()->controller()); $actionname = strtolower(request()->action()); $path = str_replace('.', '/', $controllername) . '/' . $actionname; if ($path == 'index/login') { Service::error(); } } /** * 插件安装方法 * @return bool */ public function install() { return true; } /** * 插件卸载方法 * @return bool */ public function uninstall() { return true; } /** * 插件启用方法 * @return bool */ public function enable() { return true; } /** * 插件禁用方法 * @return bool */ public function disable() { return true; } }