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 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) { function addInFlightKey(key) {
const cur = inFlightKeys.value const cur = inFlightKeys.value
if (cur.includes(key)) return if (cur.includes(key)) return

View File

@ -1,6 +1,7 @@
<script setup> <script setup>
import { computed, onMounted, ref, watch } from 'vue' import { computed, onMounted, ref, watch } from 'vue'
import { import {
clearRegenerateReportInFlightOnly,
generationInFlightKey, generationInFlightKey,
withGenerationInFlight, withGenerationInFlight,
} from '../../composables/useGenerationInFlight' } from '../../composables/useGenerationInFlight'
@ -152,6 +153,11 @@ async function loadList() {
} }
} }
function clearLocalRegenLock() {
regenErr.value = ''
clearRegenerateReportInFlightOnly()
}
async function regenerateReport() { async function regenerateReport() {
const id = selectedId.value const id = selectedId.value
if (!id) return if (!id) return
@ -246,7 +252,24 @@ watch(
> >
{{ regenBusyThisTask ? '生成中…' : '重新生成报告' }} {{ regenBusyThisTask ? '生成中…' : '重新生成报告' }}
</button> </button>
<button
v-if="regenBusyAny"
type="button"
class="ma-btn ma-btn-secondary"
title="仅清除浏览器里记录的「报告生成中」状态;若后端仍在执行请勿点"
@click="clearLocalRegenLock"
>
清除误锁(本地)
</button>
</div> </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"> <p v-if="regenBusyOtherTask" class="ma-warn-banner">
任务 #{{ regenPendingJobId }} 的报告正在重新生成中,请稍候再切换任务或重复提交。 任务 #{{ regenPendingJobId }} 的报告正在重新生成中,请稍候再切换任务或重复提交。
</p> </p>