deal danmaku maximum in back-end

This commit is contained in:
DIYgod 2016-06-08 23:33:33 +08:00
parent 2054eb086a
commit 02cbcf4495
No known key found for this signature in database
GPG Key ID: F8797DD1088C6506
6 changed files with 22 additions and 15 deletions

View File

@ -123,9 +123,11 @@ $ npm run build
## Todo
- [ ] 截图
- [ ] 记录播放位置 记录透明度
- [ ] 中英文切换
- [ ] 国际化
- [ ] 微博登录

View File

@ -70,7 +70,7 @@
id: '9E2E3368B56CDBB4',
api: 'https://dplayer.daoapp.io/',
token: 'tokendemo',
maximum: 1000
maximum: 3000
}
});
dp.init();

2
dist/DPlayer.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -79,7 +79,10 @@ app.get('/', function (req, res) {
var db = mongoose.connection;
db.on('error', errorListener);
var id = url.parse(req.url,true).query.id;
var query = url.parse(req.url,true).query;
var id = query.id;
var max = query.max;
var length;
db.once('open', function() {
cleanListener();
danmaku.find({player: id}, function (err, data) {
@ -88,9 +91,10 @@ app.get('/', function (req, res) {
}
var json = `{"code": 1,"danmaku":[`;
for (var i = 0; i < data.length; i++) {
length = max ? Math.min(data.length, max) : data.length;
for (var i = 0; i < length; i++) {
json += JSON.stringify(data[i]);
if (i !== data.length - 1) {
if (i !== length - 1) {
json += `,`;
}
}

View File

@ -837,13 +837,7 @@
alert(response.msg);
}
else {
if (this.option.danmaku.maximum) {
this.maximum = parseInt(this.option.danmaku.maximum);
this.dan = response.danmaku.splice(-this.maximum, this.maximum).sort((a, b) => a.time - b.time);
}
else {
this.dan = response.danmaku.sort((a, b) => a.time - b.time);
}
this.dan = response.danmaku.sort((a, b) => a.time - b.time);
// autoplay
if (this.option.autoplay && !this.isMobile) {
@ -859,7 +853,14 @@
}
}
};
xhr.open('get', this.option.danmaku.api + '?id=' + this.option.danmaku.id, true);
let apiurl;
if (this.option.danmaku.maximum) {
apiurl = `${this.option.danmaku.api}?id=${this.option.danmaku.id}&max=${this.option.danmaku.maximum}`;
}
else {
apiurl = `${this.option.danmaku.api}?id=${this.option.danmaku.id}`;
}
xhr.open('get', apiurl, true);
xhr.send(null);
}
else {