fix(ui): add clear local lock for regenerate-report button

Made-with: Cursor
This commit is contained in:
hub-gif 2026-04-14 14:56:20 +08:00
parent f7a4754e56
commit e73f1ffe8d
2 changed files with 43 additions and 0 deletions

View File

@ -70,6 +70,26 @@ export function generationInFlightKey() {
return inFlightKeys
}
/**
* 清空本地进行中标记sessionStorage + 内存
* 用于断网/关页后误锁导致按钮长期灰显时手动恢复若服务端仍在跑请勿点
*/
export function clearGenerationInFlightState() {
inFlightKeys.value = []
writePersistedKeys([])
}
const REGEN_REPORT_PREFIX = 'regenerate-report:'
/**
* 仅移除重新生成报告相关的进行中 key不影响策略生成报告预览等其它并行锁
*/
export function clearRegenerateReportInFlightOnly() {
const next = inFlightKeys.value.filter((k) => !String(k).startsWith(REGEN_REPORT_PREFIX))
inFlightKeys.value = next
writePersistedKeys(next)
}
function addInFlightKey(key) {
const cur = inFlightKeys.value
if (cur.includes(key)) return

View File

@ -1,6 +1,7 @@
<script setup>
import { computed, onMounted, ref, watch } from 'vue'
import {
clearRegenerateReportInFlightOnly,
generationInFlightKey,
withGenerationInFlight,
} from '../../composables/useGenerationInFlight'
@ -152,6 +153,11 @@ async function loadList() {
}
}
function clearLocalRegenLock() {
regenErr.value = ''
clearRegenerateReportInFlightOnly()
}
async function regenerateReport() {
const id = selectedId.value
if (!id) return
@ -246,7 +252,24 @@ watch(
>
{{ regenBusyThisTask ? '生成中…' : '重新生成报告' }}
</button>
<button
v-if="regenBusyAny"
type="button"
class="ma-btn ma-btn-secondary"
title="仅清除浏览器里记录的「报告生成中」状态;若后端仍在执行请勿点"
@click="clearLocalRegenLock"
>
清除误锁本地
</button>
</div>
<p v-if="!successJobs.length" class="hint-top">
当前没有<strong>已成功</strong>的任务无法生成报告请先在任务列表确认流水线成功
</p>
<p v-else-if="regenBusyAny" class="hint-top">
按钮因本页记录的生成中状态而禁用若你已重启后端或确定没有在生成可点清除误锁本地
亦可在控制台执行
<code>sessionStorage.removeItem('ma_generation_inflight');sessionStorage.removeItem('ma_generation_inflight_ts');location.reload()</code>
</p>
<p v-if="regenBusyOtherTask" class="ma-warn-banner">
任务 #{{ regenPendingJobId }} 的报告正在重新生成中请稍候再切换任务或重复提交
</p>