Browse Source

火狐下不调整顶部缩进

Karsa 3 years ago
parent
commit
7025377b28
2 changed files with 58 additions and 2 deletions
  1. 55 0
      src/utils/utils.ts
  2. 3 2
      src/views/chartShow/index.vue

+ 55 - 0
src/utils/utils.ts

@@ -0,0 +1,55 @@
+export const browser = () => {
+	// 取得浏览器的userAgent字符串
+	var userAgent = navigator.userAgent
+	// 判断是否Opera浏览器
+	var isOpera = userAgent.indexOf('Opera') > -1
+	// 判断是否IE浏览器
+	var isIE =
+		userAgent.indexOf('compatible') > -1 &&
+		userAgent.indexOf('MSIE') > -1 &&
+		!isOpera
+	// 判断是否IE的Edge浏览器
+	var isEdge = userAgent.indexOf('Edge') > -1
+	// 判断是否Firefox浏览器
+	var isFF = userAgent.indexOf('Firefox') > -1
+	// 判断是否Safari浏览器
+	var isSafari =
+		userAgent.indexOf('Safari') > -1 && userAgent.indexOf('Chrome') === -1
+	// 判断Chrome浏览器
+	var isChrome =
+		userAgent.indexOf('Chrome') > -1 && userAgent.indexOf('Safari') > -1
+
+	if (isIE) {
+		var reIE = new RegExp('MSIE (\\d+\\.\\d+);')
+		reIE.test(userAgent)
+		var fIEVersion = parseFloat(RegExp['$1'])
+		if (fIEVersion === 7) {
+			return 'IE7'
+		} else if (fIEVersion === 8) {
+			return 'IE8'
+		} else if (fIEVersion === 9) {
+			return 'IE9'
+		} else if (fIEVersion === 10) {
+			return 'IE10'
+		} else if (fIEVersion === 11) {
+			return 'IE11'
+		} else {
+			return 'IE'
+		}
+	}
+	if (isOpera) {
+		return 'Opera'
+	}
+	if (isEdge) {
+		return 'Edge'
+	}
+	if (isFF) {
+		return 'FF'
+	}
+	if (isSafari) {
+		return 'Safari'
+	}
+	if (isChrome) {
+		return 'Chrome'
+	}
+}

+ 3 - 2
src/views/chartShow/index.vue

@@ -32,6 +32,7 @@ import { IDataProps, ILunarItem, IParams, ISeasonDataItemProps } from '@/types';
 import Highcharts from 'highcharts';
 import { defaultOpts, seasonOptions } from '@/utils/chartOptions';
 import moment from 'moment';
+import { browser } from '@/utils/utils';
 
 export default defineComponent({
   components: {
@@ -347,8 +348,8 @@ export default defineComponent({
             };
 
         //农历图调整顶部缩进
-        if (state.chartInfo.Calendar === '农历') chart = {
-          spacingTop: -10,
+        if (state.chartInfo.Calendar === '农历' && browser() !== 'FF') chart = {
+          spacingTop: -26,
         }
 
         state.options = {