diff --git a/app/admin/controller/api/Plugs.php b/app/admin/controller/api/Plugs.php index d77f5ca31..0f68e931f 100644 --- a/app/admin/controller/api/Plugs.php +++ b/app/admin/controller/api/Plugs.php @@ -35,7 +35,28 @@ class Plugs extends Controller { $this->title = '图标选择器'; $this->field = $this->app->request->get('field', 'icon'); - $this->fetch(realpath(__DIR__ . '/../../view/api/icon.html')); + $this->fetch('api/icon'); + } + + /** + * 前端脚本变量 + * @return \think\Response + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function script(): \think\Response + { + $debug = $this->app->isDebug() ? 'true' : 'false'; + $editor = sysconf("base.editor") ?: "ckeditor4"; + $taroot = sysuri("admin/index/index", [], false); + return response(join("\n", [ + "window.taDebug = {$debug};", + "window.taEditor = '{$editor}';", + "window.tapiRoot = '{$taroot}';", + ]))->header([ + 'Content-Type' => 'application/x-javascript' + ]); } /** diff --git a/app/admin/view/index/index.html b/app/admin/view/index/index.html index 98335660a..f2bc08a8c 100644 --- a/app/admin/view/index/index.html +++ b/app/admin/view/index/index.html @@ -16,11 +16,7 @@ {block name="style"}{/block} - +