VENOM-2 : WIP
This commit is contained in:
parent
c7984873c0
commit
a2931d93f7
9 changed files with 311 additions and 37 deletions
|
|
@ -5,8 +5,11 @@ namespace Venom\Admin;
|
|||
|
||||
|
||||
use Venom\Helper\URLHelper;
|
||||
use Venom\Views\Asset;
|
||||
use Venom\Views\RenderController;
|
||||
use Venom\Views\VenomRenderer;
|
||||
use Venom\Models\User;
|
||||
use \Venom\Security\Security;
|
||||
|
||||
class AdminController implements RenderController
|
||||
|
||||
|
|
@ -25,6 +28,15 @@ class AdminController implements RenderController
|
|||
http_response_code(404);
|
||||
$this->tpl = 'async';
|
||||
}
|
||||
|
||||
$isLogin = Security::get()->hasRole(User::ADMIN_ROLE);
|
||||
$renderer->addVar('isLoggedIn', $isLogin);
|
||||
if (!$isLogin) {
|
||||
Asset::get()->addCSS('login','login.css');
|
||||
}
|
||||
Asset::get()->addCSS('styles','style.css', 1);
|
||||
Asset::get()->addJS('scripts', 'scripts.min.js', 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class Asset
|
|||
usort($this->jsFiles, function ($a, $b) {
|
||||
return $a['pos'] <=> $b['pos'];
|
||||
});
|
||||
$theme = $this->getPath('/theme/' . Config::getInstance()->getRenderer()->assetDir . '/js/');
|
||||
$theme = $this->getPath('/js/');
|
||||
foreach ($this->jsFiles as $key => $file) {
|
||||
echo '<script src="' . $theme . $file['file'] . '" id="js-' . $key . '"></script>';
|
||||
}
|
||||
|
|
@ -70,7 +70,8 @@ class Asset
|
|||
|
||||
private function getPath($base): string
|
||||
{
|
||||
$preDir = $base;
|
||||
$dir = Config::getInstance()->isAdmin() ? 'admin' : Config::getInstance()->getRenderer()->assetDir;
|
||||
$preDir = '/theme/' . $dir . $base;
|
||||
$config = Config::getInstance();
|
||||
$baseUrl = Config::getInstance()->getBaseUrl();
|
||||
if ($baseUrl !== '' && $config->getRenderer()->useStaticUrl) {
|
||||
|
|
@ -84,7 +85,7 @@ class Asset
|
|||
usort($this->cssFiles, function ($a, $b) {
|
||||
return $a['pos'] <=> $b['pos'];
|
||||
});
|
||||
$theme = $this->getPath('/theme/' . Config::getInstance()->getRenderer()->assetDir . '/css/');
|
||||
$theme = $this->getPath('/css/');
|
||||
foreach ($this->cssFiles as $key => $file) {
|
||||
echo '<link rel="stylesheet" href="' . $theme . $file['file'] . '" id="css-' . $key . '">';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue