feat(remote): 增加远端控制台与日志汇总导出
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
import { useTheme } from '@/composables/useTheme'
|
||||
import { useScheduler } from '@/composables/useScheduler'
|
||||
import { useSettings } from '@/composables/useSettings'
|
||||
@@ -10,6 +10,7 @@ import LogPanel from '@/components/log/LogPanel.vue'
|
||||
import SettingsModal from '@/components/modal/SettingsModal.vue'
|
||||
import CKManager from '@/components/ck/CKManager.vue'
|
||||
import ExchangeRecords from '@/components/exchange/ExchangeRecords.vue'
|
||||
import { GetRemoteStatus } from '@wails/go/app/App'
|
||||
|
||||
defineProps<{
|
||||
serverTime: string
|
||||
@@ -21,6 +22,12 @@ const { settings, loadSettings } = useSettings()
|
||||
|
||||
const settingsModalRef = ref<InstanceType<typeof SettingsModal> | null>(null)
|
||||
const currentPage = ref<'console' | 'ck' | 'exchange'>('console')
|
||||
const remoteStatus = ref<{
|
||||
enabled: boolean
|
||||
connected: boolean
|
||||
message?: string
|
||||
}>({ enabled: false, connected: false })
|
||||
let remoteStatusTimer: number | null = null
|
||||
|
||||
const proxyAutoFetchReady = computed(() => (
|
||||
settings.value.proxyEnabled
|
||||
@@ -50,11 +57,41 @@ const proxyTitle = computed(() => {
|
||||
return '代理已启用,点击打开代理设置'
|
||||
})
|
||||
|
||||
const remoteSummary = computed(() => {
|
||||
if (!settings.value.remoteEnabled) return '远端 · 未启用'
|
||||
if (remoteStatus.value.connected) return '远端 · 已连接'
|
||||
if (remoteStatus.value.enabled) return '远端 · 连接中'
|
||||
return '远端 · 未启用'
|
||||
})
|
||||
|
||||
const remoteTitle = computed(() => {
|
||||
if (!settings.value.remoteEnabled) return '远端控制未启用,点击配置'
|
||||
const target = settings.value.remoteUrl.trim() || '尚未填写控制中心地址'
|
||||
const detail = remoteStatus.value.message ? `;${remoteStatus.value.message}` : ''
|
||||
return `${target}${detail};点击打开远端设置`
|
||||
})
|
||||
|
||||
const openSettings = (section = '') => {
|
||||
settingsModalRef.value?.open(section)
|
||||
}
|
||||
|
||||
onMounted(loadSettings)
|
||||
const refreshRemoteStatus = async () => {
|
||||
try {
|
||||
remoteStatus.value = await GetRemoteStatus()
|
||||
} catch {
|
||||
remoteStatus.value = { enabled: false, connected: false }
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadSettings()
|
||||
await refreshRemoteStatus()
|
||||
remoteStatusTimer = window.setInterval(refreshRemoteStatus, 3000)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (remoteStatusTimer) clearInterval(remoteStatusTimer)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -70,6 +107,17 @@ onMounted(loadSettings)
|
||||
<span v-if="countdownSeconds > 0 && currentPage === 'console'" class="countdown-badge">{{ formatRemain(countdownSeconds) }}</span>
|
||||
</div>
|
||||
<div class="top-actions">
|
||||
<button
|
||||
class="remote-quick"
|
||||
:class="{
|
||||
active: settings.remoteEnabled && remoteStatus.connected,
|
||||
warning: settings.remoteEnabled && !remoteStatus.connected
|
||||
}"
|
||||
:title="remoteTitle"
|
||||
@click="openSettings('remote')"
|
||||
>
|
||||
{{ remoteSummary }}
|
||||
</button>
|
||||
<button
|
||||
class="proxy-quick"
|
||||
:class="{
|
||||
@@ -147,6 +195,35 @@ onMounted(loadSettings)
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.remote-quick {
|
||||
height: 30px;
|
||||
padding: 0 10px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
background: var(--surface-2);
|
||||
color: var(--muted);
|
||||
cursor: pointer;
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.remote-quick:hover {
|
||||
border-color: var(--accent-border);
|
||||
color: var(--text-strong);
|
||||
}
|
||||
|
||||
.remote-quick.active {
|
||||
color: var(--success);
|
||||
border-color: var(--success);
|
||||
background: var(--success-soft);
|
||||
}
|
||||
|
||||
.remote-quick.warning {
|
||||
color: var(--warning);
|
||||
border-color: var(--warning);
|
||||
background: var(--warning-soft);
|
||||
}
|
||||
|
||||
.proxy-quick:hover {
|
||||
border-color: var(--accent-border);
|
||||
color: var(--text-strong);
|
||||
@@ -224,6 +301,6 @@ onMounted(loadSettings)
|
||||
@media (max-width: 900px) {
|
||||
.console-head { flex-wrap: wrap; }
|
||||
.top-actions { width: 100%; justify-content: flex-end; }
|
||||
.proxy-quick { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
||||
.proxy-quick, .remote-quick { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user