Skip to content

Commit cec8ee3

Browse files
committed
feat: 浏览器兼容性提示
1 parent d043ccb commit cec8ee3

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

assets/less/iview/components/index.less

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// @import "badge";
55
// @import "circle";
66
@import "spin";
7-
// @import "alert";
7+
@import "alert";
88
// @import "collapse";
99
// @import "card";
1010
@import "message";

layouts/default.vue

+27
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
<template>
22
<div class="layout-default">
3+
<!-- Browse Happy -->
4+
<Collapse>
5+
<IAlert
6+
v-if="isIE"
7+
banner
8+
type="warning"
9+
closable
10+
:style="{marginBottom: 0,marginRight: logged && '48px', zIndex: 100}"
11+
>
12+
<!-- eslint-disable-next-line -->
13+
您正在使用过时的 IE 浏览器,因此排版可能会错乱。为了您的浏览体验,强烈建议您更换至 <a class="primary-color" href="https://browsehappy.com/" target="_blank" >现代浏览器</a>
14+
</IAlert>
15+
</Collapse>
16+
317
<CommonHeader />
418

519
<div class="container main">
@@ -23,6 +37,7 @@
2337
</template>
2438

2539
<script>
40+
import { isIE } from '@/utils'
2641
import CommonHeader from '@/components/layout/CommonHeader.vue'
2742
import CommonFooter from '@/components/layout/CommonFooter.vue'
2843
import FloatWidget from '@/components/layout/FloatWidget.vue'
@@ -48,6 +63,18 @@ export default {
4863
ModalPinned,
4964
ModalPassword,
5065
},
66+
data () {
67+
return {
68+
isIE: false,
69+
}
70+
},
71+
mounted () {
72+
if (isIE()) {
73+
setTimeout(() => {
74+
this.isIE = true
75+
}, 500)
76+
}
77+
},
5178
}
5279
</script>
5380

plugins/iview.js

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Vue from 'vue'
22
import '@/assets/less/index.less'
33

44
import {
5+
Alert,
56
Button,
67
Breadcrumb,
78
BreadcrumbItem,
@@ -32,6 +33,7 @@ import {
3233
} from 'iview'
3334

3435
const components = {
36+
Alert,
3537
Button,
3638
Breadcrumb,
3739
BreadcrumbItem,

utils/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ export const isNumber = val => {
2121
else return /^\d+$/.test(val)
2222
}
2323

24+
/**
25+
* 判断是否是 IE 浏览器
26+
*/
27+
export function isIE () {
28+
if (process.client) {
29+
return !!window.ActiveXObject || 'ActiveXObject' in window
30+
}
31+
return null
32+
}
33+
2434
/**
2535
* 获取关注状态
2636
* @param {boolean} follower 被关注

0 commit comments

Comments
 (0)