Files
tkPage/src/views/hosts/workbenches.vue

672 lines
21 KiB
Vue
Raw Normal View History

2025-07-01 21:02:39 +08:00
<template>
2026-01-21 14:02:22 +08:00
<div class="grid grid-cols-1 lg:grid-cols-12 gap-4 mb-4">
2026-01-16 19:00:07 +08:00
<!-- Stat Cards -->
2026-01-21 14:02:22 +08:00
<!-- 总数量 (较小) -->
2026-01-21 15:32:47 +08:00
<div
class="lg:col-span-2 bg-white dark:bg-slate-900 p-4 rounded-xl shadow-sm border border-slate-100 dark:border-slate-800">
2026-01-21 14:02:22 +08:00
<div class="flex items-center justify-between mb-1">
<span class="text-xs font-medium text-slate-500">{{ $t('workbenches.totalnumber') }}</span>
<span class="material-icons-round text-primary/40 text-lg">analytics</span>
2026-01-16 19:00:07 +08:00
</div>
2026-01-21 14:02:22 +08:00
<div class="text-xl font-bold text-slate-900 dark:text-white">{{ hostData.totalCount }}</div>
2026-01-16 19:00:07 +08:00
</div>
2026-01-21 15:32:47 +08:00
2026-01-21 14:02:22 +08:00
<!-- 新建主播 (较小) -->
2026-01-21 15:32:47 +08:00
<div
class="lg:col-span-2 bg-white dark:bg-slate-900 p-4 rounded-xl shadow-sm border border-slate-100 dark:border-slate-800">
2026-01-21 14:02:22 +08:00
<div class="flex items-center justify-between mb-1">
<span class="text-xs font-medium text-slate-500">{{ $t('workbenches.createHost') }}</span>
<span class="material-icons-round text-secondary/40 text-lg">person_add</span>
2026-01-16 19:00:07 +08:00
</div>
2026-01-21 14:02:22 +08:00
<div class="text-xl font-bold text-slate-900 dark:text-white">{{ hostData.validAnchorsCount }}</div>
2026-01-16 19:00:07 +08:00
</div>
2026-01-21 15:32:47 +08:00
2026-01-21 14:02:22 +08:00
<!-- 运行时间 (较大) -->
2026-01-21 15:32:47 +08:00
<div
class="lg:col-span-3 bg-white dark:bg-slate-900 p-5 rounded-xl shadow-sm border border-slate-100 dark:border-slate-800 flex flex-col justify-center">
2026-01-16 19:00:07 +08:00
<div class="flex items-center justify-between">
2026-01-21 15:32:47 +08:00
<!-- <span class="w-4 h-4 rounded-full" :class="1 ? 'bg-red-500' : 'bg-emerald-500'"></span> -->
2026-01-16 19:00:07 +08:00
<div>
<span class="text-xs font-semibold text-slate-400 uppercase tracking-wider block mb-1">{{
$t('workbenches.runTime') }}</span>
<div class="text-2xl font-mono font-bold text-primary">{{ formattedTime }}</div>
</div>
<button @click="openTK"
class="bg-primary hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm font-semibold transition-all shadow-lg shadow-primary/25">
{{ $t('workbenches.openTK') }}
</button>
</div>
</div>
</div>
2026-01-21 15:32:47 +08:00
2026-01-16 19:00:07 +08:00
<!-- Configuration Panel -->
<div
2026-01-20 19:54:12 +08:00
class="bg-white dark:bg-slate-900 rounded-2xl shadow-sm border border-slate-100 dark:border-slate-800 overflow-hidden">
2026-01-16 19:00:07 +08:00
<div class="p-6 border-b border-slate-100 dark:border-slate-800 flex justify-between items-center">
<div class="flex items-center gap-3">
<div class="w-8 h-8 bg-slate-100 dark:bg-slate-800 rounded-lg flex items-center justify-center">
<span class="material-icons-round text-slate-600 dark:text-slate-400 text-lg">settings</span>
</div>
<h2 class="font-bold text-slate-800 dark:text-white">{{ $t('workbenchesSetup.workbenches') }}</h2>
</div>
<div class="flex items-center gap-4 text-sm">
<div class="text-slate-500">{{ $t('workbenchesSetup.network') }}: <span class="text-primary font-bold">{{ locale
== 'zh' ? countryData : countryDataEN }}</span></div>
<div class="flex items-center gap-2">
<span class="text-slate-500">指定国家:</span>
<select v-model="country_info"
class="bg-slate-50 dark:bg-slate-800 border-none rounded-lg text-xs font-medium focus:ring-0">
<option value="全部">全部</option>
<option v-for="(item, index) in country_Lst" :key="index" :value="item">{{ item }}</option>
</select>
</div>
</div>
</div>
<div class="p-6">
2026-01-21 15:32:47 +08:00
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6">
2026-01-16 19:00:07 +08:00
<!-- Coins -->
<div>
<h4 class="text-sm font-bold text-slate-800 dark:text-white mb-4 flex items-center gap-2">
<span class="w-1 h-4 bg-primary rounded-full"></span>
{{ $t('workbenchesSetup.setCoinsNum') }}
</h4>
<div class="space-y-3">
<div class="flex shadow-sm rounded-lg overflow-hidden border border-slate-200 dark:border-slate-700">
<span
class="bg-slate-50 dark:bg-slate-800 px-3 py-2 text-xs font-medium text-slate-500 w-28 flex items-center border-r border-slate-200 dark:border-slate-700">{{
$t('workbenchesSetup.minCoinsNum') }}</span>
<input
class="flex-1 px-4 py-2 text-sm bg-white dark:bg-slate-900 border-none outline-none focus:ring-0 disabled:bg-slate-100"
type="number" v-model="pyData.gold.min" :disabled="!pyData.isStart" />
2025-07-01 21:02:39 +08:00
</div>
2026-01-16 19:00:07 +08:00
<div class="flex shadow-sm rounded-lg overflow-hidden border border-slate-200 dark:border-slate-700">
<span
class="bg-slate-50 dark:bg-slate-800 px-3 py-2 text-xs font-medium text-slate-500 w-28 flex items-center border-r border-slate-200 dark:border-slate-700">{{
$t('workbenchesSetup.maxCoinsNum') }}</span>
<input
class="flex-1 px-4 py-2 text-sm bg-white dark:bg-slate-900 border-none outline-none focus:ring-0 disabled:bg-slate-100"
type="number" v-model="pyData.gold.max" :disabled="!pyData.isStart" />
2025-07-01 21:02:39 +08:00
</div>
2026-01-16 19:00:07 +08:00
</div>
</div>
2025-07-01 21:02:39 +08:00
2026-01-16 19:00:07 +08:00
<!-- Fans -->
<div>
<h4 class="text-sm font-bold text-slate-800 dark:text-white mb-4 flex items-center gap-2">
<span class="w-1 h-4 bg-secondary rounded-full"></span>
{{ $t('workbenchesSetup.setFansNum') }}
</h4>
<div class="space-y-3">
<div class="flex shadow-sm rounded-lg overflow-hidden border border-slate-200 dark:border-slate-700">
<span
class="bg-slate-50 dark:bg-slate-800 px-3 py-2 text-xs font-medium text-slate-500 w-28 flex items-center border-r border-slate-200 dark:border-slate-700">{{
$t('workbenchesSetup.minFansNum') }}</span>
<input
class="flex-1 px-4 py-2 text-sm bg-white dark:bg-slate-900 border-none outline-none focus:ring-0 disabled:bg-slate-100"
type="number" v-model="pyData.fans.min" :disabled="!pyData.isStart" />
</div>
<div class="flex shadow-sm rounded-lg overflow-hidden border border-slate-200 dark:border-slate-700">
<span
class="bg-slate-50 dark:bg-slate-800 px-3 py-2 text-xs font-medium text-slate-500 w-28 flex items-center border-r border-slate-200 dark:border-slate-700">{{
$t('workbenchesSetup.maxFansNum') }}</span>
<input
class="flex-1 px-4 py-2 text-sm bg-white dark:bg-slate-900 border-none outline-none focus:ring-0 disabled:bg-slate-100"
type="number" v-model="pyData.fans.max" :disabled="!pyData.isStart" />
2025-07-01 21:02:39 +08:00
</div>
2026-01-16 19:00:07 +08:00
</div>
2025-07-01 21:02:39 +08:00
</div>
2026-01-16 19:00:07 +08:00
2025-08-25 15:18:07 +08:00
2026-01-16 19:00:07 +08:00
</div>
2026-01-21 15:32:47 +08:00
2026-01-16 19:00:07 +08:00
<div class="mt-6 text-center">
<button v-if="pyData.isStart" @click="submit"
class="bg-slate-900 dark:bg-primary hover:scale-[1.02] active:scale-[0.98] text-white px-10 py-3 rounded-xl font-bold text-lg shadow-xl shadow-slate-900/10 dark:shadow-primary/20 transition-all flex items-center gap-2 mx-auto">
<span class="material-icons-round">bolt</span>
{{ $t('workbenchesSetup.start') }}
</button>
<button v-else @click="unsubmit"
class="bg-red-500 hover:bg-red-600 hover:scale-[1.02] active:scale-[0.98] text-white px-12 py-4 rounded-xl font-bold text-lg shadow-xl shadow-red-500/20 transition-all flex items-center gap-3 mx-auto">
<span class="material-icons-round">stop</span>
{{ $t('workbenchesSetup.stop') }}
</button>
<p class="mt-4 text-xs font-medium text-emerald-600 dark:text-emerald-400">
到期时间: {{ timestampToTime(expiredTime) }}
</p>
</div>
2025-07-01 21:02:39 +08:00
</div>
2026-01-16 19:00:07 +08:00
</div>
2025-07-01 21:02:39 +08:00
</template>
<script setup>
import { ref, onMounted, computed } from 'vue';
import { usePythonBridge, } from '@/utils/pythonBridge'
import { setNumData, getNumData, getUser, setTkUser, getTkUser } from '@/utils/storage'
import { ElMessage, ElMessageBox } from 'element-plus'
import { getCountryName } from '@/utils/countryUtil'
2025-08-25 15:18:07 +08:00
import { tkaccountuseinfo, getExpiredTime } from '@/api/account'
2025-07-01 21:02:39 +08:00
import { useI18n } from 'vue-i18n'
const { locale } = useI18n()
//导入python交互方法
const { fetchDataConfig, fetchDataCount, loginBackStage, loginTikTok, backStageloginStatus, backStageloginStatusCopy } = usePythonBridge();
//ip国家
let countryData = ref('');
//英文国家
let countryDataEN = ref('');
2025-12-18 20:09:21 +08:00
let country_info = ref('全部');
let country_Lst = ref();
2025-07-01 21:02:39 +08:00
//获取主播数量的定时器
let getHostTimer = ref(null);
//获取查询次数定时器
let getNumTimer = ref(null);
//获取的主播信息
let hostData = ref({
2026-01-16 19:00:07 +08:00
totalCount: 0,
validAnchorsCount: 0,
2026-01-21 15:32:47 +08:00
2025-07-01 21:02:39 +08:00
});
//是否开启tk
// let isTk = ref(true);
//账号是否登陆中
let isLogin = ref([false, false]);
//设置状态轮询定时器
let statusTimer = ref(null);
let statusTimerCopy = ref(null);
//设置次数最大值
let maxCount = ref([
2026-01-16 19:00:07 +08:00
{
hourMax: 50,
dayMax: 300,
},
{
hourMax: 100,
dayMax: 600,
},
2025-07-01 21:02:39 +08:00
]);
//tk账号信息
let tkData = ref([
2026-01-16 19:00:07 +08:00
{
account: '',
password: '',
index: 1,
code: 0,
num: 0
},
{
account: '',
password: '',
index: 2,
code: 0,
num: 0
},
2025-07-01 21:02:39 +08:00
]);
//python需要的数据
let pyData = ref({
2026-01-16 19:00:07 +08:00
gold: { min: 0, max: 0 },
fans: { min: 0, max: 0 },
frequency: { hour: 0, day: 0 },
isStart: true,
country: countryData.value,
filterSelling: false,
filterGame: false,
rankingList: false,
tenantId: getUser().tenantId,
userId: getUser().userId,
2025-07-01 21:02:39 +08:00
});
2025-07-16 21:32:46 +08:00
//是否限制查询数量
let isLimit = ref(false);
2025-07-16 20:57:46 +08:00
//需要查询的主播数
let hostNum = ref(0);
2025-07-16 21:32:46 +08:00
2025-07-01 21:02:39 +08:00
//按钮提交状态
let submitting = ref(true);
2025-08-25 15:18:07 +08:00
let expiredTime = ref(null);
2025-07-01 21:02:39 +08:00
2025-12-18 20:09:21 +08:00
onMounted(async () => {
2026-01-16 19:00:07 +08:00
//从缓存获取数据
if (getNumData()) {
pyData.value = getNumData();
}
if (getTkUser()) {
tkData.value = getTkUser();
tkData.value[0].code = 0;
tkData.value[1].code = 0;
}
tkaccountuse(tkData.value[0].account, 0)
tkaccountuse(tkData.value[1].account, 1)
getIpInfo()
setTimeout(() => {
getExpiredTime(getUser().tenantId).then((res) => {
console.log('time:', res);
expiredTime.value = res.expiredTime
})
}, 1000);
2025-07-01 21:02:39 +08:00
2026-01-16 19:00:07 +08:00
checkVPN()
setInterval(async () => {
await checkVPN()
}, 1000 * 20)
2025-12-18 20:09:21 +08:00
2025-07-01 21:02:39 +08:00
})
const getIpInfo = async () => {
2026-01-16 19:00:07 +08:00
try {
const response = await fetch('https://ipapi.co/json/');
if (!response.ok) {
throw new Error('请求失败');
}
const data = await response.json();
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('请输入将要获取国家的中文名', '获取国家失败', {
confirmButtonText: '确认',
cancelButtonText: '取消',
showClose: false,
closeOnClickModal: false,
showCancelButton: false,
})
.then(async ({ value }) => {
countryData.value = value
2025-12-18 20:09:21 +08:00
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
2026-01-16 19:00:07 +08:00
})
// .catch(() => {
// ElMessage({
// type: 'info',
// message: 'Input canceled',
// })
// })
}
2025-07-01 21:02:39 +08:00
};
//提交数据到py
const submit = () => {
2026-01-16 19:00:07 +08:00
pyData.value.country = countryData.value;
console.log('提交的区间值:', pyData.value);
// if (tkData.value[0].account == '' && tkData.value[1].account == '') {
// ElMessage.error('请输入账号密码');
// return;
// }
// if (tkData.value[0].password == '' && tkData.value[1].password == '') {
// ElMessage.error('请输入账号密码');
// return;
// }
if (((Number(pyData.value.gold.min) > Number(pyData.value.gold.max)) || (Number(pyData.value.fans.min) > Number(pyData.value.fans.max)))) {
ElMessage.error('请输入正确的区间值');
return;
}
if ((Number(pyData.value.gold.max) <= 0 || Number(pyData.value.fans.max <= 0)) || pyData.value.gold.max == '' || pyData.value.fans.max == '') {
ElMessage.error('请输入正确的区间值');
return;
}
2026-01-21 15:32:47 +08:00
2025-07-16 21:03:06 +08:00
2025-07-16 21:32:46 +08:00
2026-01-16 19:00:07 +08:00
ElMessageBox.confirm(
'确认开始爬取数据?',
'开始',
{
confirmButtonText: '开始',
cancelButtonText: '取消',
type: 'success',
}
)
.then(() => {
// console.log('提交的区间值:', pyData.value.gold, pyData.value.fans, pyData.value.frequency);
//开始按钮的状态 改为禁用
submitting.value = true;
setNumData(pyData.value);
console.error('提交的区间值:', JSON.stringify(pyData.value));
fetchDataConfig(JSON.stringify({
2025-07-01 21:02:39 +08:00
gold: pyData.value.gold,
fans: pyData.value.fans,
frequency: pyData.value.frequency,
2026-01-16 19:00:07 +08:00
isStart: true,
2025-07-30 13:22:45 +08:00
filterSelling: pyData.value.filterSelling,
filterGame: pyData.value.filterGame,
2026-01-16 19:00:07 +08:00
rankingList: !pyData.value.rankingList,
2025-07-01 21:02:39 +08:00
country: countryData.value,
tenantId: getUser().tenantId,
2025-07-28 15:38:16 +08:00
userId: getUser().id,
2025-12-18 20:09:21 +08:00
crawl_single_nation: country_info.value == '全部' ? '' : country_info.value
2026-01-16 19:00:07 +08:00
})).then((res) => {
//开始计时器
startTimer();
//开启查询次数
getHostTimer.value = setInterval(() => {
fetchDataCount().then((res) => {
hostData.value = JSON.parse(res);
2026-01-21 15:32:47 +08:00
2026-01-16 19:00:07 +08:00
})
}, 1000);
getNumTimer.value = setInterval(() => {
tkaccountuse(tkData.value[0].account, 0)
tkaccountuse(tkData.value[1].account, 1)
}, 5000);
}).finally(() => {
setTimeout(() => {
pyData.value.isStart = false;
submitting.value = false;
}, 2000)
2025-12-18 20:09:21 +08:00
2026-01-16 19:00:07 +08:00
})
2025-07-01 21:02:39 +08:00
})
2026-01-16 19:00:07 +08:00
.catch(() => {
})
};
//停止
const unsubmit = () => {
fetchDataConfig(JSON.stringify({
gold: pyData.value.gold,
fans: pyData.value.fans,
frequency: pyData.value.frequency,
isStart: false,
filterSelling: pyData.value.filterSelling,
filterGame: pyData.value.filterGame,
rankingList: !pyData.value.rankingList,
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;
clearInterval(getHostTimer.value);
getHostTimer.value = null;
clearInterval(getNumTimer.value);
getNumTimer.value = null;
// ElMessage.sussec('已停止')
}).catch((err) => {
// ElMessage.error('停止失败')
})
2025-07-01 21:02:39 +08:00
};
//重置
const reset = () => {
2026-01-16 19:00:07 +08:00
pyData.value.gold = { min: 0, max: 0 };
pyData.value.fans = { min: 0, max: 0 };
pyData.value.frequency = { hour: 0, day: 0 };
2025-07-01 21:02:39 +08:00
};
2026-01-16 20:12:21 +08:00
// 切换过滤选项 (用于Electron环境下的即时响应)
const toggleFilter = (filterName) => {
if (!pyData.value.isStart) return; // 如果已启动则不允许修改
pyData.value[filterName] = !pyData.value[filterName];
2026-01-21 14:02:22 +08:00
console.log(pyData.value)
2026-01-16 20:12:21 +08:00
};
2025-07-01 21:02:39 +08:00
const loginTK = (index) => {
2026-01-16 19:00:07 +08:00
setTkUser(tkData.value)
loginBackStage({
account: tkData.value[index].account,
password: tkData.value[index].password,
index: index
})
if (index == 0) {
isLogin.value[1] = true;
statusTimer = setInterval(() => {
getloginStatus();
}, 2000)
} else if (index == 1) {
isLogin.value[0] = true;
statusTimerCopy = setInterval(() => {
getloginStatusCopy();
}, 2000)
}
2025-07-01 21:02:39 +08:00
}
const openTK = () => {
2026-01-16 19:00:07 +08:00
// isTk.value = true;
// console.log(isTk.value)
loginTikTok();
2025-07-01 21:02:39 +08:00
}
function getloginStatus() {
2026-01-16 19:00:07 +08:00
backStageloginStatus().then((res) => {
const data = JSON.parse(res);
tkData.value[data.index].code = data.code
if (data.code == 1) {
clearInterval(statusTimer);
statusTimer = null;
submitting.value = false
isLogin.value[1] = false;
}
})
2025-07-01 21:02:39 +08:00
}
function getloginStatusCopy() {
2026-01-16 19:00:07 +08:00
backStageloginStatusCopy().then((res) => {
const data = JSON.parse(res);
tkData.value[data.index].code = data.code
if (data.code == 1) {
clearInterval(statusTimer);
statusTimer = null;
submitting.value = false
isLogin.value[0] = false;
}
})
2025-07-01 21:02:39 +08:00
}
function tkaccountuse(id, index) {
2026-01-16 19:00:07 +08:00
let num = 0;
console.log(id, index, "查询次数")
if (!id || id == '') {
return
}
tkaccountuseinfo(id).then((res) => {
console.log("查询返回", res)
num = res
tkData.value[index].num = num
setTkUser(tkData.value)
console.log('账号使用次数', tkData.value[index].num)
// ElMessage.error('账号使用次数', tkData.value[index].num);
}).catch((err) => {
console.log('账号使用次数', err)
})
2026-01-21 15:32:47 +08:00
2025-07-01 21:02:39 +08:00
}
const isRunning = ref(false);
const totalSeconds = ref(0);
//定时器
let timerCrawl = null;
const startTimedata = ref(null);
//清空时间 并开始运行
const startTimer = () => {
2026-01-16 19:00:07 +08:00
resetTimer();
if (isRunning.value) return;
isRunning.value = true;
startTimedata.value = Date.now();
timerCrawl = setInterval(() => {
totalSeconds.value = Math.floor((Date.now() - startTimedata.value) / 1000);
}, 1000);
2025-07-01 21:02:39 +08:00
};
//结束运行 暂停
const pauseTimer = () => {
2026-01-16 19:00:07 +08:00
isRunning.value = false;
clearInterval(timerCrawl);
2025-07-01 21:02:39 +08:00
};
//清空时间
const resetTimer = () => {
2026-01-16 19:00:07 +08:00
isRunning.value = false;
clearInterval(timerCrawl);
totalSeconds.value = 0;
2025-07-01 21:02:39 +08:00
};
// 格式化时间为 HH:MM:SS
const formattedTime = computed(() => {
2026-01-16 19:00:07 +08:00
const hours = Math.floor(totalSeconds.value / 3600);
const minutes = Math.floor((totalSeconds.value % 3600) / 60);
const seconds = totalSeconds.value % 60;
return [
hours.toString().padStart(2, '0'),
minutes.toString().padStart(2, '0'),
seconds.toString().padStart(2, '0')
].join(':');
2025-07-01 21:02:39 +08:00
});
function handleInputHour(value) {
2026-01-16 19:00:07 +08:00
console.log(value)
// 替换非数字字符为空字符串
let num = value.replace(/[^\d]/g, '');
// 如果值小于等于0则设置为0
if (Number(num) <= 0) {
num = 0;
}
if ((tkData.value[0].code == 1) && (tkData.value[1].code == 1)) {
if (Number(num) > maxCount.value[1].hourMax) {
num = maxCount.value[1].hourMax;
2025-07-01 21:02:39 +08:00
}
2026-01-16 19:00:07 +08:00
} else if ((tkData.value[0].code == 1) || (tkData.value[1].code == 1)) {
// 如果值大于最大值,则设置为最大值
if (Number(num) > maxCount.value[0].hourMax) {
num = maxCount.value[0].hourMax;
2025-07-01 21:02:39 +08:00
}
2026-01-16 19:00:07 +08:00
} else {
ElMessage.error('请先登录tk后台');
num = 0;
}
// 更新模型
pyData.value.frequency.hour = num;
2025-07-01 21:02:39 +08:00
}
function handleInputDay(value) {
2026-01-16 19:00:07 +08:00
console.log(value)
// 替换非数字字符为空字符串
let num = value.replace(/[^\d]/g, '');
// 如果值小于等于0则设置为0
if (Number(num) <= 0) {
num = 0;
}
if ((tkData.value[0].code == 1) && (tkData.value[1].code == 1)) {
if (Number(num) > maxCount.value[1].dayMax) {
num = maxCount.value[1].dayMax;
2025-07-01 21:02:39 +08:00
}
2026-01-16 19:00:07 +08:00
} else if ((tkData.value[0].code == 1) || (tkData.value[1].code == 1)) {
// 如果值大于最大值,则设置为最大值
if (Number(num) > maxCount.value[0].dayMax) {
num = maxCount.value[0].dayMax;
2025-07-01 21:02:39 +08:00
}
2026-01-16 19:00:07 +08:00
} else {
ElMessage.error('请先登录tk后台');
num = 0;
}
2025-07-01 21:02:39 +08:00
2026-01-16 19:00:07 +08:00
// 更新模型
pyData.value.frequency.day = num;
2025-07-01 21:02:39 +08:00
}
2025-08-25 15:18:07 +08:00
function timestampToTime(timestamp_ms) {
2026-01-16 19:00:07 +08:00
const date = new Date(timestamp_ms);
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
const seconds = date.getSeconds().toString().padStart(2, '0');
const milliseconds = date.getMilliseconds().toString().padStart(3, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
2025-08-25 15:18:07 +08:00
}
2025-12-18 20:09:21 +08:00
let isWifi = ref(false);
const checkVPN = async () => {
2026-01-16 19:00:07 +08:00
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;
2025-12-18 20:09:21 +08:00
}
2026-01-16 19:00:07 +08:00
} catch (error) {
// 捕获超时错误或其他错误
ElMessage.error('VPN连接失败无法访问网络。');
isWifi.value = true;
}
2025-12-18 20:09:21 +08:00
};
2025-07-01 21:02:39 +08:00
</script>
2026-01-16 19:00:07 +08:00
<style scoped>
/*
Most styles are replaced by Tailwind utility classes.
We can keep specific overrides or custom animations here if needed.
*/
2026-01-21 14:02:22 +08:00
2026-01-21 15:32:47 +08:00
.text-size {
text-size: 50px !important;
2026-01-21 14:02:22 +08:00
}
2025-07-01 21:02:39 +08:00
</style>