|
@@ -1,3 +1,61 @@
|
|
|
+// 获取客户端操作系统信息
|
|
|
+export const getUserOsInfo = function () {
|
|
|
+ const userAgent = navigator.userAgent;
|
|
|
+ if (userAgent.indexOf("Windows NT 10.0") !== -1) return "Windows 10";
|
|
|
+ if (userAgent.indexOf("Windows NT 6.2") !== -1) return "Windows 8";
|
|
|
+ if (userAgent.indexOf("Windows NT 6.1") !== -1) return "Windows 7";
|
|
|
+ if (userAgent.indexOf("Windows NT 6.0") !== -1) return "Windows Vista";
|
|
|
+ if (userAgent.indexOf("Windows NT 5.1") !== -1) return "Windows XP";
|
|
|
+ if (userAgent.indexOf("Windows NT 5.0") !== -1) return "Windows 2000";
|
|
|
+ if (userAgent.indexOf("Mac") !== -1) return "Mac/iOS";
|
|
|
+ if (userAgent.indexOf("X11") !== -1) return "UNIX";
|
|
|
+ if (userAgent.indexOf("Linux") !== -1) return "Linux";
|
|
|
+ return "Other";
|
|
|
+}
|
|
|
+// 获取浏览器类型
|
|
|
+export const _mime = function (option, value) {
|
|
|
+ var mimeTypes = navigator.mimeTypes;
|
|
|
+ for (var mt in mimeTypes) {
|
|
|
+ if (mimeTypes[mt][option] == value) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+export const getBrowserType = function () {
|
|
|
+ let ua = navigator.userAgent.toLocaleLowerCase()
|
|
|
+ let browserType = null
|
|
|
+ if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
|
|
|
+ browserType = 'IE'
|
|
|
+ } else if (ua.match(/firefox/) != null) {
|
|
|
+ browserType = 'firefox'
|
|
|
+ } else if (ua.match(/ucbrowser/) != null) {
|
|
|
+ browserType = 'UC'
|
|
|
+ } else if (ua.match(/opera/) != null || ua.match(/opr/) != null) {
|
|
|
+ browserType = 'opera'
|
|
|
+ } else if (ua.match(/bidubrowser/) != null) {
|
|
|
+ browserType = 'baidu'
|
|
|
+ } else if (ua.match(/metasr/) != null) {
|
|
|
+ browserType = 'sougou'
|
|
|
+ } else if (ua.match(/tencenttraveler/) != null || ua.match(/qqbrowse/) != null) {
|
|
|
+ browserType = 'QQ'
|
|
|
+ } else if (ua.match(/maxthon/) != null) {
|
|
|
+ browserType = 'maxthon'
|
|
|
+ } else if (ua.match(/chrome/) != null) {
|
|
|
+ var is360 = _mime('type', 'application/vnd.chromium.remoting-viewer')
|
|
|
+ if (is360) {
|
|
|
+ browserType = '360'
|
|
|
+ } else {
|
|
|
+ browserType = 'chrome'
|
|
|
+ }
|
|
|
+ } else if (ua.match(/safari/) != null) {
|
|
|
+ browserType = 'Safari'
|
|
|
+ } else {
|
|
|
+ browserType = 'others'
|
|
|
+ }
|
|
|
+ return browserType
|
|
|
+}
|
|
|
+
|
|
|
export function timeFix () {
|
|
|
const time = new Date()
|
|
|
const hour = time.getHours()
|