Skip to content

Commit 27f014a

Browse files
authored
完善机制内的资源获取方式
1 parent 37a1363 commit 27f014a

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

Strategy/AdminStrategy.php

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class AdminStrategy extends AbstractController
2727
const menu_model_simple = 2;
2828

2929
/**
30+
* 资源基础url
31+
*
3032
* @var string
3133
*/
3234
private static $assetBaseUrl;
@@ -49,7 +51,7 @@ class AdminStrategy extends AbstractController
4951
/**
5052
* @var string 后台logo
5153
*/
52-
private static $logo;
54+
private static $logo = '/bundles/phpzlcadmin/images/logo.png';
5355

5456
/**
5557
* @var string 后台入口url
@@ -99,7 +101,7 @@ class AdminStrategy extends AbstractController
99101
/**
100102
* @var string 登陆页面背景图片
101103
*/
102-
private static $login_lack_ground_img;
104+
private static $login_lack_ground_im = '/bundles/phpzlcadmin/images/login_logo.png';
103105

104106
/**
105107
* @var Navigation[]
@@ -120,6 +122,7 @@ class AdminStrategy extends AbstractController
120122
public function __construct(ContainerInterface $container)
121123
{
122124
$this->setContainer($container);
125+
self::$assetBaseUrl = $this->getBaseUrl();
123126
}
124127

125128
public function setUrlAnchor()
@@ -179,15 +182,11 @@ public function setLogo($logo)
179182

180183
public function getLogo()
181184
{
182-
if(empty(static::$logo)){
183-
if(empty($this->getAssetBaseUrl())){
184-
return 'bundles/phpzlcadmin/images/logo.png';
185-
}else{
186-
return $this->getAssetBaseUrl() . '/bundles/phpzlcadmin/images/logo.png';
187-
}
185+
if(substr(static::$logo, 0, 4) == 'http'){
186+
return static::$logo;
187+
}else{
188+
return $this->getAssetBaseUrl() . static::$logo;
188189
}
189-
190-
return static::$logo;
191190
}
192191

193192
public function setEndUrl($end_url)
@@ -299,15 +298,11 @@ public function getAdminEnv()
299298
*/
300299
public function getLoginLackGroundImg(): string
301300
{
302-
if(empty(self::$login_lack_ground_img)){
303-
if(empty($this->getAssetBaseUrl())){
304-
return 'bundles/phpzlcadmin/images/login_logo.png';
305-
}else {
306-
return $this->getAssetBaseUrl() . '/bundles/phpzlcadmin/images/login_logo.png';
307-
}
301+
if(substr(static::$login_lack_ground_img, 0, 4) == 'http'){
302+
return static::$login_lack_ground_img;
303+
}else{
304+
return $this->getAssetBaseUrl() . static::$login_lack_ground_img;
308305
}
309-
310-
return self::$login_lack_ground_img;
311306
}
312307

313308
/**
@@ -445,4 +440,4 @@ public function setAdminAvatar(string $admin_avatar)
445440

446441
return $this;
447442
}
448-
}
443+
}

0 commit comments

Comments
 (0)