Browse Source

add config set command

master
filesite 4 months ago
parent
commit
c464d094bc
  1. 26
      README.md
  2. 15
      bin/upgrade.sh
  3. 1
      conf/app.php
  4. 7
      conf/nginx_machete.conf
  5. 66
      controller/CommandController.php
  6. 3
      themes/beauty/views/site/player.php
  7. 12
      www/js/beauty.js

26
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文件共享方式管理内容。 最新版本已经支持网页版后台和samba文件共享方式管理内容。

15
bin/upgrade.sh

@ -66,6 +66,9 @@ if [ -f "master.tar.gz" ]; then
fi fi
echo "Machete front-end upgraded."
echo ""
# upgrade admin # upgrade admin
cd /var/www/downloads/ cd /var/www/downloads/
@ -79,6 +82,16 @@ if [ -f "master.tar.gz" ]; then
mv jialuomaadmin/dist/ /var/www/machete/www/admin mv jialuomaadmin/dist/ /var/www/machete/www/admin
fi 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 "" echo ""

1
conf/app.php

@ -51,6 +51,7 @@ $configs = array(
'supportedImageExts' => array('jpg', 'jpeg', 'png', 'webp', 'gif'), 'supportedImageExts' => array('jpg', 'jpeg', 'png', 'webp', 'gif'),
'supportedVideoExts' => array('mp4', 'mov', 'm3u8'), 'supportedVideoExts' => array('mp4', 'mov', 'm3u8'),
'screenshot_start' => 8000, //视频播放页快照截取开始时间,单位:毫秒
/* /*
//视频皮肤配置 //视频皮肤配置

7
conf/nginx_machete.conf

@ -11,7 +11,12 @@ server {
root /var/www/machete/www; root /var/www/machete/www;
index index.php index.html; 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; expires 30d;
} }

66
controller/CommandController.php

@ -18,6 +18,72 @@ eof;
exit; 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() { public function actionTest() {
echo "## App variables:\n"; echo "## App variables:\n";
print_r(FSC::$app); print_r(FSC::$app);

3
themes/beauty/views/site/player.php

@ -29,6 +29,7 @@
<div class="videoplayer"> <div class="videoplayer">
<video <video
data-id="<?php echo $viewData['videoId']; ?>" data-id="<?php echo $viewData['videoId']; ?>"
data-screenshot-start="<?php echo FSC::$app['config']['screenshot_start']; ?>"
class="video-js vjs-big-play-centered vjs-fluid vjs-16-9" class="video-js vjs-big-play-centered vjs-fluid vjs-16-9"
controls controls
playsinline playsinline
@ -37,7 +38,7 @@
<source src="<?php echo $viewData['videoUrl']; ?>" type="video/mp4"> <source src="<?php echo $viewData['videoUrl']; ?>" type="video/mp4">
</video> </video>
<div class="text-right mt-2 mr-1"> <div class="text-right mt-2 mr-1">
<a class="btn btn-default" href="<?php echo $viewData['videoUrl']; ?>"> <a class="btn btn-default" href="<?php echo $viewData['videoUrl']; ?>&download=1">
下载视频 下载视频
</a> </a>

12
www/js/beauty.js

@ -358,6 +358,16 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') {
}; };
myPlayer.one('playing', function() { 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);
}); });
} }
Loading…
Cancel
Save