// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . package portal import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeUser/internal/configloaders" teaconst "github.com/TeaOSLab/EdgeUser/internal/const" "github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeUser/internal/web/helpers" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" timeutil "github.com/iwind/TeaGo/utils/time" ) type LayoutAction struct { actionutils.PortalAction } func (this *LayoutAction) Init() { this.Nav("", "", "") } func (this *LayoutAction) RunGet(params struct { Auth *helpers.UserShouldAuth }) { // is logged? this.Data["userIsLogged"] = params.Auth != nil && params.Auth.UserId() > 0 // service { postResp, err := this.RPC().PostRPC().ListPosts(this.UserContext(), &pb.ListPostsRequest{ Offset: 0, Size: 5, ProductCode: "global", PostCategoryId: 0, PostCategoryCode: "support", ExcludingPostCategoryCode: "", PublishedOnly: true, ContainsBody: false, }) if err != nil { this.ErrorPage(err) return } var postMaps = []maps.Map{} for _, post := range postResp.Posts { postMaps = append(postMaps, maps.Map{ "id": post.Id, "subject": post.Subject, "publishedTime": timeutil.FormatTime("Y-m-d", post.PublishedAt), }) } this.Data["supportPosts"] = postMaps } // product name, logo ... uiConfig, err := configloaders.LoadUIConfig() if err != nil { this.ErrorPage(err) return } var productName = teaconst.ProductName if uiConfig != nil && len(uiConfig.ProductName) > 0 { productName = uiConfig.ProductName } this.Data["productName"] = productName var logoURL = "" if uiConfig != nil && uiConfig.Portal.LogoFileId > 0 { logoURL = "/ui/image/" + types.String(uiConfig.Portal.LogoFileId) } this.Data["logoURL"] = logoURL this.Success() }