fix: 同步记录弹窗改为局部刷新 (#62)

This commit is contained in:
chengma
2026-08-09 21:02:28 +08:00
parent ee1e060e3a
commit d8a24247df
9 changed files with 243 additions and 62 deletions
+55
View File
@@ -0,0 +1,55 @@
{{define "syb/history_partial"}}
<div class="modal-body">
<p class="missing sync-history-load-error" role="alert" data-history-load-error hidden></p>
<p class="hint">共 {{.SyncHistory.Total}} 条,按发起时间从新到旧排列。</p>
<div class="table-wrap sync-history-table">
<table>
<thead>
<tr>
<th>状态</th><th>日期范围</th><th>操作账号</th><th>开始时间</th>
<th>完成时间</th><th>同步结果</th><th>覆盖进度</th><th>失败原因</th>
</tr>
</thead>
<tbody>
{{range .SyncHistory.Rows}}
<tr>
<td><span class="sync-status {{.StatusClass}}">{{.StatusText}}</span></td>
<td>{{.DateRange}}</td>
<td>{{.Username}}</td>
<td>{{.StartedAt}}</td>
<td>{{.FinishedAt}}</td>
<td>{{.Summary}}</td>
<td>{{.CursorText}}</td>
<td class="sync-error">{{if .ErrorMessage}}{{.ErrorMessage}}{{else}}—{{end}}</td>
</tr>
{{else}}
<tr class="empty"><td colspan="8">还没有同步记录。</td></tr>
{{end}}
</tbody>
</table>
</div>
</div>
<div class="modal-foot sync-history-foot">
<span class="grow"></span>
<span class="hint sync-history-loading" role="status" data-history-loading hidden>正在加载同步记录…</span>
<button type="button" data-history-fetch-url="{{.HistoryFetchURL}}">刷新同步记录</button>
<span class="sync-history-page">第 {{.SyncHistory.Page}} / {{.SyncHistory.TotalPages}} 页</span>
{{if .HistoryPagination.HasPrev}}
<a class="button-link" href="{{.HistoryPagination.FirstURL}}"
data-history-fetch-url="{{.HistoryFetchPagination.FirstURL}}">首页</a>
<a class="button-link" href="{{.HistoryPagination.PrevURL}}"
data-history-fetch-url="{{.HistoryFetchPagination.PrevURL}}">上一页</a>
{{else}}
<span class="button-link disabled">首页</span><span class="button-link disabled">上一页</span>
{{end}}
{{if .HistoryPagination.HasNext}}
<a class="button-link" href="{{.HistoryPagination.NextURL}}"
data-history-fetch-url="{{.HistoryFetchPagination.NextURL}}">下一页</a>
<a class="button-link" href="{{.HistoryPagination.LastURL}}"
data-history-fetch-url="{{.HistoryFetchPagination.LastURL}}">末页</a>
{{else}}
<span class="button-link disabled">下一页</span><span class="button-link disabled">末页</span>
{{end}}
<button type="button" data-modal-close>关闭</button>
</div>
{{end}}
+2 -46
View File
@@ -52,52 +52,8 @@
<h2 id="sync-history-modal-title">同步记录</h2>
<button type="button" class="modal-x" data-modal-close aria-label="关闭">×</button>
</div>
<div class="modal-body">
<p class="hint">共 {{.SyncHistory.Total}} 条,按发起时间从新到旧排列。</p>
<div class="table-wrap sync-history-table">
<table>
<thead>
<tr>
<th>状态</th><th>日期范围</th><th>操作账号</th><th>开始时间</th>
<th>完成时间</th><th>同步结果</th><th>覆盖进度</th><th>失败原因</th>
</tr>
</thead>
<tbody>
{{range .SyncHistory.Rows}}
<tr>
<td><span class="sync-status {{.StatusClass}}">{{.StatusText}}</span></td>
<td>{{.DateRange}}</td>
<td>{{.Username}}</td>
<td>{{.StartedAt}}</td>
<td>{{.FinishedAt}}</td>
<td>{{.Summary}}</td>
<td>{{.CursorText}}</td>
<td class="sync-error">{{if .ErrorMessage}}{{.ErrorMessage}}{{else}}—{{end}}</td>
</tr>
{{else}}
<tr class="empty"><td colspan="8">还没有同步记录。</td></tr>
{{end}}
</tbody>
</table>
</div>
</div>
<div class="modal-foot sync-history-foot">
<span class="grow"></span>
<button type="button" data-history-refresh-url="{{.HistoryRefreshURL}}">刷新记录</button>
<span class="sync-history-page">第 {{.SyncHistory.Page}} / {{.SyncHistory.TotalPages}} 页</span>
{{if .HistoryPagination.HasPrev}}
<a class="button-link" href="{{.HistoryPagination.FirstURL}}">首页</a>
<a class="button-link" href="{{.HistoryPagination.PrevURL}}">上一页</a>
{{else}}
<span class="button-link disabled">首页</span><span class="button-link disabled">上一页</span>
{{end}}
{{if .HistoryPagination.HasNext}}
<a class="button-link" href="{{.HistoryPagination.NextURL}}">下一页</a>
<a class="button-link" href="{{.HistoryPagination.LastURL}}">末页</a>
{{else}}
<span class="button-link disabled">下一页</span><span class="button-link disabled">末页</span>
{{end}}
<button type="button" data-modal-close>关闭</button>
<div data-syb-history-slot>
{{template "syb/history_partial" .}}
</div>
</div>
</div>