make query string right

This commit is contained in:
Ben Chang 2024-12-17 09:54:20 +08:00
parent 2969180fd1
commit 35b45fb3a6
2 changed files with 12 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import (
"net/http"
"path"
"strings"
html_template "html/template"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/organization"
@ -112,11 +113,11 @@ func home(ctx *context.Context, viewRepositories bool) {
ctx.Data["ShowMemberAndTeamTab"] = ctx.Org.IsMember || len(members) > 0
currentURL := ctx.Req.URL
queryParams := currentURL.Query()
queryParams := currentURL.Query()
queryParams.Set("view_as", "member")
ctx.Data["QueryForMember"] = queryParams.Encode()
ctx.Data["QueryForMember"] = html_template.URL(queryParams.Encode())
queryParams.Set("view_as", "public")
ctx.Data["QueryForPublic"] = queryParams.Encode()
ctx.Data["QueryForPublic"] = html_template.URL(queryParams.Encode())
isViewerMember := ctx.FormString("view_as") == "member"
ctx.Data["IsViewerMember"] = isViewerMember

View File

@ -5,6 +5,14 @@
<div class="ui container">
<div class="ui mobile reversed stackable grid">
<div class="ui {{if .ShowMemberAndTeamTab}}eleven wide{{end}} column">
<div class="item ui small dropdown jump">
<span class="text">view as</span>
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu">
<a href="{{$.Org.HomeLink}}?{{.QueryForPublic}}" class="{{if not .IsViewerMember}}active {{end}}item"><input hidden type="radio" {{if not .IsViewerMember}}checked{{end}}> Public</a>
<a href="{{$.Org.HomeLink}}?{{.QueryForMember}}" class="{{if .IsViewerMember}}active {{end}}item"><input hidden type="radio" {{if .IsViewerMember}}checked{{end}}> Member</a>
</div>
</div>
{{if .IsViewerMember}}
{{if .PrivateProfileReadme}}
<div id="readme_profile" class="markup">{{.PrivateProfileReadme}}</div>