lilei 1 년 전
부모
커밋
070104d31f
2개의 변경된 파일65개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 2
      src/utils/request.js
  2. 58 0
      src/utils/util.js

+ 7 - 2
src/utils/request.js

@@ -6,6 +6,7 @@ import notification from 'ant-design-vue/es/notification'
 import modal from 'ant-design-vue/es/modal'
 import { getAuthPriceCode } from './util'
 import { VueAxios } from './axios'
+import { getUserOsInfo, getBrowserType} from './util'
 
 //没有基地址 访问根目录下文件
 const GETNOBASE = async (url, params) => {
@@ -116,6 +117,12 @@ service.interceptors.request.use(config => {
     config.headers['access-token'] = token // 让每个请求携带自定义 token 请根据实际情况自行修改
   }
   
+  // 操作系统、浏览器信息
+  config.headers['os'] = getUserOsInfo()
+  config.headers['bws'] = getBrowserType()
+  // 分辨率
+  config.headers['sdr'] = window.screen.width+'X'+window.screen.height
+  
   // 获取当前时间撮
   const interFaceList = store.getters.interFaceList
   const curPath = config.url
@@ -134,8 +141,6 @@ service.interceptors.request.use(config => {
   if(currentPage&&currentPage.meta&&config.headers['module']){
     config.headers['module'] = encodeURIComponent(currentPage.meta.title||'') + ',' +config.headers['module']
   }
-  console.log(config.url)
-  console.log(decodeURIComponent(config.headers['module']))
    
   config.headers['auth-price'] = authPrice.join(',') // 价格权限
   config.retry = 3

+ 58 - 0
src/utils/util.js

@@ -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()