feat: Implement scheduled tasks management and budget archiving functionality
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 6s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 6s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
- Added BudgetArchiveJob for monthly budget archiving. - Created BudgetArchive entity and BudgetArchiveRepository for managing archived budgets. - Introduced JobController for handling job execution, pausing, and resuming. - Developed ScheduledTasksView for displaying and managing scheduled tasks in the frontend. - Updated PeriodicBillJob to improve scope handling. - Enhanced OpenAiService with increased HTTP timeout. - Added archiveBudgets API endpoint for archiving budgets by year and month. - Refactored BudgetController to utilize new repository patterns and improved error handling. - Introduced rich-content styles for better rendering of HTML content in Vue components. - Updated various Vue components to support rich HTML content display.
This commit is contained in:
@@ -72,7 +72,7 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div ref="resultContainer" class="result-content">
|
||||
<div ref="resultContainer" class="result-content rich-html-content">
|
||||
<div v-html="resultHtml"></div>
|
||||
<van-loading v-if="analyzing" class="result-loading">
|
||||
AI正在分析中...
|
||||
@@ -351,103 +351,12 @@ const startAnalysis = async () => {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* 结果HTML样式 */
|
||||
.result-content :deep(h1),
|
||||
.result-content :deep(h2),
|
||||
.result-content :deep(h3) {
|
||||
color: var(--van-text-color);
|
||||
margin: 16px 0 12px 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.result-content :deep(h1) {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.result-content :deep(h2) {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.result-content :deep(h3) {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.result-content :deep(p) {
|
||||
margin: 8px 0;
|
||||
color: var(--van-text-color);
|
||||
}
|
||||
|
||||
.result-content :deep(ul),
|
||||
.result-content :deep(ol) {
|
||||
padding-left: 24px;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.result-content :deep(li) {
|
||||
margin: 6px 0;
|
||||
color: var(--van-text-color);
|
||||
}
|
||||
|
||||
.result-content :deep(table) {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 16px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.result-content :deep(th),
|
||||
.result-content :deep(td) {
|
||||
padding: 10px;
|
||||
text-align: left;
|
||||
border: 1px solid var(--van-border-color);
|
||||
}
|
||||
|
||||
.result-content :deep(th) {
|
||||
background: var(--van-background-2);
|
||||
font-weight: 600;
|
||||
color: var(--van-text-color);
|
||||
}
|
||||
|
||||
.result-content :deep(td) {
|
||||
color: var(--van-text-color);
|
||||
}
|
||||
|
||||
.result-content :deep(strong) {
|
||||
color: var(--van-text-color);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.result-content :deep(.highlight) {
|
||||
background: #fff3cd;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.result-content :deep(.expense-value) {
|
||||
color: #ff6b6b;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.result-content :deep(.income-value) {
|
||||
color: #51cf66;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: #ff6b6b;
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* 暗色模式适配 */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.result-content :deep(.highlight) {
|
||||
background: rgba(255, 243, 205, 0.2);
|
||||
color: #ffc107;
|
||||
}
|
||||
}
|
||||
|
||||
/* 设置页面容器背景色 */
|
||||
:deep(.van-nav-bar) {
|
||||
background: transparent !important;
|
||||
|
||||
@@ -41,12 +41,12 @@
|
||||
v-model="detailVisible"
|
||||
:title="currentMessage.title"
|
||||
:subtitle="currentMessage.createTime"
|
||||
height="50%"
|
||||
height="80%"
|
||||
:closeable="true"
|
||||
>
|
||||
<div
|
||||
v-if="currentMessage.messageType === 2"
|
||||
class="detail-content"
|
||||
class="detail-content rich-html-content"
|
||||
v-html="currentMessage.content"
|
||||
>
|
||||
</div>
|
||||
@@ -275,10 +275,13 @@ defineExpose({
|
||||
}
|
||||
|
||||
.detail-content {
|
||||
padding: 20px;
|
||||
font-size: 16px;
|
||||
padding: 16px;
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
color: var(--van-text-color);
|
||||
}
|
||||
|
||||
.detail-content:not(.rich-html-content) {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
|
||||
182
Web/src/views/ScheduledTasksView.vue
Normal file
182
Web/src/views/ScheduledTasksView.vue
Normal file
@@ -0,0 +1,182 @@
|
||||
<template>
|
||||
<div class="page-container-flex">
|
||||
<van-nav-bar title="定时任务" left-arrow placeholder @click-left="onClickLeft" />
|
||||
<div class="scroll-content">
|
||||
<van-pull-refresh v-model="loading" @refresh="fetchTasks">
|
||||
<div v-for="task in tasks" :key="task.name" class="task-card">
|
||||
<van-cell-group inset>
|
||||
<van-cell :title="task.jobDescription" :label="task.triggerDescription || task.name">
|
||||
<template #value>
|
||||
<van-tag :type="task.status === 'Paused' ? 'warning' : 'success'">
|
||||
{{ task.status === 'Paused' ? '已暂停' : '已启动' }}
|
||||
</van-tag>
|
||||
</template>
|
||||
</van-cell>
|
||||
<van-cell title="任务标识" :value="task.name" />
|
||||
<van-cell title="下次执行" :value="task.nextRunTime || '无'" />
|
||||
<div class="card-footer">
|
||||
<van-row gutter="10">
|
||||
<van-col span="12">
|
||||
<van-button
|
||||
type="primary"
|
||||
size="small"
|
||||
block
|
||||
icon="play"
|
||||
@click="handleExecute(task)"
|
||||
>
|
||||
立即执行
|
||||
</van-button>
|
||||
</van-col>
|
||||
<van-col span="12">
|
||||
<van-button
|
||||
v-if="task.status !== 'Paused'"
|
||||
type="warning"
|
||||
size="small"
|
||||
block
|
||||
icon="pause"
|
||||
@click="handlePause(task)"
|
||||
>
|
||||
暂停任务
|
||||
</van-button>
|
||||
<van-button
|
||||
v-else
|
||||
type="success"
|
||||
size="small"
|
||||
block
|
||||
icon="play-circle-o"
|
||||
@click="handleResume(task)"
|
||||
>
|
||||
恢复任务
|
||||
</van-button>
|
||||
</van-col>
|
||||
</van-row>
|
||||
</div>
|
||||
</van-cell-group>
|
||||
</div>
|
||||
</van-pull-refresh>
|
||||
|
||||
<van-empty v-if="tasks.length === 0 && !loading" description="无定时任务" />
|
||||
|
||||
<!-- 底部安全距离 -->
|
||||
<div style="height: calc(20px + env(safe-area-inset-bottom, 0px))"></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showConfirmDialog, showSuccessToast, showToast, showLoadingToast, closeToast } from 'vant'
|
||||
import { getJobs, executeJob, pauseJob, resumeJob } from '@/api/job'
|
||||
|
||||
const router = useRouter()
|
||||
const loading = ref(false)
|
||||
const tasks = ref([])
|
||||
|
||||
const fetchTasks = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const { success, data, message } = await getJobs()
|
||||
if (success) {
|
||||
tasks.value = data
|
||||
} else {
|
||||
showToast(message || '获取任务列表失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取任务列表失败:', error)
|
||||
showToast('获取任务列表失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchTasks()
|
||||
})
|
||||
|
||||
const onClickLeft = () => {
|
||||
router.back()
|
||||
}
|
||||
|
||||
const handleExecute = async (task) => {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '确认执行',
|
||||
message: `确定要立即执行"${task.jobDescription}"吗?`,
|
||||
})
|
||||
|
||||
showLoadingToast({
|
||||
message: '执行中...',
|
||||
forbidClick: true,
|
||||
duration: 0
|
||||
})
|
||||
|
||||
const { success, message } = await executeJob(task.name)
|
||||
if (success) {
|
||||
showSuccessToast('执行指令已发送')
|
||||
setTimeout(fetchTasks, 1000)
|
||||
} else {
|
||||
showToast(message || '执行失败')
|
||||
}
|
||||
} catch (error) {
|
||||
if (error !== 'cancel') {
|
||||
console.error('执行失败:', error)
|
||||
showToast('执行失败')
|
||||
}
|
||||
} finally {
|
||||
closeToast()
|
||||
}
|
||||
}
|
||||
|
||||
const handlePause = async (task) => {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '确认暂停',
|
||||
message: `确定要暂停"${task.jobDescription}"吗?`,
|
||||
})
|
||||
|
||||
const { success, message } = await pauseJob(task.name)
|
||||
if (success) {
|
||||
showSuccessToast('已暂停')
|
||||
fetchTasks()
|
||||
} else {
|
||||
showToast(message || '暂停失败')
|
||||
}
|
||||
} catch (error) {
|
||||
if (error !== 'cancel') {
|
||||
console.error('暂停失败:', error)
|
||||
showToast('暂停失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const handleResume = async (task) => {
|
||||
try {
|
||||
const { success, message } = await resumeJob(task.name)
|
||||
if (success) {
|
||||
showSuccessToast('已恢复')
|
||||
fetchTasks()
|
||||
} else {
|
||||
showToast(message || '恢复失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('恢复失败:', error)
|
||||
showToast('恢复失败')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.task-card {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.card-footer {
|
||||
padding: 10px 16px;
|
||||
background-color: var(--van-background-2);
|
||||
}
|
||||
|
||||
.scroll-content {
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
@@ -42,6 +42,7 @@
|
||||
<van-cell-group inset>
|
||||
<van-cell title="查看日志" is-link @click="handleLogView" />
|
||||
<van-cell title="清除缓存" is-link @click="handleReloadFromNetwork" />
|
||||
<van-cell title="定时任务" is-link @click="handleScheduledTasks" />
|
||||
</van-cell-group>
|
||||
|
||||
<div class="detail-header" style="padding-bottom: 5px;">
|
||||
@@ -291,6 +292,10 @@ const handleReloadFromNetwork = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleScheduledTasks = () => {
|
||||
router.push({ name: 'scheduled-tasks' })
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user