feat: SSR 悬赏帖托管、采纳与退款
compose 支持 bounty;详情悬赏条可采纳评论或按规则退回。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
</select>
|
||||
</label>
|
||||
{{if .IsEdit}}
|
||||
<p class="j13-muted">类型:{{if eq .PostType "poll"}}投票{{else if eq .PostType "question"}}问答{{else}}普通讨论{{end}}(不可更改)</p>
|
||||
<p class="j13-muted">类型:{{if eq .PostType "poll"}}投票{{else if eq .PostType "question"}}问答{{else if eq .PostType "bounty"}}悬赏{{else}}普通讨论{{end}}(不可更改)</p>
|
||||
<input type="hidden" name="post_type" value="{{.PostType}}"/>
|
||||
{{else}}
|
||||
<label>类型
|
||||
@@ -24,6 +24,7 @@
|
||||
<option value="normal"{{if or (eq .PostType "normal") (eq .PostType "")}} selected{{end}}>普通讨论</option>
|
||||
<option value="question"{{if eq .PostType "question"}} selected{{end}}>问答</option>
|
||||
<option value="poll"{{if eq .PostType "poll"}} selected{{end}}>投票</option>
|
||||
<option value="bounty"{{if eq .PostType "bounty"}} selected{{end}}>悬赏</option>
|
||||
</select>
|
||||
</label>
|
||||
<p class="j13-muted" id="compose-question-hint"{{if ne .PostType "question"}} hidden{{end}}>问答帖无额外字段;解决状态可在帖详情由作者或管理员切换。</p>
|
||||
@@ -40,6 +41,13 @@
|
||||
<textarea name="poll_options" rows="6" placeholder="选项 A 选项 B 选项 C">{{.PollOptions}}</textarea>
|
||||
</label>
|
||||
</fieldset>
|
||||
<fieldset class="j13-bounty-fields" id="compose-bounty-fields"{{if ne .PostType "bounty"}} hidden{{end}}>
|
||||
<legend>悬赏设置</legend>
|
||||
<p class="j13-muted">当前积分:{{.ViewerPoints}}。发帖时立即托管,采纳或退款前不可收回(有他人回复后作者不可自行退款)。</p>
|
||||
<label>悬赏积分
|
||||
<input name="bounty_points" type="number" min="1" value="{{.BountyPoints}}"/>
|
||||
</label>
|
||||
</fieldset>
|
||||
{{end}}
|
||||
<label>标题
|
||||
<input name="title" required maxlength="{{.TitleMax}}" value="{{.Title}}"/>
|
||||
@@ -70,10 +78,12 @@
|
||||
(function () {
|
||||
var sel = document.getElementById('compose-post-type');
|
||||
var box = document.getElementById('compose-poll-fields');
|
||||
var bounty = document.getElementById('compose-bounty-fields');
|
||||
var qHint = document.getElementById('compose-question-hint');
|
||||
if (!sel) return;
|
||||
function sync() {
|
||||
if (box) box.hidden = sel.value !== 'poll';
|
||||
if (bounty) bounty.hidden = sel.value !== 'bounty';
|
||||
if (qHint) qHint.hidden = sel.value !== 'question';
|
||||
}
|
||||
sel.addEventListener('change', sync);
|
||||
|
||||
@@ -104,6 +104,23 @@
|
||||
</div>
|
||||
{{end}}
|
||||
</header>
|
||||
{{if .Bounty}}
|
||||
<section class="j13-bounty" aria-label="悬赏">
|
||||
<h2 class="j13-bounty__title">悬赏</h2>
|
||||
<p class="j13-muted">
|
||||
{{if eq .Bounty.Status "refunded"}}已退回{{else}}{{.Bounty.Points}} 积分{{end}}
|
||||
· {{.Bounty.StatusLabel}}
|
||||
</p>
|
||||
{{if .Bounty.CanRefund}}
|
||||
<form method="post" action="/post/{{.PostID}}/bounty/refund" class="j13-inline-form" onsubmit="return confirm('确认取消悬赏并退回积分?');">
|
||||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||||
<button type="submit" class="j13-btn-secondary">取消悬赏并退回</button>
|
||||
</form>
|
||||
{{else if .Bounty.RefundBlockReason}}
|
||||
<p class="j13-muted">{{.Bounty.RefundBlockReason}}</p>
|
||||
{{end}}
|
||||
</section>
|
||||
{{end}}
|
||||
{{if .Poll}}
|
||||
<section class="j13-poll" aria-label="投票">
|
||||
<h2 class="j13-poll__title">投票</h2>
|
||||
@@ -173,6 +190,7 @@
|
||||
<span>{{.CreatedLabel}}</span>
|
||||
{{if .StatusLabel}}<span class="j13-tag j13-tag--{{.Status}}">{{.StatusLabel}}</span>{{end}}
|
||||
{{if .IsPrivate}}<span class="j13-tag">私密</span>{{end}}
|
||||
{{if .IsBountyAward}}<span class="j13-tag j13-tag--resolved">已采纳</span>{{end}}
|
||||
{{if .ReplyToFloor}}
|
||||
<span class="j13-comment__reply-to">回复 <a href="#floor-{{.ReplyToFloor}}">#{{.ReplyToFloor}}</a>{{if .ReplyToAuthor}} {{.ReplyToAuthor}}{{end}}</span>
|
||||
{{end}}
|
||||
@@ -184,6 +202,13 @@
|
||||
{{end}}
|
||||
{{if $.LoggedIn}}
|
||||
<div class="j13-comment__actions">
|
||||
{{if .CanAwardBounty}}
|
||||
<form method="post" action="/post/{{$.PostID}}/bounty/award" class="j13-inline-form">
|
||||
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
|
||||
<input type="hidden" name="comment_id" value="{{.ID}}"/>
|
||||
<button type="submit">采纳并发放悬赏</button>
|
||||
</form>
|
||||
{{end}}
|
||||
<form method="post" action="/post/{{$.PostID}}/comments/{{.ID}}/like" class="j13-inline-form">
|
||||
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
|
||||
<button type="submit" class="j13-linkbtn">{{if .Liked}}取消赞{{else}}赞{{end}} ({{.LikeCount}})</button>
|
||||
|
||||
Reference in New Issue
Block a user