fix(street): 审核页「设为主图」改为GET链接并支持勾选批量并入
This commit is contained in:
@ -1353,8 +1353,11 @@ button.ghost{background:#fff;color:#111;border:1px solid #ccc}
|
|||||||
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:10px;margin-top:14px}
|
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:10px;margin-top:14px}
|
||||||
.cell{background:#fff;border:1px solid #eee;border-radius:8px;overflow:hidden}
|
.cell{background:#fff;border:1px solid #eee;border-radius:8px;overflow:hidden}
|
||||||
.cell img{width:100%;display:block;aspect-ratio:2/3;object-fit:cover}
|
.cell img{width:100%;display:block;aspect-ratio:2/3;object-fit:cover}
|
||||||
.cell .acts{padding:8px;display:flex;gap:6px}
|
.cell .acts{padding:8px;display:flex;flex-wrap:wrap;gap:6px}
|
||||||
.cell .acts button{margin:0;flex:1;padding:7px;font-size:13px}
|
.cell .acts button{margin:0;flex:1 1 auto;padding:7px;font-size:13px}
|
||||||
|
.btn{display:inline-block;flex:1 1 auto;margin:0;padding:7px 10px;background:#fff;color:#111;border:1px solid #ccc;border-radius:6px;text-decoration:none;font-size:13px;text-align:center}
|
||||||
|
.chk{display:flex;align-items:center;gap:4px;flex:1 1 auto;font-size:12px;color:#333;white-space:nowrap;cursor:pointer}
|
||||||
|
.chk input{margin:0}
|
||||||
</style></head>
|
</style></head>
|
||||||
<body>
|
<body>
|
||||||
<div class="bar"><span>管理后台 · 草稿审核 #{{.Draft.ID}}</span><span><a href="{{reviewDetailURL .Draft.Kind .Draft.ID}}">返回列表</a> · <a href="/admin/logout">退出</a></span></div>
|
<div class="bar"><span>管理后台 · 草稿审核 #{{.Draft.ID}}</span><span><a href="{{reviewDetailURL .Draft.Kind .Draft.ID}}">返回列表</a> · <a href="/admin/logout">退出</a></span></div>
|
||||||
@ -1364,14 +1367,13 @@ button.ghost{background:#fff;color:#111;border:1px solid #ccc}
|
|||||||
{{range .Draft.Fields}}<div><label>{{.Label}}</label>{{if eq .Type "textarea"}}<textarea name="{{.Name}}">{{.Value}}</textarea>{{else}}<input name="{{.Name}}" value="{{.Value}}"{{if eq .Type "number"}} inputmode="numeric"{{end}}>{{end}}</div>{{end}}
|
{{range .Draft.Fields}}<div><label>{{.Label}}</label>{{if eq .Type "textarea"}}<textarea name="{{.Name}}">{{.Value}}</textarea>{{else}}<input name="{{.Name}}" value="{{.Value}}"{{if eq .Type "number"}} inputmode="numeric"{{end}}>{{end}}</div>{{end}}
|
||||||
<button type="submit">通过并发布</button>
|
<button type="submit">通过并发布</button>
|
||||||
</form>
|
</form>
|
||||||
{{if eq .Draft.Kind "street"}}{{if .Draft.MainID}}<div class="hint">当前主图:#{{.Draft.MainID}}(折叠视图;点「拆出」可恢复独立主图)</div>{{end}}
|
{{if eq .Draft.Kind "street"}}<div class="hint">{{if .Draft.MainID}}当前主图:<b>#{{.Draft.MainID}}</b>。操作三步:① 在下方任意「主图」上点「设为主图」切换当前主图 → ② 勾选要并入的图 → ③ 点页面底部「并入到当前主图」。连拍快速归并可用每张图上的「并入上一张」。{{else}}尚未选定主图:请在下方某张图上点「设为主图」(页面会带上 <code>?main=</code> 参数),再勾选要并入的图、点底部「并入到当前主图」。{{end}}</div>
|
||||||
<h2>主副图分组({{len .Draft.Groups}} 组 · 共 {{.Draft.ImageCount}} 张)</h2>
|
<h2>主副图分组({{len .Draft.Groups}} 组 · 共 {{.Draft.ImageCount}} 张)</h2>
|
||||||
{{if .Draft.Groups}}{{range .Draft.Groups}}<div class="strip-group{{if eq .Image.ID $.Draft.MainID}} cur{{end}}">
|
{{if .Draft.Groups}}{{range .Draft.Groups}}<div class="strip-group{{if eq .Image.ID $.Draft.MainID}} cur{{end}}">
|
||||||
<div class="main-img">
|
<div class="main-img">
|
||||||
<img src="{{.Image.Image}}" loading="lazy">
|
<img src="{{.Image.Image}}" loading="lazy">
|
||||||
<div class="acts">
|
<div class="acts">
|
||||||
<form method="post" class="inline" action="{{reviewDetailURL $.Draft.Kind $.Draft.ID}}"><input type="hidden" name="main" value="{{.Image.ID}}"><button type="submit" class="ghost">设为主图</button></form>
|
<a class="btn" href="{{reviewDetailURL $.Draft.Kind $.Draft.ID .Image.ID}}">设为主图</a>
|
||||||
<form method="post" class="inline" action="/admin/reviews/{{$.Draft.Kind}}/{{$.Draft.ID}}/images/{{.Image.ID}}/detach"><button type="submit" onclick="return confirm('确认把这张主图拆成独立主图?')">拆出</button></form>
|
|
||||||
<form method="post" class="inline" action="/admin/reviews/{{$.Draft.Kind}}/{{$.Draft.ID}}/images/{{.Image.ID}}/delete"><button type="submit" class="reject" onclick="return confirm('确认删除这张图片?')">删除</button></form>
|
<form method="post" class="inline" action="/admin/reviews/{{$.Draft.Kind}}/{{$.Draft.ID}}/images/{{.Image.ID}}/delete"><button type="submit" class="reject" onclick="return confirm('确认删除这张图片?')">删除</button></form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -1387,22 +1389,27 @@ button.ghost{background:#fff;color:#111;border:1px solid #ccc}
|
|||||||
</div>{{end}}
|
</div>{{end}}
|
||||||
</div>{{end}}
|
</div>{{end}}
|
||||||
</div>{{end}}{{else}}<p class="muted">该草稿暂无图片。</p>{{end}}
|
</div>{{end}}{{else}}<p class="muted">该草稿暂无图片。</p>{{end}}
|
||||||
<h2>全部图片(点选并入当前主图)</h2>
|
<h2>全部图片(勾选后批量并入当前主图)</h2>
|
||||||
|
<form id="batch" method="post" action="/admin/reviews/{{.Draft.Kind}}/{{.Draft.ID}}/images/attach">
|
||||||
|
<input type="hidden" name="main" value="{{.Draft.MainID}}">
|
||||||
|
</form>
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
{{range .Draft.Images}}<div class="cell">
|
{{range .Draft.Images}}<div class="cell">
|
||||||
<img src="{{.Image}}" loading="lazy">
|
<img src="{{.Image}}" loading="lazy">
|
||||||
<span style="display:block;padding:6px 8px;font-size:12px;color:#666">{{.Name}}{{if eq .IsDetail 1}} · 副图{{end}}</span>
|
<span style="display:block;padding:6px 8px;font-size:12px;color:#666">{{.Name}}{{if eq .IsDetail 1}} · 副图 #{{.ParentImageID}}{{else if eq .ID $.Draft.MainID}} · <b>当前主图</b>{{end}}</span>
|
||||||
<div class="acts">
|
<div class="acts">
|
||||||
{{if eq .IsDetail 1}}
|
{{if eq .IsDetail 1}}
|
||||||
<form method="post" action="/admin/reviews/{{$.Draft.Kind}}/{{$.Draft.ID}}/images/{{.ID}}/detach"><button type="submit" onclick="return confirm('把这张拆成独立主图?')">拆出</button></form>
|
<label class="chk"><input type="checkbox" form="batch" name="img" value="{{.ID}}"> 并入</label>
|
||||||
<form method="post" action="/admin/reviews/{{$.Draft.Kind}}/{{$.Draft.ID}}/images/{{.ID}}/delete"><button type="submit" class="reject" onclick="return confirm('确认删除这张图片?')">删除</button></form>
|
<form method="post" action="/admin/reviews/{{$.Draft.Kind}}/{{$.Draft.ID}}/images/{{.ID}}/detach"><button type="submit">拆出</button></form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<form method="post" action="/admin/reviews/{{$.Draft.Kind}}/{{$.Draft.ID}}/images/attach"><input type="hidden" name="main" value="{{$.Draft.MainID}}"><input type="hidden" name="img" value="{{.ID}}"><button type="submit"{{if eq .ID $.Draft.MainID}} disabled{{end}}>并入当前主图</button></form>
|
<a class="btn" href="{{reviewDetailURL $.Draft.Kind $.Draft.ID .ID}}">设为主图</a>
|
||||||
<form method="post" action="/admin/reviews/{{$.Draft.Kind}}/{{$.Draft.ID}}/images/{{.ID}}/delete"><button type="submit" class="reject" onclick="return confirm('确认删除这张图片?')">删除</button></form>
|
<label class="chk"><input type="checkbox" form="batch" name="img" value="{{.ID}}"{{if eq .ID $.Draft.MainID}} disabled checked{{end}}> 并入</label>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
<form method="post" action="/admin/reviews/{{$.Draft.Kind}}/{{$.Draft.ID}}/images/{{.ID}}/delete"><button type="submit" class="reject" onclick="return confirm('确认删除这张图片?')">删除</button></form>
|
||||||
</div>
|
</div>
|
||||||
</div>{{end}}
|
</div>{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
<div style="margin-top:12px"><button type="submit" form="batch"{{if not .Draft.MainID}} disabled{{end}}>并入到当前主图{{if .Draft.MainID}} #{{.Draft.MainID}}{{end}}</button></div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<h2>图片管理({{len .Draft.Images}} 张)</h2>
|
<h2>图片管理({{len .Draft.Images}} 张)</h2>
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
|
|||||||
@ -452,4 +452,16 @@ func TestBackstageStreetRenderGroups(t *testing.T) {
|
|||||||
if !strings.Contains(body, "detail-a") {
|
if !strings.Contains(body, "detail-a") {
|
||||||
t.Fatalf("应渲染副图 detail-a")
|
t.Fatalf("应渲染副图 detail-a")
|
||||||
}
|
}
|
||||||
|
// 「设为主图」必须是带 ?main= 的 GET 链接:选主图只改 URL,不写库。
|
||||||
|
// (曾被误写成 POST 到 /admin/reviews/street/7,而该路由只有 GET,导致 404、主图根本选不了。)
|
||||||
|
if !strings.Contains(body, `href="/admin/reviews/street/7?main=1"`) {
|
||||||
|
t.Fatalf("「设为主图」应是带 ?main= 的 GET 链接")
|
||||||
|
}
|
||||||
|
if strings.Contains(body, `action="/admin/reviews/street/7"`) {
|
||||||
|
t.Fatalf("不应存在 POST 到详情页的表单(该路由只有 GET)")
|
||||||
|
}
|
||||||
|
// 批量并入:勾选框 + 独立提交按钮,用 form="batch" 关联(零 JS、不嵌套表单)。
|
||||||
|
if !strings.Contains(body, `id="batch"`) || !strings.Contains(body, `form="batch"`) {
|
||||||
|
t.Fatalf("应有勾选批量并入当前主图的表单")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user