This commit is contained in:
2025-12-18 20:09:21 +08:00
parent 57066fb864
commit b5f605dce9
7 changed files with 371 additions and 26 deletions

View File

@@ -117,7 +117,7 @@ function switchLanguage(lang) {
}
const { getVersion, stopScript } = usePythonBridge();
let version = ref('0.0.0');
let version = ref('5.1.0');
onMounted(() => {
stopScript();
@@ -156,7 +156,7 @@ const onSubmit = () => {
password: formData.value.password,
}).then((res) => {
loading.close();
console.log(res)
// console.log(res)
setToken(res.tokenValue);
setUser(res);
router.push('/nav');

View File

@@ -46,7 +46,7 @@
<el-table-column prop="invitationType" :label="$t('hostList.invitationType')" width="80">
<template #default="scope">
<el-tag :type="scope.row.invitationType == 1 ? 'success' : 'warning'">
<el-tag :type="scope.row.invitationType == 1 ? 'success' : 'warning'" @click="getliveHost">
{{ scope.row.invitationType == 1 ? $t('hostList.invitationType1') : $t('hostList.invitationType2') }}
</el-tag>
</template>
@@ -146,7 +146,7 @@
<script setup>
// import { getToken, setToken, removeToken } from '@/utils/storage'
import { tkhostdata, dicts, tkhostdetail, downList, getStaffList, managerhosts, upholdinfo, getCountryinfo, accountName } from '@/api/account';
import { tkhostdata, dicts, tkhostdetail, downList, getStaffList, managerhosts, upholdinfo, getCountryinfo, accountName, liveHostDetail } from '@/api/account';
import { usePythonBridge, } from '@/utils/pythonBridge'
import { getUser, setSerch, getSerch } from '@/utils/storage'
import { ref, reactive, onMounted } from 'vue';
@@ -155,6 +155,7 @@ import { ref, reactive, onMounted } from 'vue';
// import { color } from 'echarts';
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const loading = ref(false)
//py方法
@@ -358,6 +359,17 @@ function handleClose(done) {
}
function getliveHost() {
liveHostDetail(
{
"hostsId": "1296peahh",
"tenantId": userInfo.value.tenantId
}
).then(res => {
console.log("直播间信息列表", JSON.stringify(res))
})
}
//修改主播维护状态
// function handleSelectChange(event, data) {
@@ -396,14 +408,14 @@ function filterTag(value, row) {
//获取国家
function getCountry() {
getCountryinfo({}).then(res => {
console.log(res)
// console.log(res)
res.forEach(item => {
if (item.countryGroupName) {
options.value.push({ value: item.countryGroupName, label: item.countryGroupName })
}
})
console.log(options.value)
// console.log(options.value)
}).catch(err => {
console.log('getCountry', err)
})

View File

@@ -55,10 +55,23 @@
<div class="card-header">
<span class="center-justify"><img src="@/assets/worklogo.png">
{{ $t('workbenchesSetup.workbenches') }} </span>
<div style="margin-right: 120px;">{{ $t('workbenchesSetup.workbenches') }}:{{
locale == 'zh' ? countryData : countryDataEN }}
<!-- <el-button class="reset-button" @click="reset">重置数据</el-button> -->
<!-- <el-button class="reset-button" @click="getIpInfo">刷新</el-button>s -->
<div class="card-header-right">
<span>
{{ $t('workbenchesSetup.network') }}:{{ locale == 'zh' ? countryData : countryDataEN }}
</span>
<img style="height: 20px;" v-if="isWifi" src="@/assets/wifi.png">
<span class="inline-country">
<span style="color: black;">指定国家</span>
<el-select v-model="country_info" class="country-select" placeholder="全部" size="small">
<el-option :label="'全部'" :value="'地区全部'" />
<el-option v-for="(item, index) in country_Lst" :key="index" :label="item"
:value="item" />
</el-select>
</span>
</div>
</div>
@@ -115,13 +128,13 @@
<div class="input-group">
<label>{{ $t('workbenchesSetup.setNum') }}</label>
<label style="color: #00000070; font-size: 15px;">({{ $t('workbenchesSetup.prompt')
}})</label>
}})</label>
<el-button type="primary" @click="isLimit = true" :disabled="!pyData.isStart">{{
$t('workbenchesSetup.setHostNum')
}}</el-button>
}}</el-button>
<el-button type="info" @click="isLimit = false" :disabled="!pyData.isStart">{{
$t('workbenchesSetup.unlimitedQuantity')
}}</el-button>
}}</el-button>
<!-- <el-input type='number' v-model="pyData.frequency.hour" @input="handleInputHour" -->
<div v-if="isLimit" class="center-justify">
<el-input type='number' v-model="hostNum" :placeholder="$t('workbenchesSetup.num')"
@@ -177,7 +190,8 @@ const { fetchDataConfig, fetchDataCount, loginBackStage, loginTikTok, backStagel
let countryData = ref('');
//英文国家
let countryDataEN = ref('');
let country_info = ref('全部');
let country_Lst = ref();
//获取主播数量的定时器
let getHostTimer = ref(null);
//获取查询次数定时器
@@ -251,7 +265,7 @@ let hostNum = ref(0);
let submitting = ref(true);
let expiredTime = ref(null);
onMounted(() => {
onMounted(async () => {
//从缓存获取数据
if (getNumData()) {
pyData.value = getNumData();
@@ -273,6 +287,14 @@ onMounted(() => {
})
}, 1000);
checkVPN()
setInterval(async () => {
await checkVPN()
}, 1000 * 20)
})
const getIpInfo = async () => {
@@ -285,6 +307,13 @@ const getIpInfo = async () => {
console.log('IP信息:', data.country);
countryDataEN.value = data.country_name
countryData.value = getCountryName(data.country);
const url = `https://datasave.api.yolozs.com/api/save_data/country_info?countryName=${countryData.value}`;
const res = await fetch(url);
const countryres = await res.json();
country_Lst.value = countryres.data
} catch (error) {
console.error('请求出错:', error);
ElMessageBox.prompt('请输入将要获取国家的中文名', '获取国家失败', {
@@ -294,8 +323,15 @@ const getIpInfo = async () => {
closeOnClickModal: false,
showCancelButton: false,
})
.then(({ value }) => {
.then(async ({ value }) => {
countryData.value = value
const url = `https://datasave.api.yolozs.com/api/save_data/country_info?countryName=${countryData.value}`;
const res = await fetch(url);
const countryres = await res.json();
country_Lst.value = countryres.data
})
// .catch(() => {
// ElMessage({
@@ -368,6 +404,7 @@ const submit = () => {
country: countryData.value,
tenantId: getUser().tenantId,
userId: getUser().id,
crawl_single_nation: country_info.value == '全部' ? '' : country_info.value
})).then((res) => {
//开始计时器
startTimer();
@@ -419,6 +456,8 @@ const unsubmit = () => {
country: countryData.value,
tenantId: getUser().tenantId,
userId: getUser().id,
crawl_single_nation: country_info.value == '全部' ? '' : country_info.value
})).then((res) => {
pauseTimer();
pyData.value.isStart = true;
@@ -627,6 +666,34 @@ function timestampToTime(timestamp_ms) {
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
let isWifi = ref(false);
const checkVPN = async () => {
try {
// 设置超时 5 秒钟
const timeout = new Promise((_, reject) =>
setTimeout(() => reject(new Error('请求超时')), 10000) // 10秒超时
);
// 使用 Promise.race 来进行超时控制
const response = await Promise.race([
fetch('https://www.google.com', { method: 'HEAD', mode: 'no-cors' }),
timeout
]);
// 判断 fetch 请求是否成功
if (response && response.type === 'opaque') {
// ElMessage.success('VPN连接正常');
isWifi.value = false;
} else {
ElMessage.error('VPN连接失败无法访问网络。');
isWifi.value = true;
}
} catch (error) {
// 捕获超时错误或其他错误
ElMessage.error('VPN连接失败无法访问网络。');
isWifi.value = true;
}
};
</script>
<style scoped lang="less">
@@ -730,6 +797,34 @@ function timestampToTime(timestamp_ms) {
justify-content: space-between;
align-items: center;
.card-header-right {
margin-right: 70px;
display: inline-flex;
align-items: center;
gap: 12px;
/* 各个块之间的间距 */
white-space: nowrap;
/* 整个右侧区域不换行 */
span {
color: #0013b9;
}
}
.inline-country {
display: inline-flex;
align-items: center;
gap: 6px;
/* “指定国家” 和 select 的间距 */
}
.country-select {
min-width: 120px;
/* 防止 select 太窄,文字被挤没 */
}
span {
font-family: Source Han Sans SC;
font-weight: 400;
@@ -752,12 +847,7 @@ function timestampToTime(timestamp_ms) {
}
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: #606266;
}
.open-login {
width: 100px;