mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
增加后台入口设定
This commit is contained in:
parent
1cc1b50306
commit
ddf90f2b6d
@ -16,6 +16,7 @@
|
|||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
use think\admin\Controller;
|
use think\admin\Controller;
|
||||||
|
use think\admin\service\SystemService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统参数配置
|
* 系统参数配置
|
||||||
@ -83,10 +84,17 @@ class Config extends Controller
|
|||||||
$this->title = '修改系统参数';
|
$this->title = '修改系统参数';
|
||||||
$this->fetch();
|
$this->fetch();
|
||||||
} else {
|
} else {
|
||||||
foreach ($this->request->post() as $name => $value) {
|
if ($xpath = $this->request->post('xpath')) {
|
||||||
sysconf($name, $value);
|
if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]+$/', $xpath)) {
|
||||||
|
$this->error('后台入口名称需要是由英文字母开头!');
|
||||||
|
}
|
||||||
|
if ($xpath !== 'admin' && file_exists($this->app->getBasePath() . $xpath)) {
|
||||||
|
$this->error("后台入口名称{$xpath}已经存在应用!");
|
||||||
|
}
|
||||||
|
SystemService::instance()->setRuntime([$xpath => 'admin']);
|
||||||
}
|
}
|
||||||
$this->success('修改系统参数成功!');
|
foreach ($this->request->post() as $name => $value) sysconf($name, $value);
|
||||||
|
$this->success('修改系统参数成功!', sysuri("{$xpath}/index/index") . '#' . url("{$xpath}/config/index"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
};
|
};
|
||||||
this.getData = function (that, index) {
|
this.getData = function (that, index) {
|
||||||
index = $.msg.loading();
|
index = $.msg.loading();
|
||||||
$.form.load('{:url()}', {id: '{$vo.id}', action: 'get'}, 'post', function (ret) {
|
$.form.load('{:url("apply")}', {id: '{$vo.id}', action: 'get'}, 'post', function (ret) {
|
||||||
that.data = that.renderChildren(ret.data, 1);
|
that.data = that.renderChildren(ret.data, 1);
|
||||||
return $.msg.close(index), that.showTree(), false;
|
return $.msg.close(index), that.showTree(), false;
|
||||||
});
|
});
|
||||||
@ -54,7 +54,7 @@
|
|||||||
this.submit = function () {
|
this.submit = function () {
|
||||||
var nodes = [], data = this.ztree.getCheckedNodes(true);
|
var nodes = [], data = this.ztree.getCheckedNodes(true);
|
||||||
for (var i in data) if (data[i].node) nodes.push(data[i].node);
|
for (var i in data) if (data[i].node) nodes.push(data[i].node);
|
||||||
$.form.load('{:url()}', {id: '{$vo.id}', action: 'save', nodes: nodes}, 'post');
|
$.form.load('{:url("apply")}', {id: '{$vo.id}', action: 'save', nodes: nodes}, 'post');
|
||||||
};
|
};
|
||||||
// 刷新数据
|
// 刷新数据
|
||||||
this.getData(this);
|
this.getData(this);
|
||||||
|
@ -3,6 +3,16 @@
|
|||||||
<fieldset class="layui-form-item">
|
<fieldset class="layui-form-item">
|
||||||
<legend class="layui-bg-cyan">网站参数</legend>
|
<legend class="layui-bg-cyan">网站参数</legend>
|
||||||
<div class="layui-form-item padding-left-15 padding-right-15">
|
<div class="layui-form-item padding-left-15 padding-right-15">
|
||||||
|
<div class="layui-form-item">
|
||||||
|
<label class="relative block">
|
||||||
|
<span class="color-green font-w7">后台入口地址</span>
|
||||||
|
<span class="color-blue margin-left-5">{:sysuri('admin/index/index',[],false,true)}</span>
|
||||||
|
<span class="layui-input inline-block layui-clear">
|
||||||
|
<b class="pull-left">{:sysuri('@',[],false,true)}</b>
|
||||||
|
<input required pattern="[a-zA-Z_][a-zA-Z0-9_]+" placeholder="请完善后台入口地址" class="layui-input inline-block pull-left border-0" style="width:auto;background:none" value="{:trim(sysuri('admin/index/index'),'/')}" name="xpath">
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="relative block">
|
<label class="relative block">
|
||||||
<span class="color-green font-w7">浏览器图标</span>
|
<span class="color-green font-w7">浏览器图标</span>
|
||||||
|
8
composer.lock
generated
8
composer.lock
generated
@ -909,12 +909,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "b7d389ebc8fa2b14c652c1f42786bf1461c17799"
|
"reference": "047910e4b4c0d9af6759f823bc3e35364b3ecc54"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/b7d389ebc8fa2b14c652c1f42786bf1461c17799",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/047910e4b4c0d9af6759f823bc3e35364b3ecc54",
|
||||||
"reference": "b7d389ebc8fa2b14c652c1f42786bf1461c17799",
|
"reference": "047910e4b4c0d9af6759f823bc3e35364b3ecc54",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -958,7 +958,7 @@
|
|||||||
],
|
],
|
||||||
"description": "ThinkPHP v6.0 Development Library",
|
"description": "ThinkPHP v6.0 Development Library",
|
||||||
"homepage": "http://framework.thinkadmin.top",
|
"homepage": "http://framework.thinkadmin.top",
|
||||||
"time": "2020-04-16T05:51:49+00:00"
|
"time": "2020-04-16T06:29:58+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "zoujingli/wechat-developer",
|
"name": "zoujingli/wechat-developer",
|
||||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -935,12 +935,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||||
"reference": "b7d389ebc8fa2b14c652c1f42786bf1461c17799"
|
"reference": "047910e4b4c0d9af6759f823bc3e35364b3ecc54"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/b7d389ebc8fa2b14c652c1f42786bf1461c17799",
|
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/047910e4b4c0d9af6759f823bc3e35364b3ecc54",
|
||||||
"reference": "b7d389ebc8fa2b14c652c1f42786bf1461c17799",
|
"reference": "047910e4b4c0d9af6759f823bc3e35364b3ecc54",
|
||||||
"shasum": "",
|
"shasum": "",
|
||||||
"mirrors": [
|
"mirrors": [
|
||||||
{
|
{
|
||||||
@ -956,7 +956,7 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"topthink/framework": "^6.0"
|
"topthink/framework": "^6.0"
|
||||||
},
|
},
|
||||||
"time": "2020-04-16T05:51:49+00:00",
|
"time": "2020-04-16T06:29:58+00:00",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"think": {
|
"think": {
|
||||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
// This file is automatically generated at:2020-04-16 14:06:32
|
// This file is automatically generated at:2020-04-16 14:32:59
|
||||||
declare (strict_types = 1);
|
declare (strict_types = 1);
|
||||||
return array (
|
return array (
|
||||||
0 => 'think\\app\\Service',
|
0 => 'think\\app\\Service',
|
||||||
|
@ -204,13 +204,11 @@ class SystemService extends Service
|
|||||||
*/
|
*/
|
||||||
public function productMode($state = null)
|
public function productMode($state = null)
|
||||||
{
|
{
|
||||||
if (is_null($state)) {
|
if (is_string($state)) {
|
||||||
$this->app->debug($this->getRuntime('app_run') !== 'product');
|
|
||||||
} else {
|
|
||||||
$this->setRuntime([], $state ? 'product' : 'developoer');
|
$this->setRuntime([], $state ? 'product' : 'developoer');
|
||||||
$this->app->debug(empty($state));
|
return !$this->app->debug(empty($state))->isDebug();
|
||||||
}
|
}
|
||||||
return !$this->app->isDebug();
|
return !$this->app->debug($this->getRuntime('app_run') !== 'product')->isDebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,27 +219,16 @@ class SystemService extends Service
|
|||||||
*/
|
*/
|
||||||
public function setRuntime($map = [], $run = null)
|
public function setRuntime($map = [], $run = null)
|
||||||
{
|
{
|
||||||
$data = $this->__Runtime();
|
$data = $this->getRuntime();
|
||||||
|
if (is_array($map)) foreach ($data['app_map'] as $kk => $vv) foreach ($map as $oo) {
|
||||||
|
if ($oo === $vv) unset($data['app_map'][$kk]);
|
||||||
|
}
|
||||||
$file = "{$this->app->getRootPath()}runtime/config.json";
|
$file = "{$this->app->getRootPath()}runtime/config.json";
|
||||||
$data['app_run'] = is_null($run) ? $data['app_run'] : $run;
|
$data['app_run'] = is_null($run) ? $data['app_run'] : $run;
|
||||||
$data['app_map'] = is_null($map) ? [] : array_merge($data['app_map'], $map);
|
$data['app_map'] = is_null($map) ? [] : array_merge($data['app_map'], $map);
|
||||||
return file_put_contents($file, json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
|
return file_put_contents($file, json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 读取原数据
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function __Runtime()
|
|
||||||
{
|
|
||||||
$file = "{$this->app->getRootPath()}runtime/config.json";
|
|
||||||
$data = file_exists($file) ? json_decode(file_get_contents($file), true) : [];
|
|
||||||
if (empty($data) || !is_array($data)) $data = [];
|
|
||||||
if (empty($data['app_map']) || !is_array($data['app_map'])) $data['app_map'] = [];
|
|
||||||
if (empty($data['app_run']) || !is_string($data['app_run'])) $data['app_run'] = 'developer';
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取实时运行配置
|
* 获取实时运行配置
|
||||||
* @param null|string $key
|
* @param null|string $key
|
||||||
@ -249,7 +236,11 @@ class SystemService extends Service
|
|||||||
*/
|
*/
|
||||||
public function getRuntime($key = null)
|
public function getRuntime($key = null)
|
||||||
{
|
{
|
||||||
$data = $this->__Runtime();
|
$file = "{$this->app->getRootPath()}runtime/config.json";
|
||||||
|
$data = file_exists($file) ? json_decode(file_get_contents($file), true) : [];
|
||||||
|
if (empty($data) || !is_array($data)) $data = [];
|
||||||
|
if (empty($data['app_map']) || !is_array($data['app_map'])) $data['app_map'] = [];
|
||||||
|
if (empty($data['app_run']) || !is_string($data['app_run'])) $data['app_run'] = 'developer';
|
||||||
return is_null($key) ? $data : (isset($data[$key]) ? $data[$key] : null);
|
return is_null($key) ? $data : (isset($data[$key]) ? $data[$key] : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user