From 737ca424d0b90d7df46b13c153ffda223fa2bf0e Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Fri, 28 Aug 2020 20:30:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Tasks/MaintainTask.php | 111 ++- app/Http/Desktop/Views/partials/header.volt | 11 +- app/Providers/Annotation.php | 11 +- app/Providers/Cache.php | 18 +- app/Providers/Crypt.php | 14 +- app/Providers/Database.php | 22 +- app/Providers/MetaData.php | 21 +- app/Providers/Session.php | 18 +- app/Providers/Url.php | 16 +- app/Providers/Volt.php | 4 +- bootstrap/ConsoleKernel.php | 19 +- bootstrap/HttpKernel.php | 2 +- config/config.default.php | 33 +- .../20200827112717_insert_setting_data.php | 939 ++++++++---------- .../20200827113559_insert_user_data.php | 6 +- .../20200827120717_insert_nav_data.php | 158 ++- public/static/desktop/js/common.js | 10 +- public/static/desktop/js/fixbar.js | 2 +- 18 files changed, 802 insertions(+), 613 deletions(-) diff --git a/app/Console/Tasks/MaintainTask.php b/app/Console/Tasks/MaintainTask.php index ec641854..97ac7e1e 100644 --- a/app/Console/Tasks/MaintainTask.php +++ b/app/Console/Tasks/MaintainTask.php @@ -2,36 +2,127 @@ namespace App\Console\Tasks; +use App\Library\Cache\Backend\Redis as RedisCache; use Phalcon\Cli\Task; +use Phalcon\Config; class MaintainTask extends Task { public function mainAction() { - + $this->resetAnnotationAction(); + $this->resetMetadataAction(); + $this->resetVoltAction(); } - public function resetAnnotationsAction() + /** + * 重置注解 + * + * @command: php console.php maintain reset_annotation + */ + public function resetAnnotationAction() { - $dir = cache_path('annotations'); + $config = $this->getConfig(); + $cache = $this->getCache(); + $redis = $cache->getRedis(); + + $dbIndex = $config->path('annotation.db'); + $statsKey = $config->path('annotation.statsKey'); + + $redis->select($dbIndex); + + $keys = $redis->sMembers($statsKey); + + echo "start reset annotation..." . PHP_EOL; + + if (count($keys) > 0) { + + $keys = $this->handleKeys($keys); + + $redis->del(...$keys); + $redis->del($statsKey); + } + + echo "end reset annotation..." . PHP_EOL; + } + + /** + * 重置元数据 + * + * @command: php console.php maintain reset_metadata + */ + public function resetMetadataAction() + { + $config = $this->getConfig(); + $cache = $this->getCache(); + $redis = $cache->getRedis(); + + $dbIndex = $config->path('metadata.db'); + $statsKey = $config->path('metadata.statsKey'); + + $redis->select($dbIndex); + + $keys = $redis->sMembers($statsKey); + + echo "start reset metadata..." . PHP_EOL; + + if (count($keys) > 0) { + + $keys = $this->handleKeys($keys); + + $redis->del(...$keys); + $redis->del($statsKey); + } + + echo "start reset metadata..." . PHP_EOL; + } + + /** + * 重置模板 + * + * @command: php console.php maintain reset_volt + */ + public function resetVoltAction() + { + echo "start reset volt..." . PHP_EOL; + + $dir = cache_path('volt'); foreach (scandir($dir) as $file) { if (strpos($file, '.php')) { unlink($dir . '/' . $file); } } + + echo "end reset volt..." . PHP_EOL; } - public function resetModelsMetaDataAction() + protected function getConfig() { - $dir = cache_path('metadata'); + /** + * @var Config $config + */ + $config = $this->getDI()->get('config'); - foreach (scandir($dir) as $file) { - if (strpos($file, '.php')) { - unlink($dir . '/' . $file); - } - } + return $config; + } + + protected function getCache() + { + /** + * @var RedisCache $cache + */ + $cache = $this->getDI()->get('cache'); + + return $cache; + } + + protected function handleKeys($keys) + { + return array_map(function ($key) { + return "_PHCR{$key}"; + }, $keys); } } diff --git a/app/Http/Desktop/Views/partials/header.volt b/app/Http/Desktop/Views/partials/header.volt index bf694e0b..2f65030e 100644 --- a/app/Http/Desktop/Views/partials/header.volt +++ b/app/Http/Desktop/Views/partials/header.volt @@ -4,11 +4,11 @@