一、兼容es6语法
1、安装babel-polyfill
npm install babel-polyfill
2、在src/main.js最上面第一行代码引入
import 'babel-polyfill'
二、兼容.finally方法
npm install promise.prototype.finally --save
然后在src/main.js文件中引入
require('promise.prototype.finally').shim()
//getLogin.js文件
const getKeycloakUrl = () => {
const { host } = window.location,
pathArr = host.split('.'),
pathArr2 = host.split(':'),
r = /^\+?[1-9][0-9]*$/,
isNumberFlag = r.test(pathArr[0]),
isNumber = r.test(pathArr[0]) ? (pathArr2[1] = 18080) : (pathArr[0] = 'auth'),
pathName = isNumberFlag ? pathArr2.join(':') : pathArr.join('.'),
obj = {
numFlag: isNumber,
KC_URL: `${window.location.protocol}//${pathName}/auth`
}
return obj.KC_URL
}
export default getKeycloakUrl
//main.js 单点登录逻辑
import getKeycloakUrl from '@/utils/getLogin.js'
require('promise.prototype.finally').shim()
window.myLeftMenuList = {}
const oauth = Provide(OauthService),
redireUrl = window.location.origin;
(async function () {
try {
await oauth.install(Vue, {
// url: ((newUrls === '10.151.231.148') || (newUrls === '10.151.226.49')
// || (process.env.NODE_ENV === 'development'))
// ? process.env.VUE_APP_SSO_URL : getKeycloakUrl(),
url: process.env.VUE_APP_SSO_URL,
realm: process.env.VUE_APP_REALM,
clientId: process.env.VUE_APP_CLIENT_ID,
redirectUri: `${redireUrl}/`,
loginRequired: true
})
const localToken = local.get('ROCHE_COMMON_CACHE').token,
data = {
token: localToken
}
await getPermiss(data).then(
(resp) => {
if (resp.code === 0) {
const myPermissionsRes = resp.payload
window.myLeftMenuList = myPermissionsRes
} else {
Message.error(resp.errorMessage)
}
},
(error) => {
Message.error(error)
}
)
} finally {
new Vue({
vuetify, router, render: (h) => h(App)
}).$mount('#app')
}
})()
三、滚动条样式兼容,隐藏滚动条
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background-color: #fff;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
::-webkit-scrollbar-thumb {
background-color: #d8d8d8;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
} //浏览器样式自定义
.infoPlanDate::-webkit-scrollbar {
display: none; //普遍浏览器
}
.infoPlanDate {
scrollbar-width: none; //火狐浏览器
}
.infoPlanDate {
-ms-overflow-style: none; //ie浏览器
}