mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-05 12:44:22 +00:00
Mirror the ClientInfoModal redesign on the public SubPage so the subscription viewer reads as a tight `[PROTO] [remark] [copy] [QR]` row per link instead of raw URL cards. - subService.GetSubs now returns the per-link email list alongside the links, threaded through subController and BuildPageData into the `emails` field on subData (env.d.ts updated). Public links.go is updated to ignore the new return. - SubPage strips the client email from each row title using the matched per-link email (same trimEmail behaviour as the modal), and hides the QR button for post-quantum links (`pqv=`, `mlkem768`, `mldsa65`) since the encoded URL won't fit in a single QR.
60 lines
1.3 KiB
Go
60 lines
1.3 KiB
Go
package sub
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/mhsanaei/3x-ui/v3/database/model"
|
|
"github.com/mhsanaei/3x-ui/v3/web/service"
|
|
)
|
|
|
|
type LinkProvider struct {
|
|
settingService service.SettingService
|
|
}
|
|
|
|
func NewLinkProvider() *LinkProvider {
|
|
return &LinkProvider{}
|
|
}
|
|
|
|
func (p *LinkProvider) build(host string) *SubService {
|
|
showInfo, _ := p.settingService.GetSubShowInfo()
|
|
rModel, err := p.settingService.GetRemarkModel()
|
|
if err != nil {
|
|
rModel = "-ieo"
|
|
}
|
|
svc := NewSubService(showInfo, rModel)
|
|
svc.PrepareForRequest(host)
|
|
return svc
|
|
}
|
|
|
|
func (p *LinkProvider) SubLinksForSubId(host, subId string) ([]string, error) {
|
|
svc := p.build(host)
|
|
links, _, _, _, err := svc.GetSubs(subId, host)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out := make([]string, 0, len(links))
|
|
for _, l := range links {
|
|
out = append(out, splitLinkLines(l)...)
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (p *LinkProvider) LinksForClient(host string, inbound *model.Inbound, email string) []string {
|
|
svc := p.build(host)
|
|
svc.projectThroughFallbackMaster(inbound)
|
|
return splitLinkLines(svc.GetLink(inbound, email))
|
|
}
|
|
|
|
func splitLinkLines(raw string) []string {
|
|
if raw == "" {
|
|
return nil
|
|
}
|
|
parts := strings.Split(raw, "\n")
|
|
out := make([]string, 0, len(parts))
|
|
for _, p := range parts {
|
|
if p = strings.TrimSpace(p); p != "" {
|
|
out = append(out, p)
|
|
}
|
|
}
|
|
return out
|
|
}
|