广告位调整
This commit is contained in:
+12
-34
@@ -12,7 +12,6 @@
|
||||
<span v-show="state.countdown > 0">{{ state.countdown }}</span>
|
||||
<div class="jump_over" v-show="state.countdown <= 0" @click="goApp">跳过</div>
|
||||
</div>
|
||||
<EnterGroupPopup v-if="state.isCheckError" />
|
||||
<!-- <UpgradePopup :show="state.isUpgrade" /> -->
|
||||
<div class="selectLineBox" v-if="state.loading">
|
||||
<van-loading color="#1989fa" size="30" />
|
||||
@@ -50,11 +49,8 @@ const state = reactive({
|
||||
timer: <any>null, //广告定时器
|
||||
checkTimer: <any>null, //检测图片是否加载成功定时器
|
||||
checkTime: 3, //图片加载成功检测时间
|
||||
isCheckError: false, //是否选线失败
|
||||
checkLineErrorNum: 0, //选线失败次数
|
||||
isResLock: false, // 请求结果锁
|
||||
resResult: <any>[], // 响应结果
|
||||
pingCheckCount: 0, // 请求的ping失败次数
|
||||
lineFailCount: 0, // 已失败的线路数
|
||||
loading: true, // 选线loading
|
||||
isUpgrade: true, //是否升级
|
||||
});
|
||||
@@ -353,30 +349,14 @@ const getConfig = async (): Promise<boolean> => {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
const pingErrorPop = (hosts: any) => {
|
||||
// 只有最后一条域名出错时,判断响应结果不存在true的时候,说明全部不通,即弹出选线失败
|
||||
state.pingCheckCount++;
|
||||
if (state.pingCheckCount == hosts.length) {
|
||||
state.pingCheckCount = 0;
|
||||
let index = state.resResult.indexOf(true);
|
||||
if (index == -1) {
|
||||
if (state.checkLineErrorNum == 1) {
|
||||
state.isCheckError = true;
|
||||
return;
|
||||
}
|
||||
showDialog({
|
||||
title: '温馨提示',
|
||||
message: '选线失败',
|
||||
confirmButtonText: '重试',
|
||||
theme: 'round-button',
|
||||
}).then(() => {
|
||||
state.checkLineErrorNum++;
|
||||
appStore.$reset();
|
||||
userStore.$reset();
|
||||
configStore.$reset();
|
||||
init();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @description 选线失败:同安卓,失败不做处理(不弹重试/线路异常弹窗)。
|
||||
* 全部线路都不通就收起「选线中...」,启动流程停在启动页
|
||||
*/
|
||||
const onLineCheckFail = (hosts: any) => {
|
||||
state.lineFailCount++;
|
||||
if (state.lineFailCount >= hosts.length && !state.isResLock) {
|
||||
state.loading = false;
|
||||
}
|
||||
};
|
||||
/**
|
||||
@@ -389,8 +369,7 @@ const init = async () => {
|
||||
: localStorage.setItem('isAppStore', ''); // 保存是否来自商店包,用于判断是否跳转外链
|
||||
const baseUrls: string = process.env.VITE_BASE_URL || '[]';
|
||||
const hosts = JSON.parse(baseUrls);
|
||||
state.resResult = new Array(hosts.length);
|
||||
hosts.forEach((url: any, index: number) => {
|
||||
hosts.forEach((url: any) => {
|
||||
axios({
|
||||
method: 'GET',
|
||||
url: url + '/api/app/ping/check',
|
||||
@@ -400,17 +379,16 @@ const init = async () => {
|
||||
if (res.data.code == 200) {
|
||||
if (!state.isResLock) {
|
||||
state.isResLock = true;
|
||||
state.resResult[index] = true;
|
||||
//选线成功
|
||||
useConfigStore().saveBaseUrl(url);
|
||||
await ensureAuthAndConfig();
|
||||
}
|
||||
} else {
|
||||
pingErrorPop(hosts);
|
||||
onLineCheckFail(hosts);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
pingErrorPop(hosts);
|
||||
onLineCheckFail(hosts);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user