mirror of
https://github.com/fawney19/Aether.git
synced 2026-01-02 15:52:26 +08:00
fix: 优化自动刷新交互和ESC关闭样式
- 自动刷新改为按钮切换模式,移除独立Switch开关 - 自动刷新间隔从30s改为10s - ESC关闭弹窗后blur焦点,避免样式残留
This commit is contained in:
@@ -45,6 +45,11 @@ export function useEscapeKey(
|
|||||||
// 执行回调
|
// 执行回调
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
|
// 移除当前元素的焦点,避免残留样式
|
||||||
|
if (document.activeElement instanceof HTMLElement) {
|
||||||
|
document.activeElement.blur()
|
||||||
|
}
|
||||||
|
|
||||||
// 如果只监听一次,则移除监听器
|
// 如果只监听一次,则移除监听器
|
||||||
if (once) {
|
if (once) {
|
||||||
removeEventListener()
|
removeEventListener()
|
||||||
|
|||||||
@@ -136,23 +136,20 @@
|
|||||||
<!-- 分隔线 -->
|
<!-- 分隔线 -->
|
||||||
<div class="hidden sm:block h-4 w-px bg-border" />
|
<div class="hidden sm:block h-4 w-px bg-border" />
|
||||||
|
|
||||||
<!-- 刷新按钮 -->
|
<!-- 自动刷新按钮 -->
|
||||||
<RefreshButton
|
<Button
|
||||||
v-if="!autoRefresh"
|
variant="ghost"
|
||||||
:loading="loading"
|
size="icon"
|
||||||
@click="$emit('refresh')"
|
class="h-8 w-8"
|
||||||
/>
|
:class="autoRefresh ? 'text-primary' : ''"
|
||||||
|
:title="autoRefresh ? '点击关闭自动刷新' : '点击开启自动刷新(每10秒刷新)'"
|
||||||
<!-- 自动刷新开关 -->
|
@click="$emit('update:autoRefresh', !autoRefresh)"
|
||||||
<div class="flex items-center gap-2">
|
>
|
||||||
<Switch
|
<RefreshCcw
|
||||||
:model-value="autoRefresh"
|
class="w-3.5 h-3.5"
|
||||||
@update:model-value="$emit('update:autoRefresh', $event)"
|
:class="autoRefresh ? 'animate-spin' : ''"
|
||||||
/>
|
/>
|
||||||
<label class="text-xs text-muted-foreground cursor-pointer select-none" @click="$emit('update:autoRefresh', !autoRefresh)">
|
</Button>
|
||||||
自动刷新
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<Table>
|
<Table>
|
||||||
@@ -420,6 +417,7 @@ import { ref, computed, onUnmounted, watch } from 'vue'
|
|||||||
import {
|
import {
|
||||||
TableCard,
|
TableCard,
|
||||||
Badge,
|
Badge,
|
||||||
|
Button,
|
||||||
Select,
|
Select,
|
||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
@@ -432,9 +430,8 @@ import {
|
|||||||
TableHead,
|
TableHead,
|
||||||
TableCell,
|
TableCell,
|
||||||
Pagination,
|
Pagination,
|
||||||
RefreshButton,
|
|
||||||
Switch,
|
|
||||||
} from '@/components/ui'
|
} from '@/components/ui'
|
||||||
|
import { RefreshCcw } from 'lucide-vue-next'
|
||||||
import { formatTokens, formatCurrency } from '@/utils/format'
|
import { formatTokens, formatCurrency } from '@/utils/format'
|
||||||
import { formatDateTime } from '../composables'
|
import { formatDateTime } from '../composables'
|
||||||
import { useRowClick } from '@/composables/useRowClick'
|
import { useRowClick } from '@/composables/useRowClick'
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ const hasActiveRequests = computed(() => activeRequestIds.value.length > 0)
|
|||||||
let autoRefreshTimer: ReturnType<typeof setInterval> | null = null
|
let autoRefreshTimer: ReturnType<typeof setInterval> | null = null
|
||||||
let globalAutoRefreshTimer: ReturnType<typeof setInterval> | null = null
|
let globalAutoRefreshTimer: ReturnType<typeof setInterval> | null = null
|
||||||
const AUTO_REFRESH_INTERVAL = 1000 // 1秒刷新一次(用于活跃请求)
|
const AUTO_REFRESH_INTERVAL = 1000 // 1秒刷新一次(用于活跃请求)
|
||||||
const GLOBAL_AUTO_REFRESH_INTERVAL = 30000 // 30秒刷新一次(全局自动刷新)
|
const GLOBAL_AUTO_REFRESH_INTERVAL = 10000 // 10秒刷新一次(全局自动刷新)
|
||||||
const globalAutoRefresh = ref(false) // 全局自动刷新开关
|
const globalAutoRefresh = ref(false) // 全局自动刷新开关
|
||||||
|
|
||||||
// 轮询活跃请求状态(轻量级,只更新状态变化的记录)
|
// 轮询活跃请求状态(轻量级,只更新状态变化的记录)
|
||||||
|
|||||||
Reference in New Issue
Block a user