Allow to use relative path at PLUGINS_DIR

This commit is contained in:
Pig Fang 2019-07-01 21:25:25 +08:00
parent e811d1afc3
commit 00d7d5481e
3 changed files with 8 additions and 1 deletions

View File

@ -68,6 +68,9 @@ class PluginManager
$installed = []; $installed = [];
$cwd = getcwd();
chdir(base_path());
try { try {
$resource = opendir($this->getPluginsDir()); $resource = opendir($this->getPluginsDir());
} catch (\Exception $e) { } catch (\Exception $e) {
@ -125,6 +128,8 @@ class PluginManager
$this->plugins = $plugins->sortBy(function ($plugin, $name) { $this->plugins = $plugins->sortBy(function ($plugin, $name) {
return $plugin->name; return $plugin->name;
}); });
chdir($cwd);
} }
return $this->plugins; return $this->plugins;
@ -400,7 +405,7 @@ class PluginManager
*/ */
public function getPluginsDir() public function getPluginsDir()
{ {
return config('plugins.directory') ?: base_path('plugins'); return config('plugins.directory') ? realpath(config('plugins.directory')) : base_path('plugins');
} }
/** /**

View File

@ -3,6 +3,7 @@
- Supported Chrome's `theme-color`. - Supported Chrome's `theme-color`.
- Allowed to customize HTTP status code for rejecting accessing private texture. - Allowed to customize HTTP status code for rejecting accessing private texture.
- Added configurable "Explore" menu. - Added configurable "Explore" menu.
- Custom `PLUGINS_DIR` with relative path is allowed.
## Tweaked ## Tweaked

View File

@ -3,6 +3,7 @@
- 支持 Chrome 的 `theme-color` 属性 - 支持 Chrome 的 `theme-color` 属性
- 允许自定义拒绝访问私有材质时返回的 HTTP 状态码 - 允许自定义拒绝访问私有材质时返回的 HTTP 状态码
- 添加可自定义的「浏览」菜单 - 添加可自定义的「浏览」菜单
- 允许在 `PLUGINS_DIR` 配置项中使用相对路径
## 调整 ## 调整