12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace app\assets;
- use app\modules\admin\models\Config;
- use yii\web\AssetBundle;
- use Yii;
- class PcAsset extends AssetBundle
- {
- //资源文件的源文件位置
- public $sourcePath;
- //当前事例引入的文件
- public $css = [
- ];
- public $js = [
- ];
- //没有依赖
- public $depends = [
- ];
- public function init()
- {
- parent::init();
- $baseconfigResult = Config::find()->where("name='baseconfig'")->one();
- $baseconfig = string2array($baseconfigResult->value);
- if(!empty($baseconfig['style']))
- {
- $this->sourcePath = Yii::$app->params['themePath'].$baseconfig['theme'].'/pc/assets/'.$baseconfig['style'];
- }
- else
- {
- $this->sourcePath = Yii::$app->params['themePath'].$baseconfig['theme'].'/pc/assets';
- }
- }
- static function getInitCls()
- {
- static $initCls = NULL;
- if(!isset($initCls)) $initCls = new PcAsset();
- return $initCls;
- }
- }
|