ComposerUpdate

This commit is contained in:
Anyon 2020-07-31 16:24:15 +08:00
parent 96f54f8d5e
commit c79ce279ca
11 changed files with 56 additions and 77 deletions

View File

@ -2,7 +2,7 @@
<div class="layui-card-body padding-left-40">
<div class="layui-form-item">
<span class="color-green font-w7 label-required-prev">后台登录入口</span>
<span class="color-desc margin-left-5">login</span>
<span class="color-desc margin-left-5">Login</span>
<label class="layui-input relative block label-required-null">
<span>{:sysuri('@',[],false,true)}</span>
<input autofocus required pattern="[a-zA-Z_][a-zA-Z0-9_]+" placeholder="请输入后台登录入口" class="layui-input inline-block padding-0 border-0" style="width:auto;background:none" value="{:trim(sysuri('admin/index/index',[],false),'/')}" name="xpath">
@ -13,7 +13,7 @@
<span class="color-green font-w7">浏览器小图标</span>
<span class="color-desc margin-left-5">Icon</span>
<input class="layui-input" required pattern="^http" placeholder="请上传浏览器图标  " value="{:sysconf('site_icon')}" name="site_icon">
<a class="input-right-icon layui-icon layui-icon-upload-circle" style="top:25px" data-file="btn" data-type="ico,png" data-field="site_icon"></a>
<a class="input-right-icon layui-icon layui-icon-upload-drag" style="top:25px" data-file="btn" data-type="ico,png" data-field="site_icon"></a>
<span class="help-block">建议上传 <span class="color-blue">128x128</span> ico png 图片,可以通过 <a href="http://www.favicon-icon-generator.com" target="_blank">ICON </a>在线制作 ico 文件!</span>
</label>
<div class="layui-form-item layui-row layui-col-space15">

10
composer.lock generated
View File

