diff --git a/README.md b/README.md index 263a42e..babd884 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,32 @@ docker exec -it machete /var/www/machete/bin/upgrade.sh ``` +### 配置修改 + +修改配置有两种方式: +1. 进入容器目录:/var/www/machete/runtime/,修改**custom_config.json**后保存即可; +2. 命令行修改 +``` +docker exec -it machete php /var/www/machete/bin/command.php config "do=set&key=screenshot_start&val=1000" +``` + +上述命令为修改配置项**screenshot_start**的示例。 + +配置读取、修改、删除命令: +``` +php /var/www/machete/bin/command.php config "参数" +``` + +参数说明: +* do - 操作,可选值:get, all, set, del(分别对应获取单个配置项、所有配置项、设置单个配置项、删除单个配置项) +* key - 配置项名称 +* val - 配置项值 + + +说明: +不支持数组类型的配置修改,可用配置项明细参考:**conf/app.php**。 + + ## 后台管理内容 最新版本已经支持网页版后台和samba文件共享方式管理内容。 diff --git a/bin/upgrade.sh b/bin/upgrade.sh index 243c58a..bc1ff72 100755 --- a/bin/upgrade.sh +++ b/bin/upgrade.sh @@ -66,6 +66,9 @@ if [ -f "master.tar.gz" ]; then fi +echo "Machete front-end upgraded." +echo "" + # upgrade admin cd /var/www/downloads/ @@ -79,6 +82,16 @@ if [ -f "master.tar.gz" ]; then mv jialuomaadmin/dist/ /var/www/machete/www/admin fi +echo "Admin system upgraded." +echo "" + -echo "Machete upgrade done." +# upgrade nginx config +cp /var/www/machete/conf/nginx_machete.conf /etc/nginx/http.d/machete.conf +/usr/sbin/nginx -s reload +echo "Nginx config upgraded and reloaded." +echo "" + +echo "" +echo "==Machete upgrade done.==" echo "" diff --git a/conf/app.php b/conf/app.php index f43b130..8cd7b86 100644 --- a/conf/app.php +++ b/conf/app.php @@ -51,6 +51,7 @@ $configs = array( 'supportedImageExts' => array('jpg', 'jpeg', 'png', 'webp', 'gif'), 'supportedVideoExts' => array('mp4', 'mov', 'm3u8'), + 'screenshot_start' => 8000, //视频播放页快照截取开始时间,单位:毫秒 /* //视频皮肤配置 diff --git a/conf/nginx_machete.conf b/conf/nginx_machete.conf index f644f36..7737925 100644 --- a/conf/nginx_machete.conf +++ b/conf/nginx_machete.conf @@ -11,7 +11,12 @@ server { root /var/www/machete/www; index index.php index.html; - location ~ .*\.(gif|jpg|jpeg|png|webp|bmp|swf|js|css|ico|mp4|ts)$ { + location ~ /.*/([^\/]*\.(gif|jpg|jpeg|png|webp|bmp|swf|js|css|ico|mp4|ts))$ { + # support file download + if ($arg_download) { + add_header Content-disposition "attachment; filename=$1"; + } + expires 30d; } diff --git a/controller/CommandController.php b/controller/CommandController.php index 293d1d3..4f3810b 100644 --- a/controller/CommandController.php +++ b/controller/CommandController.php @@ -18,6 +18,72 @@ eof; exit; } + public function actionConfig() { + $themeName = FSC::$app['config']['theme']; + + $code = 1; + $data = ''; + + //修改配置文件 + $param_do = $this->get('do', 'set'); //支持:set, get, all, del + $param_key = $this->get('key', ''); + $param_value = $this->get('val', ''); + + if ($param_do == 'set' && empty($param_value)) { + throw new Exception("缺少val参数!", 403); + }else if (in_array($param_do, array('set', 'get', 'del')) && empty($param_key)) { + throw new Exception("缺少key参数!", 403); + } + + + $config_file = __DIR__ . "/../runtime/custom_config.json"; + if (file_exists($config_file)) { + $content = file_get_contents($config_file); + $configs = @json_decode($content, true); + if (empty($configs)) { + $config_file_template = __DIR__ . "/../conf/custom_config_{$themeName}.json"; + $content = file_get_contents($config_file_template); + $configs = @json_decode($content, true); + } + } + + if (!empty($configs)) { + switch($param_do) { + case 'set': + $configs[$param_key] = $param_value; + file_put_contents($config_file, json_encode($configs, JSON_PRETTY_PRINT)); + $data = $configs; + break; + + case 'get': + $data = !empty($configs[$param_key]) ? $configs[$param_key] : ''; + break; + + case 'del': + unset($configs[$param_key]); + file_put_contents($config_file, json_encode($configs, JSON_PRETTY_PRINT)); + $data = $configs; + break; + + case 'all': + default: + $data = $configs; + break; + } + } + + + $res = compact('code', 'data'); + + echo "命令参数:\n"; + print_r($this->get()); + echo "\n"; + echo "命令执行结果:\n"; + print_r($res); + echo "\n\n"; + exit; + } + public function actionTest() { echo "## App variables:\n"; print_r(FSC::$app); diff --git a/themes/beauty/views/site/player.php b/themes/beauty/views/site/player.php index 4f684cb..0880dff 100644 --- a/themes/beauty/views/site/player.php +++ b/themes/beauty/views/site/player.php @@ -29,6 +29,7 @@
- + ⬇️ 下载视频 diff --git a/www/js/beauty.js b/www/js/beauty.js index 2069a30..4d1f28e 100644 --- a/www/js/beauty.js +++ b/www/js/beauty.js @@ -358,6 +358,16 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') { }; myPlayer.one('playing', function() { - setTimeout(takeScreenshot, 1000); + var screenshot_start = $('video.vjs-tech').attr('data-screenshot-start'); + + if (screenshot_start) { + screenshot_start = parseInt(screenshot_start); + } + + if (!screenshot_start) { + screenshot_start = 1000; + } + + setTimeout(takeScreenshot, screenshot_start); }); } \ No newline at end of file