[fix] Linux case sencitive

This commit is contained in:
Lkeme 2022-08-22 10:07:10 +08:00
parent 7fd6f95d13
commit 0e4e75a550
3 changed files with 109 additions and 3 deletions

View File

@ -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)

106
src/Core/Core.php Normal file
View File

@ -0,0 +1,106 @@
<?php declare(strict_types=1);
/**
* Website: https://mudew.com/
* Author: Lkeme
* License: The MIT License
* Email: Useri@live.cn
* Updated: 2022 ~ 2023
*
* _____ _ _ _ _ _ _____ _ _____ _____ _____
* | _ \ | | | | | | | | | | | ____| | | | _ \ | ____| | _ \ & l、
* | |_| | | | | | | | | |_| | | |__ | | | |_| | | |__ | |_| | (゚、
* | _ { | | | | | | | _ | | __| | | | ___/ | __| | _ /   \、゙ ~ *
* | |_| | | | | |___ | | | | | | | |___ | |___ | | | |___ | | \ \  じしf_, )
* |_____/ |_| |_____| |_| |_| |_| |_____| |_____| |_| |_____| |_| \_\
*/
namespace Bhp\Core;
use Bhp\Console\Console;
use Bhp\Util\DesignPattern\SingleTon;
use Bhp\Util\Os\Path;
class Core extends SingleTon
{
/**
* @var string
*/
protected string $global_path;
/**
* @var string
*/
protected string $profile_name;
/**
* @param string $global_path
* @param string $profile_name
* @return void
*/
public function init(string $global_path, string $profile_name): void
{
$this->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);
}
}
}
}

View File

@ -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);
}
}
}