From 0e4e75a550464bee1c64d49fab3ae73b3dc4c8a3 Mon Sep 17 00:00:00 2001 From: Lkeme <19500576+lkeme@users.noreply.github.com> Date: Mon, 22 Aug 2022 10:07:10 +0800 Subject: [PATCH] [fix] Linux case sencitive --- README.md | 2 +- src/Core/Core.php | 106 +++++++++++++++++++++++++++++++++++++ src/Util/Qrcode/Qrcode.php | 4 +- 3 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 src/Core/Core.php diff --git a/README.md b/README.md index 6a2a22a..51adccf 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ 有疑问一定要先看看文档或Issue里是否存在相同的问题,再考虑其他渠道咨询。 -* [使用文档 / DOC.md](./dosc/DOC.md) +* [使用文档 / DOC.md](./docs/DOC.md) * [推送文档 / NOTIFY.md](./docs/NOTIFY.md) * [更新日志 / CHANGELOG.md](./docs/CHANGELOG.md) * [配置文档 / WIKI.md](https://github.com/lkeme/BiliHelper-personal/wiki/%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%AF%A6%E8%A7%A3) diff --git a/src/Core/Core.php b/src/Core/Core.php new file mode 100644 index 0000000..a6ce109 --- /dev/null +++ b/src/Core/Core.php @@ -0,0 +1,106 @@ +global_path = $global_path; + $this->profile_name = $profile_name; + // 定义全局常量 + $this->initSystemConstant(); + // 初始化全局文件夹 + $this->initSystemPath(); + } + + /** + * 初始化全局常量 + * @return void + */ + protected function initSystemConstant(): void + { + define('APP_MICROSECOND', 1000000); + define('APP_RESOURCES_PATH', $this->global_path . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR); + define('APP_PLUGIN_PATH', $this->global_path . DIRECTORY_SEPARATOR . 'plugin' . DIRECTORY_SEPARATOR); + // Profile + define('PROFILE_CONFIG_PATH', $this->fillPath('config')); + define('PROFILE_DEVICE_PATH', $this->fillPath('device')); + define('PROFILE_LOG_PATH', $this->fillPath('log')); + define('PROFILE_TASK_PATH', $this->fillPath('task')); + define('PROFILE_CACHE_PATH', $this->fillPath('cache')); + + // 判断profile/*是否存在存在 + if (!is_dir(PROFILE_CONFIG_PATH)) { + die("加载 {$this->profile_name} 用户文档失败,请检查路径!"); + } + } + + /** + * 补充目录 + * @param string $path + * @return string + */ + protected function fillPath(string $path): string + { + // */profile/*/* + return $this->global_path . DIRECTORY_SEPARATOR . 'profile' . DIRECTORY_SEPARATOR . $this->profile_name . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR; + } + + /** + * 初始化系统目录(创建、设置权限) + * @return void + */ + protected function initSystemPath(): void + { + $system_paths = [ + PROFILE_CONFIG_PATH, + PROFILE_DEVICE_PATH, + PROFILE_LOG_PATH, + PROFILE_TASK_PATH, + PROFILE_CACHE_PATH + ]; + foreach ($system_paths as $path) { + if (!file_exists($path)) { + Path::CreateFolder($path); + Path::SetFolderPermissions($path); + } + } + } + + +} \ No newline at end of file diff --git a/src/Util/Qrcode/Qrcode.php b/src/Util/Qrcode/Qrcode.php index efacc3d..4999c4e 100644 --- a/src/Util/Qrcode/Qrcode.php +++ b/src/Util/Qrcode/Qrcode.php @@ -17,7 +17,7 @@ namespace Bhp\Util\Qrcode; -use Bhp\Util\Qrcode\Lib\Qrcode as QrConsole; +use Bhp\Util\Qrcode\Lib\QrCode as QrConsole; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; @@ -85,4 +85,4 @@ class Qrcode $style = new OutputFormatterStyle('white', 'white', ['bold']); $output->getFormatter()->setStyle('whitec', $style); } -} \ No newline at end of file +}