diff --git a/.gitignore b/.gitignore index bc119718ebc56849a2ceaaedcc482ae7113d1fa4..b850c06bf1caee079334ce985c3cb36faa2790ee 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /runtime/* /addons/* /application/admin/command/Install/*.lock +/application/extra/site.php /public/assets/libs/ /public/assets/addons/* /public/uploads/* diff --git a/application/admin/command/Install.php b/application/admin/command/Install.php index 99414c3925d4a4bda4f59c4817450872f42df48f..1d3bcfd46f14b84a7340e9347d26d0be150c66fb 100644 --- a/application/admin/command/Install.php +++ b/application/admin/command/Install.php @@ -64,7 +64,7 @@ class Install extends Command } $adminUsername = 'admin'; - $adminPassword = Random::alnum(10); + $adminPassword = Config::get('app_debug') ? '123456' : Random::alnum(10); $adminEmail = 'admin@admin.com'; $siteName = __('My Website'); @@ -246,28 +246,33 @@ class Install extends Command // 修改后台入口 $adminName = ''; if (is_file($adminFile)) { - $adminName = Random::alpha(10) . '.php'; - rename($adminFile, ROOT_PATH . 'public' . DS . $adminName); + if (Config::get('app_debug')) { + $adminName = 'admin.php'; + } else { + $adminName = Random::alpha(10) . '.php'; + rename($adminFile, ROOT_PATH . 'public' . DS . $adminName); + } } //修改站点名称 if ($siteName != config('site.name')) { $instance->name('config')->where('name', 'name')->update(['value' => $siteName]); - $siteConfigFile = CONF_PATH . 'extra' . DS . 'site.php'; - $siteConfig = include $siteConfigFile; - $configList = $instance->name("config")->select(); - foreach ($configList as $k => $value) { - if (in_array($value['type'], ['selects', 'checkbox', 'images', 'files'])) { - $value['value'] = explode(',', $value['value']); - } - if ($value['type'] == 'array') { - $value['value'] = (array)json_decode($value['value'], true); - } - $siteConfig[$value['name']] = $value['value']; + } + + // 生成站点配置文件 + $siteConfigFile = CONF_PATH . 'extra' . DS . 'site.php'; + $siteConfig = []; + $configList = $instance->name("config")->select(); + foreach ($configList as $k => $value) { + if (in_array($value['type'], ['selects', 'checkbox', 'images', 'files'])) { + $value['value'] = explode(',', $value['value']); + } + if ($value['type'] == 'array') { + $value['value'] = (array)json_decode($value['value'], true); } - $siteConfig['name'] = $siteName; - file_put_contents($siteConfigFile, 'request->file('file'); try { - $uid = $this->request->post("uid"); - $token = $this->request->post("token"); - $faversion = $this->request->post("faversion"); - if (!$uid || !$token) { - throw new Exception(__('Please login and try to install')); + $extend = []; + if (Config::get('api_url')) { + $uid = $this->request->post("uid"); + $token = $this->request->post("token"); + $faversion = $this->request->post("faversion"); + if (!$uid || !$token) { + throw new Exception(__('Please login and try to install')); + } + $extend = [ + 'uid' => $uid, + 'token' => $token, + 'faversion' => $faversion + ]; } - $extend = [ - 'uid' => $uid, - 'token' => $token, - 'faversion' => $faversion - ]; $info = Service::local($file, $extend); } catch (AddonException $e) { $this->result($e->getData(), $e->getCode(), __($e->getMessage())); diff --git a/application/admin/lang/zh-cn/auth/rule.php b/application/admin/lang/zh-cn/auth/rule.php index 053d11df7c862045063d5a7132ccba420b0514cc..7d48733e9eac6e8472352b018a9a793568ffc11a 100644 --- a/application/admin/lang/zh-cn/auth/rule.php +++ b/application/admin/lang/zh-cn/auth/rule.php @@ -25,4 +25,5 @@ return [ 'Can not change the parent to child' => '父级不能是它的子级', 'Can not change the parent to self' => '父级不能是它自己', 'Name only supports letters, numbers, underscore and slash' => 'URL规则只能是小写字母、数字、下划线和/组成', + 'Isdebug' => '调试模式显示', ]; diff --git a/application/admin/library/Auth.php b/application/admin/library/Auth.php index 5e265f5cc14ba296a80c75055045006e3f355b52..7f2042dc737f2ba45459278bd46513e031152ddf 100644 --- a/application/admin/library/Auth.php +++ b/application/admin/library/Auth.php @@ -385,6 +385,7 @@ class Auth extends \fast\Auth $colorNums = count($colorArr); $badgeList = []; $module = request()->module(); + $debug = Config::get('app_debug'); // 生成菜单的badge foreach ($params as $k => $v) { $url = $k; @@ -411,11 +412,21 @@ class Auth extends \fast\Auth // 必须将结果集转换为数组 $ruleList = collection(\app\admin\model\AuthRule::where('status', 'normal') ->where('ismenu', 1) + ->where(function ($query) use ($debug) { + if ($debug == false) { + $query->where('isdebug', 0); + } + }) ->order('weigh', 'desc') ->cache("__menu__") ->select())->toArray(); $indexRuleList = \app\admin\model\AuthRule::where('status', 'normal') ->where('ismenu', 0) + ->where(function ($query) use ($debug) { + if ($debug == false) { + $query->where('isdebug', 0); + } + }) ->where('name', 'like', '%/index') ->column('name,pid'); $pidArr = array_filter(array_unique(array_map(function ($item) { diff --git a/application/admin/view/addon/index.html b/application/admin/view/addon/index.html index 770fdc2a481ba0c97b37cd4cc0f1b7efa5302177..c6348896383afbf3501283e5c89db1279130d009 100644 --- a/application/admin/view/addon/index.html +++ b/application/admin/view/addon/index.html @@ -79,10 +79,10 @@