mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5079] [MERGED] feat: customizable subscription page templates #5773
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5773
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5079
Author: @rqzbeh
Created: 6/8/2026
Status: ✅ Merged
Merged: 6/8/2026
Merged by: @MHSanaei
Base:
main← Head:feature/custom-sub-templates📝 Commits (10+)
900c080feat: add support for subscription-based outbounds with auto-update9f8a186Merge pull request #1 from rqzbeh/feat/outbound-subscriptionscbb0653Merge branch 'main' into main37d2cb7Merge branch 'main' into mainf9dbf1ffix: resolve frontend lint/type errors and Go build break5c7c72afix(xray): make outbound subscription creation work end-to-end602162efeat(xray): show traffic/test for subscription outbounds; harden + test the feature837286cfix(xray): make outbound-subs feature pass CI (test compile, route docs, openapi)ddbb1befeat(xray): per-subscription allow-private, gap-filled tags, UI tweaks, delete refreshb3d97c6i18n(xray): translate outbound-subscription UI into all locales📊 Changes
25 files changed (+369 additions, -21 deletions)
View changed files
📝
frontend/public/openapi.json(+10 -0)📝
frontend/src/generated/examples.ts(+2 -0)📝
frontend/src/generated/schemas.ts(+10 -0)📝
frontend/src/generated/types.ts(+2 -0)📝
frontend/src/generated/zod.ts(+2 -0)📝
frontend/src/models/setting.ts(+1 -0)📝
frontend/src/pages/settings/SubscriptionGeneralTab.tsx(+5 -0)📝
sub/subController.go(+111 -21)➕
sub/subController_test.go(+149 -0)➕
sub_templates/README.md(+44 -0)📝
web/entity/entity.go(+1 -0)📝
web/service/setting.go(+6 -0)📝
web/translation/ar-EG.json(+2 -0)📝
web/translation/en-US.json(+2 -0)📝
web/translation/es-ES.json(+2 -0)📝
web/translation/fa-IR.json(+2 -0)📝
web/translation/id-ID.json(+2 -0)📝
web/translation/ja-JP.json(+2 -0)📝
web/translation/pt-BR.json(+2 -0)📝
web/translation/ru-RU.json(+2 -0)...and 5 more files
📄 Description
Summary
Adds support for custom subscription page HTML templates. Panel admins can replace the default React subscription page with their own HTML template, rendered server-side with Go's
html/template.How it works
When a browser opens a subscription URL, if the Sub Theme Directory setting points to a folder containing
sub.htmlorindex.html, that template is rendered with all subscription data injected as template variables (sub.htmltakes precedence overindex.html).If the path is empty, missing, not a directory, or the template fails to parse/execute, the panel logs the reason and falls back to the default built-in React page — the response is rendered into a buffer first, so a failed template can never leave a half-written/corrupt response.
Rendering notes:
html/templateis used deliberately: its context-aware auto-escaping protects against XSS from user-influenced data (e.g. remarks inside config links).New setting: Sub Theme Directory
Settings → Subscription → Information → Sub Theme Directory
Set it to an absolute path (e.g.
/etc/3x-ui/sub_templates/my-theme/) to activate a custom template; leave it empty for the default page. The setting is read live per request (no restart needed) and its label/description are translated into all locales.Available template variables
.sId.enabled.download/.upload.total/.used/.remained.downloadByte/.uploadByte/.totalByte.expire0= never).lastOnline0= never).subUrl/.subJsonUrl/.subClashUrl.subTitle.subSupportUrl.links{{ range .links }}…{{ end }}).emails.datepicker"gregorian"or"jalali"The authoring guide lives in
sub_templates/README.md.Files changed
sub/subController.goIsDirguard + diagnostic logs,subTitle/subSupportUrlvariablessub/subController_test.gosub.htmlprecedence, fallback cases, malformed template, mtime cache invalidationweb/service/setting.go,web/entity/entity.gosubThemeDirsetting default +GetSubThemeDir()frontend/src/models/setting.ts,frontend/src/pages/settings/SubscriptionGeneralTab.tsxweb/translation/*.jsonsubThemeDir/subThemeDirDescin all localessub_templates/README.mdTesting
Verified end-to-end in Docker:
subTitle/subSupportUrl).sub.htmltakes precedence overindex.html.superfluous WriteHeadernever occurs).Go unit tests cover the loader; frontend
lint+typecheckpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.