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