Compare commits
3 Commits
0103444cb8
...
667d53484e
Author | SHA1 | Date |
---|---|---|
guoyue | 667d53484e | |
guoyue | d13dbbb09a | |
guoyue | 14aa35bd11 |
Binary file not shown.
Binary file not shown.
|
@ -24,6 +24,9 @@ import 'vue3-video-play-emiyagm/dist/style.css' // 引入css
|
|||
import ElementPlus from 'element-plus'
|
||||
import 'element-plus/dist/index.css'
|
||||
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
console.log(111, 'main')
|
||||
/**
|
||||
* @author chuzhixin 1204505056@qq.com
|
||||
* @description 正式环境默认使用mock,正式项目记得注释后再打包
|
||||
|
@ -54,3 +57,79 @@ router.beforeEach((to, from, next) => {
|
|||
document.body.scrollTop = 0
|
||||
next()
|
||||
})
|
||||
|
||||
|
||||
// 判断浏览器
|
||||
function judgeAgent() {
|
||||
let userAgent = navigator.userAgent // 取得浏览器的userAgent字符串
|
||||
console.log('userAgent------------>', userAgent);
|
||||
let isOpera = userAgent.indexOf('Opera') > -1
|
||||
//判断是否Opera浏览器
|
||||
if (isOpera) {
|
||||
return 'Opera'
|
||||
}
|
||||
//判断是否Firefox浏览器
|
||||
if (userAgent.indexOf('Firefox') > -1) {
|
||||
return 'FF'
|
||||
}
|
||||
//判断是否chorme浏览器
|
||||
if (userAgent.indexOf('Chrome') > -1) {
|
||||
return 'Chrome'
|
||||
}
|
||||
//判断是否Safari浏览器
|
||||
if (userAgent.indexOf('Safari') > -1) {
|
||||
return 'Safari'
|
||||
}
|
||||
//判断是否IE浏览器
|
||||
if (
|
||||
userAgent.indexOf('compatible') > -1 &&
|
||||
userAgent.indexOf('MSIE') > -1 &&
|
||||
!isOpera
|
||||
) {
|
||||
return 'IE'
|
||||
}
|
||||
//判断是否Edge浏览器
|
||||
if (userAgent.indexOf('Trident') > -1) {
|
||||
return 'Edge'
|
||||
}
|
||||
}
|
||||
function downloadFile(name, url) {
|
||||
const alink = document.createElement('a');
|
||||
alink.download = name;// 文件名,大部分浏览器兼容,IE10及以下不兼容
|
||||
alink.href = url;// 创建 url地址
|
||||
alink.click(); // 自动点击
|
||||
}
|
||||
|
||||
function getPCNum() {
|
||||
const agent = navigator.userAgent.toLowerCase();
|
||||
if (agent.indexOf('win32') >= 0 || agent.indexOf('wow32') >= 0) {
|
||||
return 32;
|
||||
}
|
||||
if (agent.indexOf('win64') >= 0 || agent.indexOf('wow64') >= 0) {
|
||||
return 64;
|
||||
}
|
||||
}
|
||||
|
||||
console.log('------判断浏览器------>', judgeAgent());
|
||||
|
||||
// 提示下载谷歌
|
||||
if (judgeAgent() !== 'Chrome') {
|
||||
ElMessageBox.confirm('当前仅支持Chrome浏览器,是否进行下载?', '提示', {
|
||||
confirmButtonText: '下载',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
// 获取当前系统的方法
|
||||
const agent = getPCNum();
|
||||
console.log('agent------------>', agent);
|
||||
if (agent == 64) {
|
||||
// 64位操作系统
|
||||
// downloadFile(_global.config.loginInfo.name_32, _global.config.loginInfo.url_32);
|
||||
downloadFile('ChromeStandaloneSetup64.exe', '/static/download/ChromeStandaloneSetup64.exe');
|
||||
} else {
|
||||
// 32位操作系统
|
||||
downloadFile('ChromeStandalonesetup32.exe', '/static/download/standalonesetup32.exe');
|
||||
}
|
||||
}).catch(() => {
|
||||
});
|
||||
}
|
||||
|
|
|
@ -82,9 +82,9 @@ instance.interceptors.request.use(
|
|||
if (debounce.some((item) => config.url.includes(item))) {
|
||||
//这里写加载动画
|
||||
}
|
||||
if (!config.headers.REQUESTURI) {
|
||||
config.headers.REQUESTURI = window.location.href
|
||||
}
|
||||
// if (!config.headers.REQUESTURI) {
|
||||
// config.headers.REQUESTURI = window.location.href
|
||||
// }
|
||||
|
||||
return config
|
||||
},
|
||||
|
@ -108,19 +108,19 @@ instance.interceptors.response.use(
|
|||
message
|
||||
} = response.data
|
||||
|
||||
if (response.headers.token) {
|
||||
setAccessToken(response.headers.token)
|
||||
}
|
||||
if (response.headers.redirect) {
|
||||
const _old_href = window.location.href.split('#')[0];
|
||||
const _new_href = response.headers.redirect.split('#')[0];
|
||||
window.location.replace(response.headers.redirect)
|
||||
// url 相同,强制刷新
|
||||
if (_old_href === _new_href) {
|
||||
location.reload()
|
||||
}
|
||||
return response
|
||||
}
|
||||
// if (response.headers.token) {
|
||||
// setAccessToken(response.headers.token)
|
||||
// }
|
||||
// if (response.headers.redirect) {
|
||||
// const _old_href = window.location.href.split('#')[0];
|
||||
// const _new_href = response.headers.redirect.split('#')[0];
|
||||
// window.location.replace(response.headers.redirect)
|
||||
// // url 相同,强制刷新
|
||||
// if (_old_href === _new_href) {
|
||||
// location.reload()
|
||||
// }
|
||||
// return response
|
||||
// }
|
||||
if (response.headers.redirect === '/#/login') {
|
||||
var keys = document.cookie.match(/[^ =;]+(?=\=)/g)
|
||||
if (keys) {
|
||||
|
@ -179,10 +179,10 @@ instance.interceptors.response.use(
|
|||
if (response.headers.token) {
|
||||
setAccessToken(response.headers.token)
|
||||
}
|
||||
if (response.headers.redirect) {
|
||||
window.location.replace(response.headers.redirect)
|
||||
return Promise.resolve()
|
||||
}
|
||||
// if (response.headers.redirect) {
|
||||
// window.location.replace(response.headers.redirect)
|
||||
// return Promise.resolve()
|
||||
// }
|
||||
const {
|
||||
status,
|
||||
data
|
||||
|
|
Loading…
Reference in New Issue