内网环境判断

This commit is contained in:
王卓煜
2025-07-21 10:33:44 +08:00
parent 3cfa3ffec3
commit 147366f738

View File

@@ -630,7 +630,7 @@
let urlSign = encodeURIComponent(encrypt(beforeUrl)); let urlSign = encodeURIComponent(encrypt(beforeUrl));
cookies.set('PLAYSIGN_TIME', ctime); //写客户端的cookie保存 cookies.set('PLAYSIGN_TIME', ctime); //写客户端的cookie保存
//以下判断是为了区分本地环境和服务器环境 //以下判断是为了区分本地环境和服务器环境
if (process.env.NODE_ENV == 'development') { if (true) {
this.blobUrl = process.env.VUE_APP_FILE_BASE_URL + u; this.blobUrl = process.env.VUE_APP_FILE_BASE_URL + u;
} else { } else {
this.blobUrl = process.env.VUE_APP_BASE_API + '/xboe/m/course/cware/resource?sign=' + urlSign; this.blobUrl = process.env.VUE_APP_BASE_API + '/xboe/m/course/cware/resource?sign=' + urlSign;
@@ -1386,12 +1386,55 @@
this.totalContent = rs.result.contents.length; this.totalContent = rs.result.contents.length;
//加载学习的数据 //加载学习的数据
this.loadStudyData(rs.result); this.loadStudyData(rs.result);
if (rs.result.course.isPermission){
this.getInternet()
console.log('需要内网环境')
}
} else { } else {
this.$message.error(rs.message); this.$message.error(rs.message);
} }
}); });
}, },
// 检测是否为内网
getInternet() {
this.Internet = 3;
let $this = this;
let xmlhttp = this.getXmlHttpRequest();
let timedOut = false;
let timer = setTimeout(function () {
timedOut = true;
xmlhttp.abort();
}, 5000);
xmlhttp.open("HEAD", window.location.protocol + "//uapi.boe.com.cn/500.html", true);
xmlhttp.send();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
clearTimeout(timer);
$this.Internet = 1;
$this.$store.dispatch("userTrigger", {
key: "ViewCase",//后台的事件key 发布文章且审核通过
title: '查看案例',//事件的标题
parameters: "",//用户自定义参数 name:value,name:value
content: '查看了案例',//事件的内容
objId: $this.resolveId,//关联的id
objType: "3",//关联的类型
objInfo: $this.caseDetail?.title,
aid: $this.userInfo.aid, //当前登录人的id
aname: $this.userInfo.name,//当前人的姓名
status: 1 //状态直接写1
});
$this.sendEventData();
} else {
clearTimeout(timer);
$this.Internet = 2;
}
} else {
if (timedOut) return;//忽略中止请求
clearTimeout(timer);//取消等待的超时
}
}
},
loadStudyData(result) { loadStudyData(result) {
let $this=this; let $this=this;
this.loadScorePraiseAndTrample(); this.loadScorePraiseAndTrample();