chore: fix remarks shadowrocket subscription (#4247)

This commit is contained in:
Harry NG 2026-05-11 13:24:22 +07:00 committed by GitHub
parent e20d73ba7e
commit 9f06bffbea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 54 additions and 41 deletions

View file

@ -37,6 +37,8 @@ const lastOnlineMs = Number(subData.lastOnline || 0);
const subUrl = subData.subUrl || ''; const subUrl = subData.subUrl || '';
const subJsonUrl = subData.subJsonUrl || ''; const subJsonUrl = subData.subJsonUrl || '';
const subClashUrl = subData.subClashUrl || ''; const subClashUrl = subData.subClashUrl || '';
const subTitle = subData.subTitle || '';
const subSupportUrl = subData.subSupportUrl || '';
const links = Array.isArray(subData.links) ? subData.links : []; const links = Array.isArray(subData.links) ? subData.links : [];
// Panel's "Calendar Type" setting; controls whether expiry / lastOnline // Panel's "Calendar Type" setting; controls whether expiry / lastOnline
// render in Gregorian or Jalali on this standalone subscription page. // render in Gregorian or Jalali on this standalone subscription page.
@ -102,7 +104,14 @@ function linkName(link, idx) {
// iOS deep links taken verbatim from the legacy subpage. Each // iOS deep links taken verbatim from the legacy subpage. Each
// client expects the sub URL in a slightly different param name. // client expects the sub URL in a slightly different param name.
const shadowrocketUrl = computed(() => `sub://${btoa(subUrl)}`); const shadowrocketUrl = computed(() => {
if (!subUrl) return '';
const separator = subUrl.includes('?') ? '&' : '?';
const rawUrl = subUrl + separator + 'flag=shadowrocket';
const base64Url = encodeURIComponent(btoa(rawUrl));
const remark = encodeURIComponent(subTitle || sId || 'Subscription');
return `shadowrocket://add/sub/${base64Url}?remark=${remark}`;
});
const v2boxUrl = computed(() => `v2box://install-sub?url=${encodeURIComponent(subUrl)}&name=${encodeURIComponent(sId)}`); const v2boxUrl = computed(() => `v2box://install-sub?url=${encodeURIComponent(subUrl)}&name=${encodeURIComponent(sId)}`);
const streisandUrl = computed(() => `streisand://import/${encodeURIComponent(subUrl)}`); const streisandUrl = computed(() => `streisand://import/${encodeURIComponent(subUrl)}`);
const v2raytunUrl = computed(() => subUrl); const v2raytunUrl = computed(() => subUrl);

View file

@ -128,7 +128,7 @@ func (a *SUBController) subs(c *gin.Context) {
basePath = "/" basePath = "/"
} }
basePathStr := basePath.(string) basePathStr := basePath.(string)
page := a.subService.BuildPageData(subId, hostHeader, traffic, lastOnline, subs, subURL, subJsonURL, subClashURL, basePathStr) page := a.subService.BuildPageData(subId, hostHeader, traffic, lastOnline, subs, subURL, subJsonURL, subClashURL, basePathStr, a.subTitle, a.subSupportUrl)
a.serveSubPage(c, basePathStr, page) a.serveSubPage(c, basePathStr, page)
return return
} }

View file

@ -1431,6 +1431,8 @@ type PageData struct {
SubUrl string SubUrl string
SubJsonUrl string SubJsonUrl string
SubClashUrl string SubClashUrl string
SubTitle string
SubSupportUrl string
Result []string Result []string
} }
@ -1545,7 +1547,7 @@ func (s *SubService) joinPathWithID(basePath, subId string) string {
// BuildPageData parses header and prepares the template view model. // BuildPageData parses header and prepares the template view model.
// BuildPageData constructs page data for rendering the subscription information page. // BuildPageData constructs page data for rendering the subscription information page.
func (s *SubService) BuildPageData(subId string, hostHeader string, traffic xray.ClientTraffic, lastOnline int64, subs []string, subURL, subJsonURL, subClashURL string, basePath string) PageData { func (s *SubService) BuildPageData(subId string, hostHeader string, traffic xray.ClientTraffic, lastOnline int64, subs []string, subURL, subJsonURL, subClashURL string, basePath string, subTitle string, subSupportUrl string) PageData {
download := common.FormatTraffic(traffic.Down) download := common.FormatTraffic(traffic.Down)
upload := common.FormatTraffic(traffic.Up) upload := common.FormatTraffic(traffic.Up)
total := "∞" total := "∞"
@ -1581,6 +1583,8 @@ func (s *SubService) BuildPageData(subId string, hostHeader string, traffic xray
SubUrl: subURL, SubUrl: subURL,
SubJsonUrl: subJsonURL, SubJsonUrl: subJsonURL,
SubClashUrl: subClashURL, SubClashUrl: subClashURL,
SubTitle: subTitle,
SubSupportUrl: subSupportUrl,
Result: subs, Result: subs,
} }
} }