show device icon and name in session list

This commit is contained in:
MaysWind
2020-11-17 21:49:01 +08:00
parent 4c706282d5
commit 68233852e7
12 changed files with 135 additions and 4 deletions
+23 -1
View File
@@ -1,4 +1,5 @@
import accountConstants from '../consts/account.js'
import uaParser from 'ua-parser-js';
import accountConstants from '../consts/account.js';
function isFunction(val) {
return typeof(val) === 'function';
@@ -28,6 +29,26 @@ function isBoolean(val) {
return typeof(val) === 'boolean';
}
function parseUserAgent(ua) {
const uaParseRet = uaParser(ua);
return {
device: {
vendor: uaParseRet.device.vendor,
model: uaParseRet.device.model,
type: uaParseRet.device.type
},
os: {
name: uaParseRet.os.name,
version: uaParseRet.os.version
},
browser: {
name: uaParseRet.browser.name,
version: uaParseRet.browser.version
}
};
}
function getCategorizedAccounts(allAccounts) {
const ret = {};
@@ -104,6 +125,7 @@ export default {
isString,
isNumber,
isBoolean,
parseUserAgent,
getCategorizedAccounts,
getAccountByAccountId,
getAllFilteredAccountsBalance,