@ -879,12 +879,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "54dfd26bd7de6bb86d233f4bb03b80d3b475ce7f"
"reference": "0a8548f0b1814130840210695a9febc3766d0803"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/54dfd26bd7de6bb86d233f4bb03b80d3b475ce7f",
"reference": "54dfd26bd7de6bb86d233f4bb03b80d3b475ce7f",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/0a8548f0b1814130840210695a9febc3766d0803",
"reference": "0a8548f0b1814130840210695a9febc3766d0803",
"shasum": "",
"mirrors": [
{
@ -927,8 +927,8 @@
}
],
"description": "ThinkPHP v6.0 Development Library",
"homepage": "http://framework.thinkadmin.top",
"time": "2020-07-30T10:54:48+00:00"
"homepage": "http://thinkadmin.top",
"time": "2020-07-31T08:20:24+00:00"
},
{
"name": "zoujingli/wechat-developer",

View File

@ -903,12 +903,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "54dfd26bd7de6bb86d233f4bb03b80d3b475ce7f"
"reference": "0a8548f0b1814130840210695a9febc3766d0803"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/54dfd26bd7de6bb86d233f4bb03b80d3b475ce7f",
"reference": "54dfd26bd7de6bb86d233f4bb03b80d3b475ce7f",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/0a8548f0b1814130840210695a9febc3766d0803",
"reference": "0a8548f0b1814130840210695a9febc3766d0803",
"shasum": "",
"mirrors": [
{
@ -924,7 +924,7 @@
"ext-json": "*",
"topthink/framework": "^6.0"
},
"time": "2020-07-30T10:54:48+00:00",
"time": "2020-07-31T08:20:24+00:00",
"type": "library",
"extra": {
"think": {
@ -953,7 +953,7 @@
}
],
"description": "ThinkPHP v6.0 Development Library",
"homepage": "http://framework.thinkadmin.top"
"homepage": "http://thinkadmin.top"
},
{
"name": "zoujingli/wechat-developer",

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2020-07-30 19:00:19
// This file is automatically generated at:2020-07-31 16:24:00
declare (strict_types = 1);
return array (
0 => 'think\\admin\\Library',

View File

@ -2,7 +2,7 @@
"type": "library",
"name": "zoujingli/think-library",
"license": "MIT",
"homepage": "http://framework.thinkadmin.top",
"homepage": "http://thinkadmin.top",
"description": "ThinkPHP v6.0 Development Library",
"authors": [
{

View File

@ -53,7 +53,7 @@ class Library extends Service
$this->commands(['build' => Build::class, 'clear' => Clear::class]);
// 注册 ThinkAdmin 指令
$this->commands([Queue::class, Install::class, Version::class, Database::class]);
// 动态应用配置参数
// 动态应用运行参数
SystemService::instance()->bindRuntime();
}

View File

@ -15,9 +15,7 @@
namespace think\admin;
use think\admin\storage\AliossStorage;
use think\admin\storage\LocalStorage;
use think\admin\storage\QiniuStorage;
use think\App;
use think\Container;
@ -57,25 +55,22 @@ abstract class Storage
/**
* Storage constructor.
* @param App $app
*/
public function __construct(App $app)
{
$this->app = $app;
}
/**
* 存储初始化
* @return static
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
protected function initialize()
public function __construct(App $app)
{
$this->app = $app;
$this->linkType = sysconf('storage.link_type');
return $this;
$this->initialize();
}
/**
* 存储驱动初始化
*/
abstract protected function initialize();
/**
* 静态访问启用
* @param string $method 方法名称
@ -106,9 +101,9 @@ abstract class Storage
*/
public static function instance($name = null)
{
$class = ucfirst(strtolower(is_null($name) ? sysconf('storage.type') : $name));
$class = ucfirst(strtolower($name ?: sysconf('storage.type')));
if (class_exists($object = "think\\admin\\storage\\{$class}Storage")) {
return Container::getInstance()->make($object)->initialize();
return Container::getInstance()->make($object);
} else {
throw new Exception("File driver [{$class}] does not exist.");
}

View File

@ -213,7 +213,7 @@ class SystemService extends Service
* @param string $type 运行模式dev|demo|local
* @return boolean
*/
public function checkRunMode($type = 'dev')
public function checkRunMode($type = 'dev'): bool
{
$domain = $this->app->request->host(true);
$isDemo = is_numeric(stripos($domain, 'thinkadmin.top'));
@ -228,7 +228,7 @@ class SystemService extends Service
* 判断实时运行模式
* @return boolean
*/
public function isDebug()
public function isDebug(): bool
{
return $this->getRuntime('run') !== 'product';
}
@ -238,7 +238,7 @@ class SystemService extends Service
* @param null|boolean $state
* @return boolean
*/
public function productMode($state = null)
public function productMode($state = null): bool
{
if (is_null($state)) {
return $this->bindRuntime();
@ -254,37 +254,35 @@ class SystemService extends Service
* @param array|null $uri 域名映射
* @return boolean 是否调试模式
*/
public function setRuntime($map = [], $run = null, $uri = [])
public function setRuntime(array $map = [], $run = null, array $uri = []): bool
{
$data = $this->getRuntime();
if (is_array($map) && count($map) > 0 && count($data['map']) > 0) {
foreach ($data['map'] as $kk => $vv) if (in_array($vv, $map)) unset($data['map'][$kk]);
}
if (is_array($uri) && count($uri) > 0 && count($data['uri']) > 0) {
foreach ($data['uri'] as $kk => $vv) if (in_array($vv, $uri)) unset($data['uri'][$kk]);
}
$file = "{$this->app->getRootPath()}runtime/config.json";
$data['run'] = is_null($run) ? $data['run'] : $run;
$data['map'] = is_null($map) ? [] : array_merge($data['map'], $map);
$data['uri'] = is_null($uri) ? [] : array_merge($data['uri'], $uri);
file_put_contents($file, json_encode($data, JSON_UNESCAPED_UNICODE));
$data['run'] = is_string($run) ? $run : $data['run'];
$data['map'] = array_unique(array_reverse(array_merge($data['map'], $map)));
$data['uri'] = array_unique(array_reverse(array_merge($data['uri'], $uri)));
foreach ($data['map'] as $kk => $vv) if ($kk === $vv) unset($data['map'][$kk]);
foreach ($data['uri'] as $kk => $vv) if ($kk === $vv) unset($data['uri'][$kk]);
file_put_contents("{$this->app->getRootPath()}runtime/config.json", json_encode($data, JSON_UNESCAPED_UNICODE));
return $this->bindRuntime($data);
}
/**
* 获取实时运行配置
* @param null|string $key
* @param string $key
* @param array $default
* @return array
*/
public function getRuntime($key = null)
public function getRuntime($key = null, $default = [])
{
$file = "{$this->app->getRootPath()}runtime/config.json";
$data = file_exists($file) ? json_decode(file_get_contents($file), true) : [];
$jsonfile = "{$this->app->getRootPath()}runtime/config.json";
if (file_exists($jsonfile) && is_file($jsonfile)) {
$data = json_decode(file_get_contents($jsonfile), true);
}
if (empty($data) || !is_array($data)) $data = [];
if (empty($data['map']) || !is_array($data['map'])) $data['map'] = [];
if (empty($data['uri']) || !is_array($data['uri'])) $data['uri'] = [];
if (empty($data['run']) || !is_string($data['run'])) $data['run'] = 'developer';
return is_null($key) ? $data : ($data[$key] ?? null);
return is_null($key) ? $data : ($data[$key] ?? $default);
}
/**
@ -292,33 +290,27 @@ class SystemService extends Service
* @param array $data 配置数据
* @return boolean 是否调试模式
*/
public function bindRuntime($data = [])
public function bindRuntime($data = []): bool
{
// 获取运行配置
if (empty($data)) $data = $this->getRuntime();
// 动态设置应用绑定
if (!empty($data['map'])) {
$maps = $this->app->config->get('app.app_map', []);
if (is_array($maps) && count($maps) > 0 && count($data['map']) > 0) {
foreach ($maps as $kk => $vv) if (in_array($vv, $data['map'])) unset($maps[$kk]);
}
$this->app->config->set(['app_map' => array_merge($maps, $data['map'])], 'app');
$config = ['app_map' => [], 'domain_bind' => []];
if (isset($data['map']) && is_array($data['map']) && count($data['map']) > 0) {
$config['app_map'] = array_unique(array_reverse(array_merge($this->app->config->get('app.app_map', []), $data['map'])));
}
// 动态设置域名绑定
if (!empty($data['uri'])) {
$uris = $this->app->config->get('app.domain_bind', []);
if (is_array($uris) && count($uris) > 0 && count($data['uri']) > 0) {
foreach ($uris as $kk => $vv) if (in_array($vv, $data['uri'])) unset($uris[$kk]);
}
$this->app->config->set(['domain_bind' => array_merge($uris, $data['uri'])], 'app');
if (isset($data['uri']) && is_array($data['uri']) && count($data['uri']) > 0) {
$config['domain_bind'] = array_unique(array_reverse(array_merge($this->app->config->get('app.domain_bind', []), $data['uri'])));
}
// 动态设置运行模式
$this->app->config->set($config, 'app');
return $this->app->debug($data['run'] !== 'product')->isDebug();
}
/**
* 压缩发布项目
*/
public function pushRuntime()
public function pushRuntime(): void
{
$type = $this->app->db->getConfig('default');
$this->app->console->call("optimize:schema", ["--connection={$type}"]);
@ -332,7 +324,7 @@ class SystemService extends Service
/**
* 清理运行缓存
*/
public function clearRuntime()
public function clearRuntime(): void
{
$data = $this->getRuntime();
$this->app->console->call('clear');
@ -343,7 +335,7 @@ class SystemService extends Service
* 初始化并运行应用
* @param \think\App $app
*/
public function doInit(\think\App $app)
public function doInit(\think\App $app): void
{
$app->debug($this->isDebug());
$response = $app->http->run();

View File

@ -38,20 +38,19 @@ class AliossStorage extends Storage
private $bucket;
/**
* AccessKeyId
* AccessId
* @var string
*/
private $accessKey;
/**
* AccessKeySecret
* AccessSecret
* @var string
*/
private $secretKey;
/**
* 初始化入口
* @return static
* @throws \think\admin\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
@ -71,8 +70,6 @@ class AliossStorage extends Storage
elseif ($type === 'http') $this->prefix = "http://{$domain}";
elseif ($type === 'https') $this->prefix = "https://{$domain}";
else throw new \think\admin\Exception('未配置阿里云URL域名哦');
// 初始化配置并返回当前实例
return parent::initialize();
}
/**

View File

@ -27,7 +27,6 @@ class LocalStorage extends Storage
/**
* 初始化入口
* @return static
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
@ -43,7 +42,6 @@ class LocalStorage extends Storage
elseif ($type === 'http') $this->prefix = "http://{$domain}";
elseif ($type === 'https') $this->prefix = "https://{$domain}";
}
return parent::initialize();
}
/**

View File

@ -31,7 +31,6 @@ class QiniuStorage extends Storage
/**
* 初始化入口
* @return static
* @throws \think\admin\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
@ -50,8 +49,6 @@ class QiniuStorage extends Storage
elseif ($type === 'http') $this->prefix = "http://{$domain}";
elseif ($type === 'https') $this->prefix = "https://{$domain}";
else throw new \think\admin\Exception('未配置七牛云URL域名哦');
// 初始化配置并返回当前实例
return parent::initialize();
}
/**