mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
ComposerUpdate
This commit is contained in:
parent
c79ce279ca
commit
49b9255dcc
8
composer.lock
generated
8
composer.lock
generated
@ -879,12 +879,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "0a8548f0b1814130840210695a9febc3766d0803"
|
||||
"reference": "568ab719724c389c6b2a41d3fe4a2c5a82286d21"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/0a8548f0b1814130840210695a9febc3766d0803",
|
||||
"reference": "0a8548f0b1814130840210695a9febc3766d0803",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/568ab719724c389c6b2a41d3fe4a2c5a82286d21",
|
||||
"reference": "568ab719724c389c6b2a41d3fe4a2c5a82286d21",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -928,7 +928,7 @@
|
||||
],
|
||||
"description": "ThinkPHP v6.0 Development Library",
|
||||
"homepage": "http://thinkadmin.top",
|
||||
"time": "2020-07-31T08:20:24+00:00"
|
||||
"time": "2020-07-31T09:06:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "zoujingli/wechat-developer",
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -903,12 +903,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "0a8548f0b1814130840210695a9febc3766d0803"
|
||||
"reference": "568ab719724c389c6b2a41d3fe4a2c5a82286d21"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/0a8548f0b1814130840210695a9febc3766d0803",
|
||||
"reference": "0a8548f0b1814130840210695a9febc3766d0803",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/568ab719724c389c6b2a41d3fe4a2c5a82286d21",
|
||||
"reference": "568ab719724c389c6b2a41d3fe4a2c5a82286d21",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -924,7 +924,7 @@
|
||||
"ext-json": "*",
|
||||
"topthink/framework": "^6.0"
|
||||
},
|
||||
"time": "2020-07-31T08:20:24+00:00",
|
||||
"time": "2020-07-31T09:06:14+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"think": {
|
||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// This file is automatically generated at:2020-07-31 16:24:00
|
||||
// This file is automatically generated at:2020-07-31 17:13:29
|
||||
declare (strict_types = 1);
|
||||
return array (
|
||||
0 => 'think\\admin\\Library',
|
||||
|
@ -141,10 +141,8 @@ class SystemService extends Service
|
||||
*/
|
||||
public function sysuri($url = '', array $vars = [], $suffix = true, $domain = false)
|
||||
{
|
||||
$d1 = $this->app->config->get('app.default_app');
|
||||
$d3 = $this->app->config->get('route.default_action');
|
||||
$d2 = $this->app->config->get('route.default_controller');
|
||||
$location = $this->app->route->buildUrl($url, $vars)->suffix($suffix)->domain($domain)->build();
|
||||
[$d1, $d2, $d3] = [$this->app->config->get('app.default_app'), $this->app->config->get('route.default_controller'), $this->app->config->get('route.default_action')];
|
||||
return preg_replace('|/\.html$|', '', preg_replace(["|^/{$d1}/{$d2}/{$d3}(\.html)?$|i", "|/{$d2}/{$d3}(\.html)?$|i", "|/{$d3}(\.html)?$|i"], ['$1', '$1', '$1'], $location));
|
||||
}
|
||||
|
||||
@ -174,7 +172,7 @@ class SystemService extends Service
|
||||
try {
|
||||
$value = $this->app->db->name('SystemData')->where(['name' => $name])->value('value', null);
|
||||
return is_null($value) ? $default : unserialize($value);
|
||||
} catch (\Exception $e) {
|
||||
} catch (\Exception $exception) {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
@ -247,6 +245,25 @@ class SystemService extends Service
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实时运行配置
|
||||
* @param string $key
|
||||
* @param array $default
|
||||
* @return array
|
||||
*/
|
||||
public function getRuntime($key = null, $default = [])
|
||||
{
|
||||
$filename = "{$this->app->getRootPath()}runtime/config.json";
|
||||
if (file_exists($filename) && is_file($filename)) {
|
||||
$data = json_decode(file_get_contents($filename), 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] ?? $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置实时运行配置
|
||||
* @param array|null $map 应用映射
|
||||
@ -258,33 +275,13 @@ class SystemService extends Service
|
||||
{
|
||||
$data = $this->getRuntime();
|
||||
$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));
|
||||
$data['map'] = $this->uniqueArray($data['map'], $map);
|
||||
$data['uri'] = $this->uniqueArray($data['uri'], $uri);
|
||||
$filename = "{$this->app->getRootPath()}runtime/config.json";
|
||||
file_put_contents($filename, json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
return $this->bindRuntime($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实时运行配置
|
||||
* @param string $key
|
||||
* @param array $default
|
||||
* @return array
|
||||
*/
|
||||
public function getRuntime($key = null, $default = [])
|
||||
{
|
||||
$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] ?? $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定应用实时配置
|
||||
* @param array $data 配置数据
|
||||
@ -297,16 +294,28 @@ class SystemService extends Service
|
||||
// 动态设置应用绑定
|
||||
$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'])));
|
||||
$config['app_map'] = $this->uniqueArray($this->app->config->get('app.app_map', []), $data['map']);
|
||||
}
|
||||
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'])));
|
||||
$config['domain_bind'] = $this->uniqueArray($this->app->config->get('app.domain_bind', []), $data['uri']);
|
||||
}
|
||||
// 动态设置运行模式
|
||||
$this->app->config->set($config, 'app');
|
||||
return $this->app->debug($data['run'] !== 'product')->isDebug();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取唯一数组参数
|
||||
* @param array ...$args
|
||||
* @return array
|
||||
*/
|
||||
private function uniqueArray(...$args): array
|
||||
{
|
||||
$unique = array_unique(array_reverse(array_merge(...$args)));
|
||||
foreach ($unique as $kk => $vv) if ($kk == $vv) unset($unique[$kk]);
|
||||
return $unique;
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩发布项目
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user