Skip to content

Commit

Permalink
实现Demo全部功能
Browse files Browse the repository at this point in the history
  • Loading branch information
hauk0101 committed Aug 28, 2017
1 parent 27b0c93 commit 3d6046e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
25 changes: 13 additions & 12 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
Expand Down Expand Up @@ -37,19 +36,21 @@ app.use(session({
maxAge:1000 * 60 * 60 * 24
}
}));
//静态资源访问限制,
//静态资源访问限制
app.use(function (req, res, next) {
var static = /^(\/public|\/key)/g;//设置指定文件目录
var suffix = /(\.key)$/g;//后缀格式指定
// if ((req.session.username != 'admin')
// && (static.test(req.path) && suffix.test(req.path) )) {
// console.log('用户未登录,不允许访问key文件');
// return res.send('请求非法');
// }
// else {
// console.log('当前用户已登录');
if ( suffix.test(req.path)) {
console.log(req.session.username,'++++请求key文件了');
if((req.session.username != 'admin')){
return res.send('请求非法');
}else{
console.log('+++++请求key文件了,并且已经登录,登录名为:',req.session.username);
next();
}
}
else {
next();
// }
}
});
app.use(express.static(path.join(__dirname, 'public')));

Expand All @@ -64,7 +65,7 @@ app.use(function (req, res, next) {
});

// error handler
app.use(function (err, req, res, next) {
app.use(function (err, req, res) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
Expand Down
1 change: 1 addition & 0 deletions app/controllers/encrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function encryptFun(options,socket, callback) {
.save(_outputPath)
.on('end', function () {
socket.emit('encrypt-event',{msg:'Encrypt the ' + options.fileName + ' file OK!',type:1});
callback(null, 'Encrypt the ' + options.fileName + ' file OK!');
})
.on('stderr', function (stderrLine) {
console.log('Stderr output: ' + stderrLine);
Expand Down
4 changes: 2 additions & 2 deletions app/public/javascripts/encrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
type:'POST',
data:data,
dataType:'json',
success:function(){

success:function(data){
console.log(data);
},
fail:function () {
console.log('视频加密POST请求失败!');
Expand Down
5 changes: 1 addition & 4 deletions app/public/javascripts/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

var video_name,video_url,canPlay;

//隐藏播放器
setClickable(play_btn,false);
//检测按钮点击处理函数
eventBind(test_btn,'click',function(){
canPlay = false;
Expand Down Expand Up @@ -47,7 +45,6 @@
}
});
setClickable(test_btn,false);
setHide(player_container,false);
} else{
alert('请输入需要检测的视频文件名!');
player_tip.innerHTML = '播放前请检测视频是否存在,如不存在则无法正常播放!';
Expand All @@ -61,7 +58,7 @@
myPlayer.ready(function() {
this.src({
src: video_url,
type: 'application/x-mpegURL',
type: 'application/x-mpegURL'
});
this.play();
});
Expand Down
1 change: 0 additions & 1 deletion app/views/upload.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<script>
var upload_file = document.getElementById('upload-file');
function check(){
console.log(upload_file.value.length);
if(upload_file.value.length>0){
return true;
}else{
Expand Down

0 comments on commit 3d6046e

Please sign in to comment.