Files
electron-egg/app/extend/context.js
gaoshuaixing be06d62916 1
2020-12-30 11:39:20 +08:00

36 lines
621 B
JavaScript

/**
*
* @type {{foo(*)}}
*/
'use strict';
module.exports = {
isMobile() {
const deviceAgent = this.get('user-agent').toLowerCase();
const agentID = deviceAgent.match(/(iphone|ipod|ipad|android)/);
if (agentID) {
// 手机访问
return true;
}
// 电脑访问
return false;
},
success(msg, data, total) {
this.body = {
success: true,
msg,
result: data,
total,
};
},
failure(msg, data) {
this.body = {
success: false,
msg,
result: data,
};
},
async infoPage(msg) {
await this.render('500', { msg });
},
};