令牌下线提示

This commit is contained in:
2026-03-30 09:53:08 +08:00
parent b81a0377b8
commit 466a853905
5 changed files with 539 additions and 127 deletions

View File

@@ -69,6 +69,7 @@ onMounted(() => {
}).catch(() => {
document.title = 'Yolo终端'
})
console.log('[App]', !isDev, isElectronEnv, !updateReady.value)
// Check Login
try {
@@ -156,7 +157,7 @@ const startHealthCheck = () => {
try {
const result = await window.electronAPI.checkHealth()
if (result.success && result.code === 40400) {
alert('当前账号已在其他地方登录,请重新登录')
alert(result.message)
localStorage.removeItem(USER_KEY)
// 隐藏所有 BrowserView 并停止自动化,防止视图悬浮在登录页上方
try {

View File

@@ -226,3 +226,12 @@ export function resendEmail(data) {
export function logout(data) {
return postAxios({ url: 'user/logout', data })
}
// 获取商品列表
export function getPkItemList(data) {
return getAxios({ url: 'pkItem/list', params: data })
}
// 购买商品
export function buyPkItem(data) {
return postAxios({ url: 'pkItem/buy', data })
}

View File

@@ -6,6 +6,7 @@
<div class="points-text">
我的积分: <span class="points-num">{{ currentUser.points || 0 }}</span>
</div>
<button class="exchange-btn" @click="openExchangeDialog">积分兑换</button>
</div>
<div class="points-list" v-if="pointsList.length > 0">
@@ -18,14 +19,51 @@
</div>
</div>
<div class="empty-tip" v-else>您还没有积分记录</div>
<!-- 积分兑换弹窗 -->
<div class="exchange-dialog" v-if="exchangeDialogVisible">
<div class="dialog-overlay" @click="closeExchangeDialog"></div>
<div class="dialog-content">
<div class="dialog-header">
<div class="dialog-title">积分兑换</div>
<div class="close-btn" @click="closeExchangeDialog">×</div>
</div>
<div class="dialog-body">
<div class="user-info">
我的积分: <span class="points-num">{{ currentUser.points || 0 }}</span>
</div>
<div class="item-list" v-if="itemList.length > 0">
<div class="item-card" v-for="item in itemList" :key="item.id">
<div class="item-info">
<div class="item-header">
<div class="item-name">{{ item.itemName }}</div>
<div class="item-price">
<span class="price-tag">积分</span>
<span class="price-num">{{ item.itemPrice }}</span>
</div>
</div>
<div class="item-desc">{{ item.itemDesc }}</div>
<button class="exchange-btn" @click="exchangeItem(item)"
:disabled="(currentUser.points || 0) < item.itemPrice">
{{ (currentUser.points || 0) < item.itemPrice ? '积分不足' : '立即兑换' }} </button>
</div>
</div>
</div>
<div class="empty-tip" v-else-if="!loading">暂无商品</div>
<div class="loading-tip" v-else>加载中...</div>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { getIntegralDetail } from '@/api/pk-mini'
import { getIntegralDetail, getPkItemList, buyPkItem } from '@/api/pk-mini'
import { getMainUserData } from '@/utils/pk-mini/storage'
import { TimestamptolocalTime } from '@/utils/pk-mini/timeConversion'
import { ElMessage } from 'element-plus'
import { getCurrent } from '@/api/account'
function getUserId(user) {
return user?.id || user?.userId || user?.uid || null
@@ -36,6 +74,66 @@ const pointsList = ref([])
const page = ref(0)
const formatTime = TimestamptolocalTime
// 弹窗状态
const exchangeDialogVisible = ref(false)
const itemList = ref([])
const loading = ref(false)
// 打开积分兑换弹窗
const openExchangeDialog = async () => {
exchangeDialogVisible.value = true
await loadItemList()
}
// 关闭积分兑换弹窗
const closeExchangeDialog = () => {
exchangeDialogVisible.value = false
}
// 加载商品列表
const loadItemList = async () => {
try {
loading.value = true
const res = await getPkItemList({})
if (res && res.length > 0) {
itemList.value = res
}
} catch (e) {
console.error('加载商品列表失败', e)
ElMessage.error('加载商品列表失败')
} finally {
loading.value = false
}
}
// 兑换商品
const exchangeItem = async (item) => {
const userPoints = currentUser.value.points || 0
if (userPoints < item.itemPrice) {
ElMessage.warning('积分不足')
return
}
try {
// 调用兑换接口
const res = await buyPkItem({ itemId: item.id })
if (res) {
ElMessage.success(`兑换 ${item.itemName} 成功`)
// 重新获取用户信息,更新积分
const userRes = await getCurrent()
if (userRes) {
currentUser.value = userRes
}
closeExchangeDialog()
} else {
ElMessage.error('兑换失败,请稍后重试')
}
} catch (e) {
console.error('兑换商品失败', e)
ElMessage.error('兑换失败,请稍后重试')
}
}
async function loadPointsList() {
const userId = getUserId(currentUser.value)
if (!userId) return
@@ -54,8 +152,22 @@ async function loadPointsList() {
}
}
onMounted(() => {
onMounted(async () => {
try {
// 获取最新的用户信息,包括积分
const res = await getCurrent()
if (res) {
currentUser.value = res
} else {
// 如果获取失败,使用缓存中的数据
currentUser.value = getMainUserData() || {}
}
} catch (e) {
console.error('获取用户信息失败', e)
// 出错时使用缓存中的数据
currentUser.value = getMainUserData() || {}
}
const userId = getUserId(currentUser.value)
if (userId) {
loadPointsList()
@@ -73,8 +185,27 @@ onMounted(() => {
width: 100%;
height: 70px;
display: flex;
justify-content: center;
justify-content: space-between;
align-items: center;
padding: 0 20px;
background: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
.exchange-btn {
padding: 8px 16px;
background: #ff6b35;
color: #fff;
border: none;
border-radius: 20px;
font-size: 14px;
font-weight: bold;
cursor: pointer;
transition: background 0.3s ease;
&:hover {
background: #ff5216;
}
}
}
.points-icon {
@@ -148,4 +279,181 @@ onMounted(() => {
font-size: 18px;
color: #03aba8;
}
/* 积分兑换弹窗样式 */
.exchange-dialog {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
.dialog-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
}
.dialog-content {
position: relative;
width: 90%;
max-width: 800px;
max-height: 80vh;
background: #fff;
border-radius: 10px;
overflow: hidden;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
.dialog-header {
height: 60px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
border-bottom: 1px solid #eee;
.dialog-title {
font-size: 18px;
font-weight: bold;
color: #333;
}
.close-btn {
font-size: 24px;
color: #999;
cursor: pointer;
transition: color 0.3s ease;
&:hover {
color: #333;
}
}
}
.dialog-body {
padding: 20px;
max-height: calc(80vh - 60px);
overflow: auto;
.user-info {
font-size: 16px;
color: #666;
margin-bottom: 20px;
.points-num {
font-weight: bold;
color: #ff6b35;
margin-left: 5px;
}
}
.item-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 15px;
}
.item-card {
background: #f9f9f9;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
transition: transform 0.3s ease;
&:hover {
transform: translateY(-3px);
}
.item-info {
padding: 15px;
.item-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
.item-name {
font-size: 16px;
font-weight: bold;
color: #333;
flex: 1;
margin-right: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.item-price {
display: flex;
align-items: center;
.price-tag {
font-size: 12px;
color: #ff6b35;
background: rgba(255, 107, 53, 0.1);
padding: 3px 8px;
border-radius: 4px;
margin-right: 8px;
}
.price-num {
font-size: 18px;
font-weight: bold;
color: #ff6b35;
}
}
}
.item-desc {
font-size: 14px;
color: #666;
margin-bottom: 15px;
line-height: 1.4;
min-height: 40px;
}
.exchange-btn {
width: 100%;
height: 32px;
background: #ff6b35;
color: #fff;
border: none;
border-radius: 16px;
font-size: 12px;
font-weight: bold;
cursor: pointer;
transition: background 0.3s ease;
&:hover:not(:disabled) {
background: #ff5216;
}
&:disabled {
background: #ccc;
cursor: not-allowed;
}
}
}
}
.empty-tip,
.loading-tip {
height: 200px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
color: #999;
}
}
}
}
</style>

View File

@@ -1,7 +1,8 @@
<template>
<div class="flex h-screen w-screen overflow-hidden bg-white">
<!-- Left Navigation Sidebar -->
<div ref="sidebarRef" class="flex flex-col items-center py-4 border-r z-50" style="flex: 0 0 calc(100vw * 2 / 19); min-width: 96px; max-width: 400px; background-color: #F8F9FA;">
<div ref="sidebarRef" class="flex flex-col items-center py-4 border-r z-50"
style="flex: 0 0 calc(100vw * 2 / 19); min-width: 96px; max-width: 400px; background-color: #F8F9FA;">
<div class="mb-6" style="border-bottom: 1px solid #A0AEC023; padding: 10%;">
<!-- Logo or Brand -->
<div class="">
@@ -13,8 +14,7 @@
<!-- TK Workbench Tab -->
<button @click="currentView = 'tk'"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
style="height: 6vh;"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
:class="currentView === 'tk' ? 'bg-white text-blue-600 shadow shadow-blue-900/20' : 'text-slate-400 hover:bg-[rgba(21,96,250,0.06)]'">
<img :src="currentView === 'tk' ? nav11 : nav1" class="w-9 h-9 object-contain flex-shrink-0" />
<span class="text-base font-medium truncate">TK 工作台</span>
@@ -22,8 +22,7 @@
<!-- Hosts List Tab -->
<button @click="currentView = 'hosts'"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
style="height: 6vh;"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
:class="currentView === 'hosts' ? 'bg-white text-blue-600 shadow shadow-blue-900/20' : 'text-slate-400 hover:bg-[rgba(21,96,250,0.06)]'">
<img :src="currentView === 'hosts' ? nav22 : nav2" class="w-9 h-9 object-contain flex-shrink-0" />
<span class="text-base font-medium truncate">主播列表</span>
@@ -31,8 +30,7 @@
<!-- Auto DM Workbench Tab -->
<button @click="currentView = 'auto_dm'"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
style="height: 6vh;"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
:class="currentView === 'auto_dm' ? 'bg-white text-blue-600 shadow shadow-blue-900/20' : 'text-slate-400 hover:bg-[rgba(21,96,250,0.06)]'">
<img :src="currentView === 'auto_dm' ? nav33 : nav3" class="w-9 h-9 object-contain flex-shrink-0" />
<span class="text-base font-medium truncate">自动私信</span>
@@ -40,8 +38,7 @@
<!-- Fan Workbench Tab -->
<button @click="currentView = 'FanWorkbench'"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
style="height: 6vh;"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
:class="currentView === 'FanWorkbench' ? 'bg-white text-blue-600 shadow shadow-blue-900/20' : 'text-slate-400 hover:bg-[rgba(21,96,250,0.06)]'">
<img :src="currentView === 'FanWorkbench' ? nav44 : nav4" class="w-9 h-9 object-contain flex-shrink-0" />
<span class="text-base font-medium truncate">大哥工作台</span>
@@ -49,8 +46,7 @@
<!-- PK 工作台 Tab -->
<button @click="currentView = 'pk_mini'"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
style="height: 6vh;"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
:class="currentView === 'pk_mini' ? 'bg-white text-blue-600 shadow shadow-blue-900/20' : 'text-slate-400 hover:bg-[rgba(21,96,250,0.06)]'">
<img :src="currentView === 'pk_mini' ? nav55 : nav5" class="w-9 h-9 object-contain flex-shrink-0" />
<span class="text-base font-medium truncate">PK 工作台</span>
@@ -58,12 +54,18 @@
<!-- yolo商店 Tab -->
<button @click="currentView = 'shop'"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
style="height: 6vh;"
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
:class="currentView === 'shop' ? 'bg-white text-blue-600 shadow shadow-blue-900/20' : 'text-slate-400 hover:bg-[rgba(21,96,250,0.06)]'">
<img :src="currentView === 'shop' ? nav66 : nav6" class="w-9 h-9 object-contain flex-shrink-0" />
<span class="text-base font-medium truncate">TK商店</span>
</button>
<!-- 尽请期待 Tab -->
<button class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
style="height: 6vh; :disabled"
:class="currentView === 'test' ? 'bg-white text-blue-600 shadow shadow-blue-900/20' : 'text-slate-400 hover:bg-[rgba(21,96,250,0.06)]'">
<span class="text-base font-medium truncate">尽请期待...</span>
</button>
</div>
<div class="mt-auto w-full px-2">
@@ -81,65 +83,38 @@
<!-- Tab 1: Auto DM Workbench (Config + Browser) - webAi 权限 -->
<div v-show="currentView === 'auto_dm'" class="absolute inset-0 z-10 h-full w-full">
<PermissionMask
permission-key="webAi"
title="自动私信工作台未开通"
description="您当前没有使用自动私信功能的权限"
:placeholder-image="placeholderWebAi"
:contacts="serviceContacts"
>
<PermissionMask permission-key="webAi" title="自动私信工作台未开通" description="您当前没有使用自动私信功能的权限"
:placeholder-image="placeholderWebAi" :contacts="serviceContacts">
<div v-if="autoDmMode === 'config'" class="h-full w-full bg-slate-50 overflow-auto">
<ConfigPage
@go-to-browser="handleGoToBrowser"
@logout="$emit('logout')"
/>
<ConfigPage @go-to-browser="handleGoToBrowser" @logout="$emit('logout')" />
</div>
<div v-show="autoDmMode === 'browser'" class="h-full w-full">
<YoloBrowser
v-bind="$attrs"
:nav-sidebar-width="navSidebarWidth"
@go-back="handleBackToConfig"
@stop-all="handleStopAll"
/>
<YoloBrowser v-bind="$attrs" :nav-sidebar-width="navSidebarWidth" @go-back="handleBackToConfig"
@stop-all="handleStopAll" />
</div>
</PermissionMask>
</div>
<!-- Tab 2: TK Workbench - crawl 权限 -->
<div v-show="currentView === 'tk'" class="absolute inset-0 z-20 bg-gray-50 h-full overflow-hidden">
<PermissionMask
permission-key="crawl"
title="TK工作台未开通"
description="您当前没有使用TK工作台功能的权限"
:placeholder-image="placeholderTk"
:contacts="serviceContacts"
>
<TkWorkbenches />
<PermissionMask permission-key="crawl" title="TK工作台未开通" description="您当前没有使用TK工作台功能的权限"
:placeholder-image="placeholderTk" :contacts="serviceContacts">
<TkWorkbenches :key="tkWorkbenchKey" />
</PermissionMask>
</div>
<!-- Tab 3: Hosts List - crawl 权限 -->
<div v-show="currentView === 'hosts'" class="absolute inset-0 z-20 bg-gray-50 h-full overflow-hidden">
<PermissionMask
permission-key="crawl"
title="主播列表未开通"
description="您当前没有使用主播列表功能的权限"
:placeholder-image="placeholderHosts"
:contacts="serviceContacts"
>
<PermissionMask permission-key="crawl" title="主播列表未开通" description="您当前没有使用主播列表功能的权限"
:placeholder-image="placeholderHosts" :contacts="serviceContacts">
<HostsList />
</PermissionMask>
</div>
<!-- Tab 4: Fan Workbench - bigBrother 权限 -->
<div v-show="currentView === 'FanWorkbench'" class="absolute inset-0 z-20 bg-gray-50 h-full overflow-hidden">
<PermissionMask
permission-key="bigBrother"
title="大哥工作台未开通"
description="您当前没有使用大哥工作台功能的权限"
:placeholder-image="placeholderBigBrother"
:contacts="serviceContacts"
>
<PermissionMask permission-key="bigBrother" title="大哥工作台未开通" description="您当前没有使用大哥工作台功能的权限"
:placeholder-image="placeholderBigBrother" :contacts="serviceContacts">
<FanWorkbench />
</PermissionMask>
</div>
@@ -151,16 +126,13 @@
<!-- Tab 6: yolo商店 - Electron BrowserViewWeb iframe 兜底 -->
<div v-show="currentView === 'shop'" class="absolute inset-0 z-20 h-full overflow-hidden">
<div v-if="isElectron()" class="w-full h-full flex items-center justify-center text-base text-slate-500 bg-white">
<div v-if="isElectron()"
class="w-full h-full flex items-center justify-center text-base text-slate-500 bg-white">
正在进入商店...
</div>
<iframe
v-else-if="adminLoaded"
:src="shopUrl"
class="w-full h-full border-0"
<iframe v-else-if="adminLoaded" :src="shopUrl" class="w-full h-full border-0"
allow="clipboard-read; clipboard-write"
sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-downloads"
></iframe>
sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-downloads"></iframe>
</div>
</div>
</div>
@@ -210,6 +182,16 @@ const shopOpened = ref(false) // Electron 只首开加载一次
const shopUrl = ENV.SHOP_URL
const sidebarRef = useTemplateRef('sidebarRef')
const navSidebarWidth = ref(200) // 左侧导航菜单的实际宽度px传给 YoloBrowser/Sidebar 使用
const tkWorkbenchKey = ref(0) // 用于触发 TK 工作台重新加载
// 重新加载 TK 工作台
const reloadTkWorkbench = () => {
tkWorkbenchKey.value++
console.log('TK 工作台已重新加载')
}
// 将重新加载 TK 工作台的方法挂载到 window 对象
window.reloadTkWorkbench = reloadTkWorkbench
// 客服名片
const serviceContacts = ref([])
@@ -343,6 +325,3 @@ watch(autoDmMode, async (newVal) => {
width: 70%;
}
</style>

View File

@@ -276,16 +276,23 @@
</div>
<div class="mt-6 text-center">
<div class="flex flex-col md:flex-row gap-4 justify-center items-center">
<button v-if="pyData.isStart" @click="submit"
class="bg-slate-900 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 transition-all flex items-center gap-2 mx-auto">
class="bg-slate-900 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 transition-all flex items-center gap-2">
<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">
class="bg-red-500 hover:bg-red-600 hover:scale-[1.02] active:scale-[0.98] text-white px-12 py-3 rounded-xl font-bold text-lg shadow-xl shadow-red-500/20 transition-all flex items-center gap-3">
<span class="material-icons-round">stop</span>
{{ $t('workbenchesSetup.stop') }}
</button>
<button @click="resetTask"
class="bg-amber-500 hover:bg-amber-600 hover:scale-[1.02] active:scale-[0.98] text-white px-10 py-3 rounded-xl font-bold text-lg shadow-xl shadow-amber-500/20 transition-all flex items-center gap-2">
<span class="material-icons-round">refresh</span>
重置任务
</button>
</div>
<p class="mt-4 text-xs font-medium text-emerald-600">
到期时间: {{ timestampToTime(expiredTime) }}
</p>
@@ -297,7 +304,8 @@
</template>
<script setup>
import { ref, onMounted, computed } from 'vue';
import { ref, onMounted, computed, onUnmounted } from 'vue';
import { useRouter } from 'vue-router';
import { usePythonBridge, } from '@/utils/pythonBridge'
import { setNumData, getNumData, getUser, setTkUser, getTkUser } from '@/utils/storage'
import { ElMessage, ElMessageBox } from 'element-plus'
@@ -306,6 +314,24 @@ import { tkaccountuseinfo, getExpiredTime } from '@/api/account'
import { useI18n } from 'vue-i18n'
import { useCountryInfo } from '@/composables/useCountryInfo'
// 获取路由实例
const router = useRouter();
// 重启 Python 服务的方法
const restartPythonService = async () => {
return new Promise((resolve, reject) => {
if (window.electronAPI && window.electronAPI.restartPythonService) {
window.electronAPI.restartPythonService().then(result => {
resolve(result)
}).catch(err => {
reject(err)
})
} else {
reject(new Error('重启 Python 服务的方法不可用'))
}
})
}
const { t, locale } = useI18n()
// 使用独立的国家信息管理(不与其他页面共享)
const {
@@ -602,6 +628,44 @@ const toggleFilter = (filterName) => {
pyData.value[filterName] = !pyData.value[filterName];
};
// 重置任务 - 重启 Python 服务
const resetTask = async () => {
try {
ElMessageBox.confirm(
'确定要重置任务吗?这将重启 Python 服务并重新加载工作台数据,可能会中断当前正在进行的操作。',
'重置任务',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).then(async () => {
ElMessage.info('正在重启 Python 服务...');
const result = await restartPythonService();
await restartPythonService();
if (result.success) {
ElMessage.success('Python 服务已重启,正在重新加载工作台页面...');
// 重新加载 TK 工作台页面(相当于重新进入 tk 工作台)
setTimeout(() => {
// 调用 window.reloadTkWorkbench() 方法触发 TK 工作台重新加载
if (window.reloadTkWorkbench) {
window.reloadTkWorkbench();
}
}, 1000);
} else {
ElMessage.error(`重启失败: ${result.error}`);
}
}).catch(() => {
// 用户取消
});
} catch (error) {
console.error('重置任务失败:', error);
ElMessage.error('重置任务失败,请稍后重试');
}
};
const loginTK = (index) => {
setTkUser(tkData.value)
@@ -639,6 +703,11 @@ const openTK = () => {
const checkTkLoginStatus = () => {
getTkLoginStatus().then((res) => {
isTkLoggedIn.value = res === true || res === 'true';
if (isTkLoggedIn.value) {
clearInterval(tkStatusTimer.value);
tkStatusTimer.value = null;
}
}).catch(() => {
isTkLoggedIn.value = false;
});
@@ -746,6 +815,52 @@ const formattedTime = computed(() => {
].join(':');
});
// 清理所有定时器
const clearAllTimers = () => {
// 清理获取主播数量的定时器
if (getHostTimer.value) {
clearInterval(getHostTimer.value);
getHostTimer.value = null;
}
// 清理获取查询次数的定时器
if (getNumTimer.value) {
clearInterval(getNumTimer.value);
getNumTimer.value = null;
}
// 清理 TK 状态轮询定时器
if (tkStatusTimer.value) {
clearInterval(tkStatusTimer.value);
tkStatusTimer.value = null;
}
// 清理设置状态轮询定时器
if (statusTimer) {
clearInterval(statusTimer);
statusTimer = null;
}
// 清理设置状态轮询定时器(副本)
if (statusTimerCopy) {
clearInterval(statusTimerCopy);
statusTimerCopy = null;
}
// 清理运行时间的定时器
if (timerCrawl) {
clearInterval(timerCrawl);
timerCrawl = null;
}
console.log('所有定时器已清理');
};
// 在组件卸载时清理定时器
onUnmounted(() => {
clearAllTimers();
});
function timestampToTime(timestamp_ms) {
const date = new Date(timestamp_ms);
const year = date.getFullYear();