123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace wechat\assets;
- use yii\web\AssetBundle;
- use Yii;
- use yii\helpers\ArrayHelper;
- /**
- * Main frontend application asset bundle.
- */
- class AppAsset extends AssetBundle
- {
- public $basePath = '@webroot';
- public $baseUrl = '@web';
- public $css = [
- 'css/public.css',
- 'js/alert/alert.css', /*公共弹窗样式*/
- //'css/public/font.css',
- ];
- public $js = [
- 'js/jquery-3.2.1.min.js',
- 'js/nav.js?v=11',
- 'js/signup/signup.js',
- 'js/applyVerify.js',
- // 'js/public.js',
- 'js/csrftoken.js',
- 'js/alert/alert.js', /*公共弹窗JS*/
- ];
- public $depends = [
- 'yii\web\YiiAsset',
- // 'yii\bootstrap\BootstrapAsset',
- ];
- public static function addScript($view, $jsfile) {
- $view->registerJsFile($jsfile.static::Clear(), [AppAsset::className(), "depends" => "wechat\assets\AppAsset"]);
- }
- public static function addCss($view, $jsfile)
- {
- $view->registerCssFile($jsfile.static::Clear(), [AppAsset::className(), "depends" => "wechat\assets\AppAsset"]);
- }
- public function registerAssetFiles($view)
- {
- $manager = $view->getAssetManager();
- foreach ($this->js as $js) {
- if (is_array($js)) {
- $file = array_shift($js);
- $options = ArrayHelper::merge($this->jsOptions, $js);
- $view->registerJsFile($manager->getAssetUrl($this, $file), $options);
- } else {
- if ($js !== null) {
- $view->registerJsFile($manager->getAssetUrl($this, $js.static::Clear()), $this->jsOptions);
- }
- }
- }
- foreach ($this->css as $css) {
- if (is_array($css)) {
- $file = array_shift($css);
- $options = ArrayHelper::merge($this->cssOptions, $css);
- $view->registerCssFile($manager->getAssetUrl($this, $file), $options);
- } else {
- if ($css !== null) {
- $view->registerCssFile($manager->getAssetUrl($this, $css.static::Clear()), $this->cssOptions);
- }
- }
- }
- }
- public static function Clear()
- {
- $cache = Yii::$app->cache;
- $name = Yii::$app->params['resourceCacheKey']['wechat'];
- $con = $cache->get($name);
- if($con != false)
- {
- return '?v='.$con;
- }
- else
- {
- return '?v=1111001s';
- }
- }
- }
|