令牌下线提示
This commit is contained in:
@@ -276,16 +276,23 @@
|
||||
</div>
|
||||
|
||||
<div class="mt-6 text-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">
|
||||
<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>
|
||||
<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">
|
||||
<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-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();
|
||||
|
||||
Reference in New Issue
Block a user