mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 16:54:25 +08:00
show device icon and name in session list
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import utils from "../lib/utils.js";
|
||||
|
||||
export default function (token) {
|
||||
const ua = utils.parseUserAgent(token.userAgent);
|
||||
let result = '';
|
||||
|
||||
if (ua.device.model) {
|
||||
result = ua.device.model;
|
||||
} else if (ua.os.name) {
|
||||
result = ua.os.name;
|
||||
|
||||
if (ua.os.version) {
|
||||
result += ' ' + ua.os.version;
|
||||
}
|
||||
}
|
||||
|
||||
if (ua.browser.name) {
|
||||
let browserInfo = ua.browser.name;
|
||||
|
||||
if (ua.browser.version) {
|
||||
browserInfo += ' ' + ua.browser.version;
|
||||
}
|
||||
|
||||
if (result) {
|
||||
result += ' (' + browserInfo + ')';
|
||||
} else {
|
||||
result = browserInfo;
|
||||
}
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
return 'Unknown Device';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import icons from "../consts/icon.js";
|
||||
import utils from "../lib/utils.js";
|
||||
|
||||
export default function (token) {
|
||||
const ua = utils.parseUserAgent(token.userAgent);
|
||||
|
||||
if (!ua || !ua.device) {
|
||||
return icons.deviceIcons.desktop.f7Icon;
|
||||
}
|
||||
|
||||
if (ua.device.type === 'mobile') {
|
||||
return icons.deviceIcons.mobile.f7Icon;
|
||||
} else if (ua.device.type === 'wearable') {
|
||||
return icons.deviceIcons.wearable.f7Icon;
|
||||
} else if (ua.device.type === 'tablet') {
|
||||
return icons.deviceIcons.tablet.f7Icon;
|
||||
} else if (ua.device.type === 'smarttv') {
|
||||
return icons.deviceIcons.tv.f7Icon;
|
||||
} else {
|
||||
return icons.deviceIcons.desktop.f7Icon;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user