deal danmaku maximum in back-end
This commit is contained in:
parent
2054eb086a
commit
02cbcf4495
|
|
@ -123,9 +123,11 @@ $ npm run build
|
|||
|
||||
## Todo
|
||||
|
||||
- [ ] 截图
|
||||
|
||||
- [ ] 记录播放位置 记录透明度
|
||||
|
||||
- [ ] 中英文切换
|
||||
- [ ] 国际化
|
||||
|
||||
- [ ] 微博登录
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
id: '9E2E3368B56CDBB4',
|
||||
api: 'https://dplayer.daoapp.io/',
|
||||
token: 'tokendemo',
|
||||
maximum: 1000
|
||||
maximum: 3000
|
||||
}
|
||||
});
|
||||
dp.init();
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -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 += `,`;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue