令牌下线提示
This commit is contained in:
@@ -69,6 +69,7 @@ onMounted(() => {
|
|||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
document.title = 'Yolo终端'
|
document.title = 'Yolo终端'
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('[App]', !isDev, isElectronEnv, !updateReady.value)
|
console.log('[App]', !isDev, isElectronEnv, !updateReady.value)
|
||||||
// Check Login
|
// Check Login
|
||||||
try {
|
try {
|
||||||
@@ -156,7 +157,7 @@ const startHealthCheck = () => {
|
|||||||
try {
|
try {
|
||||||
const result = await window.electronAPI.checkHealth()
|
const result = await window.electronAPI.checkHealth()
|
||||||
if (result.success && result.code === 40400) {
|
if (result.success && result.code === 40400) {
|
||||||
alert('当前账号已在其他地方登录,请重新登录')
|
alert(result.message)
|
||||||
localStorage.removeItem(USER_KEY)
|
localStorage.removeItem(USER_KEY)
|
||||||
// 隐藏所有 BrowserView 并停止自动化,防止视图悬浮在登录页上方
|
// 隐藏所有 BrowserView 并停止自动化,防止视图悬浮在登录页上方
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -226,3 +226,12 @@ export function resendEmail(data) {
|
|||||||
export function logout(data) {
|
export function logout(data) {
|
||||||
return postAxios({ url: 'user/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 })
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
<div class="points-text">
|
<div class="points-text">
|
||||||
我的积分: <span class="points-num">{{ currentUser.points || 0 }}</span>
|
我的积分: <span class="points-num">{{ currentUser.points || 0 }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<button class="exchange-btn" @click="openExchangeDialog">积分兑换</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="points-list" v-if="pointsList.length > 0">
|
<div class="points-list" v-if="pointsList.length > 0">
|
||||||
@@ -18,14 +19,51 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="empty-tip" v-else>您还没有积分记录!</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue'
|
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 { getMainUserData } from '@/utils/pk-mini/storage'
|
||||||
import { TimestamptolocalTime } from '@/utils/pk-mini/timeConversion'
|
import { TimestamptolocalTime } from '@/utils/pk-mini/timeConversion'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { getCurrent } from '@/api/account'
|
||||||
|
|
||||||
function getUserId(user) {
|
function getUserId(user) {
|
||||||
return user?.id || user?.userId || user?.uid || null
|
return user?.id || user?.userId || user?.uid || null
|
||||||
@@ -36,6 +74,66 @@ const pointsList = ref([])
|
|||||||
const page = ref(0)
|
const page = ref(0)
|
||||||
const formatTime = TimestamptolocalTime
|
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() {
|
async function loadPointsList() {
|
||||||
const userId = getUserId(currentUser.value)
|
const userId = getUserId(currentUser.value)
|
||||||
if (!userId) return
|
if (!userId) return
|
||||||
@@ -54,8 +152,22 @@ async function loadPointsList() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
currentUser.value = getMainUserData() || {}
|
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)
|
const userId = getUserId(currentUser.value)
|
||||||
if (userId) {
|
if (userId) {
|
||||||
loadPointsList()
|
loadPointsList()
|
||||||
@@ -73,8 +185,27 @@ onMounted(() => {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: space-between;
|
||||||
align-items: center;
|
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 {
|
.points-icon {
|
||||||
@@ -148,4 +279,181 @@ onMounted(() => {
|
|||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
color: #03aba8;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex h-screen w-screen overflow-hidden bg-white">
|
<div class="flex h-screen w-screen overflow-hidden bg-white">
|
||||||
<!-- Left Navigation Sidebar -->
|
<!-- 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%;">
|
<div class="mb-6" style="border-bottom: 1px solid #A0AEC023; padding: 10%;">
|
||||||
<!-- Logo or Brand -->
|
<!-- Logo or Brand -->
|
||||||
<div class="" >
|
<div class="">
|
||||||
<img :src="yoloIcon" class="yolo-logo" />
|
<img :src="yoloIcon" class="yolo-logo" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -13,8 +14,7 @@
|
|||||||
|
|
||||||
<!-- TK Workbench Tab -->
|
<!-- TK Workbench Tab -->
|
||||||
<button @click="currentView = 'tk'"
|
<button @click="currentView = 'tk'"
|
||||||
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
|
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
|
||||||
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)]'">
|
: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" />
|
<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>
|
<span class="text-base font-medium truncate">TK 工作台</span>
|
||||||
@@ -22,8 +22,7 @@
|
|||||||
|
|
||||||
<!-- Hosts List Tab -->
|
<!-- Hosts List Tab -->
|
||||||
<button @click="currentView = 'hosts'"
|
<button @click="currentView = 'hosts'"
|
||||||
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
|
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
|
||||||
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)]'">
|
: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" />
|
<img :src="currentView === 'hosts' ? nav22 : nav2" class="w-9 h-9 object-contain flex-shrink-0" />
|
||||||
<span class="text-base font-medium truncate">主播列表</span>
|
<span class="text-base font-medium truncate">主播列表</span>
|
||||||
@@ -31,8 +30,7 @@
|
|||||||
|
|
||||||
<!-- Auto DM Workbench Tab -->
|
<!-- Auto DM Workbench Tab -->
|
||||||
<button @click="currentView = 'auto_dm'"
|
<button @click="currentView = 'auto_dm'"
|
||||||
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
|
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
|
||||||
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)]'">
|
: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" />
|
<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>
|
<span class="text-base font-medium truncate">自动私信</span>
|
||||||
@@ -40,8 +38,7 @@
|
|||||||
|
|
||||||
<!-- Fan Workbench Tab -->
|
<!-- Fan Workbench Tab -->
|
||||||
<button @click="currentView = 'FanWorkbench'"
|
<button @click="currentView = 'FanWorkbench'"
|
||||||
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
|
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
|
||||||
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)]'">
|
: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" />
|
<img :src="currentView === 'FanWorkbench' ? nav44 : nav4" class="w-9 h-9 object-contain flex-shrink-0" />
|
||||||
<span class="text-base font-medium truncate">大哥工作台</span>
|
<span class="text-base font-medium truncate">大哥工作台</span>
|
||||||
@@ -49,8 +46,7 @@
|
|||||||
|
|
||||||
<!-- PK 工作台 Tab -->
|
<!-- PK 工作台 Tab -->
|
||||||
<button @click="currentView = 'pk_mini'"
|
<button @click="currentView = 'pk_mini'"
|
||||||
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
|
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
|
||||||
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)]'">
|
: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" />
|
<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>
|
<span class="text-base font-medium truncate">PK 工作台</span>
|
||||||
@@ -58,12 +54,18 @@
|
|||||||
|
|
||||||
<!-- yolo商店 Tab -->
|
<!-- yolo商店 Tab -->
|
||||||
<button @click="currentView = 'shop'"
|
<button @click="currentView = 'shop'"
|
||||||
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200"
|
class="w-full rounded-xl flex items-center gap-2 px-3 py-2.5 transition-all duration-200" style="height: 6vh;"
|
||||||
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)]'">
|
: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" />
|
<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>
|
<span class="text-base font-medium truncate">TK商店</span>
|
||||||
</button>
|
</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>
|
||||||
|
|
||||||
<div class="mt-auto w-full px-2">
|
<div class="mt-auto w-full px-2">
|
||||||
@@ -81,65 +83,38 @@
|
|||||||
|
|
||||||
<!-- Tab 1: Auto DM Workbench (Config + Browser) - webAi 权限 -->
|
<!-- Tab 1: Auto DM Workbench (Config + Browser) - webAi 权限 -->
|
||||||
<div v-show="currentView === 'auto_dm'" class="absolute inset-0 z-10 h-full w-full">
|
<div v-show="currentView === 'auto_dm'" class="absolute inset-0 z-10 h-full w-full">
|
||||||
<PermissionMask
|
<PermissionMask permission-key="webAi" title="自动私信工作台未开通" description="您当前没有使用自动私信功能的权限"
|
||||||
permission-key="webAi"
|
:placeholder-image="placeholderWebAi" :contacts="serviceContacts">
|
||||||
title="自动私信工作台未开通"
|
|
||||||
description="您当前没有使用自动私信功能的权限"
|
|
||||||
:placeholder-image="placeholderWebAi"
|
|
||||||
:contacts="serviceContacts"
|
|
||||||
>
|
|
||||||
<div v-if="autoDmMode === 'config'" class="h-full w-full bg-slate-50 overflow-auto">
|
<div v-if="autoDmMode === 'config'" class="h-full w-full bg-slate-50 overflow-auto">
|
||||||
<ConfigPage
|
<ConfigPage @go-to-browser="handleGoToBrowser" @logout="$emit('logout')" />
|
||||||
@go-to-browser="handleGoToBrowser"
|
|
||||||
@logout="$emit('logout')"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-show="autoDmMode === 'browser'" class="h-full w-full">
|
<div v-show="autoDmMode === 'browser'" class="h-full w-full">
|
||||||
<YoloBrowser
|
<YoloBrowser v-bind="$attrs" :nav-sidebar-width="navSidebarWidth" @go-back="handleBackToConfig"
|
||||||
v-bind="$attrs"
|
@stop-all="handleStopAll" />
|
||||||
:nav-sidebar-width="navSidebarWidth"
|
|
||||||
@go-back="handleBackToConfig"
|
|
||||||
@stop-all="handleStopAll"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</PermissionMask>
|
</PermissionMask>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tab 2: TK Workbench - crawl 权限 -->
|
<!-- Tab 2: TK Workbench - crawl 权限 -->
|
||||||
<div v-show="currentView === 'tk'" class="absolute inset-0 z-20 bg-gray-50 h-full overflow-hidden">
|
<div v-show="currentView === 'tk'" class="absolute inset-0 z-20 bg-gray-50 h-full overflow-hidden">
|
||||||
<PermissionMask
|
<PermissionMask permission-key="crawl" title="TK工作台未开通" description="您当前没有使用TK工作台功能的权限"
|
||||||
permission-key="crawl"
|
:placeholder-image="placeholderTk" :contacts="serviceContacts">
|
||||||
title="TK工作台未开通"
|
<TkWorkbenches :key="tkWorkbenchKey" />
|
||||||
description="您当前没有使用TK工作台功能的权限"
|
|
||||||
:placeholder-image="placeholderTk"
|
|
||||||
:contacts="serviceContacts"
|
|
||||||
>
|
|
||||||
<TkWorkbenches />
|
|
||||||
</PermissionMask>
|
</PermissionMask>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tab 3: Hosts List - crawl 权限 -->
|
<!-- Tab 3: Hosts List - crawl 权限 -->
|
||||||
<div v-show="currentView === 'hosts'" class="absolute inset-0 z-20 bg-gray-50 h-full overflow-hidden">
|
<div v-show="currentView === 'hosts'" class="absolute inset-0 z-20 bg-gray-50 h-full overflow-hidden">
|
||||||
<PermissionMask
|
<PermissionMask permission-key="crawl" title="主播列表未开通" description="您当前没有使用主播列表功能的权限"
|
||||||
permission-key="crawl"
|
:placeholder-image="placeholderHosts" :contacts="serviceContacts">
|
||||||
title="主播列表未开通"
|
|
||||||
description="您当前没有使用主播列表功能的权限"
|
|
||||||
:placeholder-image="placeholderHosts"
|
|
||||||
:contacts="serviceContacts"
|
|
||||||
>
|
|
||||||
<HostsList />
|
<HostsList />
|
||||||
</PermissionMask>
|
</PermissionMask>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tab 4: Fan Workbench - bigBrother 权限 -->
|
<!-- Tab 4: Fan Workbench - bigBrother 权限 -->
|
||||||
<div v-show="currentView === 'FanWorkbench'" class="absolute inset-0 z-20 bg-gray-50 h-full overflow-hidden">
|
<div v-show="currentView === 'FanWorkbench'" class="absolute inset-0 z-20 bg-gray-50 h-full overflow-hidden">
|
||||||
<PermissionMask
|
<PermissionMask permission-key="bigBrother" title="大哥工作台未开通" description="您当前没有使用大哥工作台功能的权限"
|
||||||
permission-key="bigBrother"
|
:placeholder-image="placeholderBigBrother" :contacts="serviceContacts">
|
||||||
title="大哥工作台未开通"
|
|
||||||
description="您当前没有使用大哥工作台功能的权限"
|
|
||||||
:placeholder-image="placeholderBigBrother"
|
|
||||||
:contacts="serviceContacts"
|
|
||||||
>
|
|
||||||
<FanWorkbench />
|
<FanWorkbench />
|
||||||
</PermissionMask>
|
</PermissionMask>
|
||||||
</div>
|
</div>
|
||||||
@@ -151,16 +126,13 @@
|
|||||||
|
|
||||||
<!-- Tab 6: yolo商店 - Electron 用 BrowserView,Web 用 iframe 兜底 -->
|
<!-- Tab 6: yolo商店 - Electron 用 BrowserView,Web 用 iframe 兜底 -->
|
||||||
<div v-show="currentView === 'shop'" class="absolute inset-0 z-20 h-full overflow-hidden">
|
<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>
|
</div>
|
||||||
<iframe
|
<iframe v-else-if="adminLoaded" :src="shopUrl" class="w-full h-full border-0"
|
||||||
v-else-if="adminLoaded"
|
|
||||||
:src="shopUrl"
|
|
||||||
class="w-full h-full border-0"
|
|
||||||
allow="clipboard-read; clipboard-write"
|
allow="clipboard-read; clipboard-write"
|
||||||
sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-downloads"
|
sandbox="allow-same-origin allow-scripts allow-forms allow-popups allow-downloads"></iframe>
|
||||||
></iframe>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -210,68 +182,78 @@ const shopOpened = ref(false) // Electron 只首开加载一次
|
|||||||
const shopUrl = ENV.SHOP_URL
|
const shopUrl = ENV.SHOP_URL
|
||||||
const sidebarRef = useTemplateRef('sidebarRef')
|
const sidebarRef = useTemplateRef('sidebarRef')
|
||||||
const navSidebarWidth = ref(200) // 左侧导航菜单的实际宽度(px),传给 YoloBrowser/Sidebar 使用
|
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([])
|
const serviceContacts = ref([])
|
||||||
const loadServiceContacts = async () => {
|
const loadServiceContacts = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getCustomServiceInfo()
|
const res = await getCustomServiceInfo()
|
||||||
console.log("获取名片",res)
|
console.log("获取名片", res)
|
||||||
if (res) {
|
if (res) {
|
||||||
serviceContacts.value = res.map(item => ({
|
serviceContacts.value = res.map(item => ({
|
||||||
avatar: item.avater,
|
avatar: item.avater,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
desc: item.description,
|
desc: item.description,
|
||||||
qrcode: item.concat,
|
qrcode: item.concat,
|
||||||
phone: item.phone
|
phone: item.phone
|
||||||
}))
|
}))
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('获取客服名片失败:', e)
|
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('获取客服名片失败:', e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听菜单栏实际宽度,通知后端更新 BrowserView 定位
|
// 监听菜单栏实际宽度,通知后端更新 BrowserView 定位
|
||||||
let resizeObserver = null
|
let resizeObserver = null
|
||||||
const notifySidebarWidth = (width) => {
|
const notifySidebarWidth = (width) => {
|
||||||
navSidebarWidth.value = Math.round(width)
|
navSidebarWidth.value = Math.round(width)
|
||||||
if (isElectron()) {
|
if (isElectron()) {
|
||||||
window.electronAPI.setSidebarWidth(Math.round(width)).catch(() => {})
|
window.electronAPI.setSidebarWidth(Math.round(width)).catch(() => { })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadServiceContacts()
|
loadServiceContacts()
|
||||||
if (!isElectron()) return
|
if (!isElectron()) return
|
||||||
resizeObserver = new ResizeObserver((entries) => {
|
resizeObserver = new ResizeObserver((entries) => {
|
||||||
const width = entries[0]?.contentRect.width
|
const width = entries[0]?.contentRect.width
|
||||||
if (width) notifySidebarWidth(width)
|
if (width) notifySidebarWidth(width)
|
||||||
})
|
})
|
||||||
if (sidebarRef.value) {
|
if (sidebarRef.value) {
|
||||||
resizeObserver.observe(sidebarRef.value)
|
resizeObserver.observe(sidebarRef.value)
|
||||||
// 立即上报初始宽度
|
// 立即上报初始宽度
|
||||||
notifySidebarWidth(sidebarRef.value.getBoundingClientRect().width)
|
notifySidebarWidth(sidebarRef.value.getBoundingClientRect().width)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
resizeObserver?.disconnect()
|
resizeObserver?.disconnect()
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleGoToBrowser = async () => {
|
const handleGoToBrowser = async () => {
|
||||||
autoDmMode.value = 'browser'
|
autoDmMode.value = 'browser'
|
||||||
if (isElectron()) {
|
if (isElectron()) {
|
||||||
await window.electronAPI.showViews()
|
await window.electronAPI.showViews()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleBackToConfig = async () => {
|
const handleBackToConfig = async () => {
|
||||||
autoDmMode.value = 'config'
|
autoDmMode.value = 'config'
|
||||||
if (isElectron()) {
|
if (isElectron()) {
|
||||||
await window.electronAPI.hideViews()
|
await window.electronAPI.hideViews()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleStopAll = () => {
|
const handleStopAll = () => {
|
||||||
emit('stop-all')
|
emit('stop-all')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch for view changes to manage native Electron BrowserViews
|
// Watch for view changes to manage native Electron BrowserViews
|
||||||
@@ -325,13 +307,13 @@ watch(currentView, async (newVal, oldVal) => {
|
|||||||
|
|
||||||
// Watch sub-mode changes
|
// Watch sub-mode changes
|
||||||
watch(autoDmMode, async (newVal) => {
|
watch(autoDmMode, async (newVal) => {
|
||||||
if (currentView.value !== 'auto_dm') return
|
if (currentView.value !== 'auto_dm') return
|
||||||
|
|
||||||
if (newVal === 'browser') {
|
if (newVal === 'browser') {
|
||||||
if (isElectron()) await window.electronAPI.showViews()
|
if (isElectron()) await window.electronAPI.showViews()
|
||||||
} else {
|
} else {
|
||||||
if (isElectron()) await window.electronAPI.hideViews()
|
if (isElectron()) await window.electronAPI.hideViews()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -339,10 +321,7 @@ watch(autoDmMode, async (newVal) => {
|
|||||||
/* Material Icons support - simplistic import, ideal to put in index.html or main.js */
|
/* Material Icons support - simplistic import, ideal to put in index.html or main.js */
|
||||||
@import url('https://fonts.googleapis.com/icon?family=Material+Icons+Round');
|
@import url('https://fonts.googleapis.com/icon?family=Material+Icons+Round');
|
||||||
|
|
||||||
.yolo-logo{
|
.yolo-logo {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -276,16 +276,23 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-6 text-center">
|
<div class="mt-6 text-center">
|
||||||
<button v-if="pyData.isStart" @click="submit"
|
<div class="flex flex-col md:flex-row gap-4 justify-center items-center">
|
||||||
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">
|
<button v-if="pyData.isStart" @click="submit"
|
||||||
<span class="material-icons-round">bolt</span>
|
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">
|
||||||
{{ $t('workbenchesSetup.start') }}
|
<span class="material-icons-round">bolt</span>
|
||||||
</button>
|
{{ $t('workbenchesSetup.start') }}
|
||||||
<button v-else @click="unsubmit"
|
</button>
|
||||||
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">
|
<button v-else @click="unsubmit"
|
||||||
<span class="material-icons-round">stop</span>
|
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">
|
||||||
{{ $t('workbenchesSetup.stop') }}
|
<span class="material-icons-round">stop</span>
|
||||||
</button>
|
{{ $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">
|
<p class="mt-4 text-xs font-medium text-emerald-600">
|
||||||
到期时间: {{ timestampToTime(expiredTime) }}
|
到期时间: {{ timestampToTime(expiredTime) }}
|
||||||
</p>
|
</p>
|
||||||
@@ -297,7 +304,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<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 { usePythonBridge, } from '@/utils/pythonBridge'
|
||||||
import { setNumData, getNumData, getUser, setTkUser, getTkUser } from '@/utils/storage'
|
import { setNumData, getNumData, getUser, setTkUser, getTkUser } from '@/utils/storage'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
@@ -306,6 +314,24 @@ import { tkaccountuseinfo, getExpiredTime } from '@/api/account'
|
|||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useCountryInfo } from '@/composables/useCountryInfo'
|
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 { t, locale } = useI18n()
|
||||||
// 使用独立的国家信息管理(不与其他页面共享)
|
// 使用独立的国家信息管理(不与其他页面共享)
|
||||||
const {
|
const {
|
||||||
@@ -602,6 +628,44 @@ const toggleFilter = (filterName) => {
|
|||||||
pyData.value[filterName] = !pyData.value[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) => {
|
const loginTK = (index) => {
|
||||||
setTkUser(tkData.value)
|
setTkUser(tkData.value)
|
||||||
@@ -639,6 +703,11 @@ const openTK = () => {
|
|||||||
const checkTkLoginStatus = () => {
|
const checkTkLoginStatus = () => {
|
||||||
getTkLoginStatus().then((res) => {
|
getTkLoginStatus().then((res) => {
|
||||||
isTkLoggedIn.value = res === true || res === 'true';
|
isTkLoggedIn.value = res === true || res === 'true';
|
||||||
|
|
||||||
|
if (isTkLoggedIn.value) {
|
||||||
|
clearInterval(tkStatusTimer.value);
|
||||||
|
tkStatusTimer.value = null;
|
||||||
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
isTkLoggedIn.value = false;
|
isTkLoggedIn.value = false;
|
||||||
});
|
});
|
||||||
@@ -746,6 +815,52 @@ const formattedTime = computed(() => {
|
|||||||
].join(':');
|
].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) {
|
function timestampToTime(timestamp_ms) {
|
||||||
const date = new Date(timestamp_ms);
|
const date = new Date(timestamp_ms);
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
|
|||||||
Reference in New Issue
Block a user