mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix(system-settings): 修复定时任务时间选择器截断及添加取消按钮
Co-Authored-By: AAEE86 <ppk0227@hotmail.com>
This commit is contained in:
@@ -58,10 +58,10 @@
|
||||
:model-value="task.hour"
|
||||
@update:model-value="(val: string) => task.updateTime(val, task.minute)"
|
||||
>
|
||||
<SelectTrigger class="w-14 h-8 text-xs">
|
||||
<SelectTrigger class="w-16 h-8 text-xs px-2 justify-center gap-1">
|
||||
<SelectValue placeholder="时" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectContent class="min-w-0">
|
||||
<SelectItem
|
||||
v-for="h in 24"
|
||||
:key="h - 1"
|
||||
@@ -76,10 +76,10 @@
|
||||
:model-value="task.minute"
|
||||
@update:model-value="(val: string) => task.updateTime(task.hour, val)"
|
||||
>
|
||||
<SelectTrigger class="w-14 h-8 text-xs">
|
||||
<SelectTrigger class="w-16 h-8 text-xs px-2 justify-center gap-1">
|
||||
<SelectValue placeholder="分" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectContent class="min-w-0">
|
||||
<SelectItem
|
||||
v-for="m in 60"
|
||||
:key="m - 1"
|
||||
@@ -89,23 +89,33 @@
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Button
|
||||
v-if="task.hasChanges"
|
||||
variant="default"
|
||||
size="sm"
|
||||
class="h-8 px-2.5 text-xs"
|
||||
:disabled="task.loading"
|
||||
@click="task.onSave"
|
||||
>
|
||||
<Check
|
||||
v-if="!task.loading"
|
||||
class="w-3.5 h-3.5"
|
||||
/>
|
||||
<Loader2
|
||||
v-else
|
||||
class="w-3.5 h-3.5 animate-spin"
|
||||
/>
|
||||
</Button>
|
||||
<template v-if="task.hasChanges">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
class="h-8 px-2.5 text-xs"
|
||||
:disabled="task.loading"
|
||||
@click="task.onCancel"
|
||||
>
|
||||
<X class="w-3.5 h-3.5" />
|
||||
</Button>
|
||||
<Button
|
||||
variant="default"
|
||||
size="sm"
|
||||
class="h-8 px-2.5 text-xs"
|
||||
:disabled="task.loading"
|
||||
@click="task.onSave"
|
||||
>
|
||||
<Check
|
||||
v-if="!task.loading"
|
||||
class="w-3.5 h-3.5"
|
||||
/>
|
||||
<Loader2
|
||||
v-else
|
||||
class="w-3.5 h-3.5 animate-spin"
|
||||
/>
|
||||
</Button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -142,7 +152,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Clock, Check, Loader2 } from 'lucide-vue-next'
|
||||
import { Clock, Check, Loader2, X } from 'lucide-vue-next'
|
||||
import Button from '@/components/ui/button.vue'
|
||||
import Input from '@/components/ui/input.vue'
|
||||
import Switch from '@/components/ui/switch.vue'
|
||||
@@ -168,6 +178,7 @@ interface ScheduledTask {
|
||||
loading: boolean
|
||||
onToggle: (enabled: boolean) => void
|
||||
onSave: () => void
|
||||
onCancel: () => void
|
||||
}
|
||||
|
||||
defineProps<{
|
||||
|
||||
@@ -129,6 +129,16 @@ export function useScheduledTasks(systemConfig: Ref<SystemConfig>) {
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel handlers
|
||||
function handleCheckinTimeCancel() {
|
||||
systemConfig.value.provider_checkin_time = previousCheckinTime.value
|
||||
}
|
||||
|
||||
function handleQuotaResetConfigCancel() {
|
||||
systemConfig.value.user_quota_reset_time = previousUserQuotaResetTime.value
|
||||
systemConfig.value.user_quota_reset_interval_days = previousUserQuotaResetIntervalDays.value
|
||||
}
|
||||
|
||||
// Save handlers
|
||||
async function handleCheckinTimeSave() {
|
||||
const newTime = systemConfig.value.provider_checkin_time
|
||||
@@ -238,6 +248,7 @@ export function useScheduledTasks(systemConfig: Ref<SystemConfig>) {
|
||||
loading: checkinConfigLoading.value,
|
||||
onToggle: handleProviderCheckinToggle,
|
||||
onSave: handleCheckinTimeSave,
|
||||
onCancel: handleCheckinTimeCancel,
|
||||
},
|
||||
{
|
||||
id: 'user-quota-reset',
|
||||
@@ -253,6 +264,7 @@ export function useScheduledTasks(systemConfig: Ref<SystemConfig>) {
|
||||
loading: quotaResetConfigLoading.value,
|
||||
onToggle: handleUserQuotaResetToggle,
|
||||
onSave: handleQuotaResetConfigSave,
|
||||
onCancel: handleQuotaResetConfigCancel,
|
||||
},
|
||||
{
|
||||
id: 'oauth-token-refresh',
|
||||
@@ -268,6 +280,7 @@ export function useScheduledTasks(systemConfig: Ref<SystemConfig>) {
|
||||
loading: false,
|
||||
onToggle: handleOAuthTokenRefreshToggle,
|
||||
onSave: () => {},
|
||||
onCancel: () => {},
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user