fix: 扫码登录后保留会话并补上余量语言参数

This commit is contained in:
Nixevol
2026-10-16 16:40:15 +08:00
parent 89b3160a21
commit def0b08784
3 changed files with 14 additions and 2 deletions
+4 -1
View File
@@ -226,9 +226,12 @@ func (c *Client) Query(ctx context.Context, phone string) (Snapshot, error) {
extra.Set("language", c.plan.Language)
}
plan, err := c.postBill(ctx, c.plan, extra)
if err != nil {
if err != nil && !errors.Is(err, ErrNeedLogin) {
return BuildSnapshot(phone, balance, nil), err
}
if err != nil {
return BuildSnapshot(phone, balance, nil), nil
}
return BuildSnapshot(phone, balance, plan), nil
}
+1 -1
View File
@@ -53,7 +53,7 @@ var (
queryKeyRE = regexp.MustCompile(`(?:VUE_APP_KEY_QUERY|key_query):"([^"]+)"`)
httpsHostRE = regexp.MustCompile(`"(https://[a-zA-Z0-9.-]+\.10010\.com)"`)
versionRE = regexp.MustCompile(`version:"([^"]+)"`)
languageRE = regexp.MustCompile(`language:"([^"]+)"`)
languageRE = regexp.MustCompile(`(?:language|languageType)\s*[:=]\s*"([^"]+)"`)
jsPathRE = regexp.MustCompile(`["']([^"']+\.js(?:\?[^"']*)?)["']`)
)
+9
View File
@@ -78,6 +78,15 @@ func TestParseBillAPI(t *testing.T) {
}
}
func TestParseBillLanguageType(t *testing.T) {
js := `VUE_APP_XX_BASE_URL:"https://bill.example.10010.com",key_query:"servicequerybusiness",version:"WT",languageType="chinese"
m("".concat(g.c,"/operationservice/queryOcsPackageFlowLeftContentRevisedInJune"),e)`
api, ok := parseBillAPI(js, "https://img.example.10010.com/plan/index.html", "/operationservice/queryOcsPackageFlowLeftContentRevisedInJune")
if !ok || api.Language != "chinese" {
t.Fatalf("%v %#v", ok, api)
}
}
func TestResolveNav(t *testing.T) {
texts := []string{
`function getNavJson(){ var url = CommonsVariables.QueryRequestPrefix() +'/QueryNavigations'; }`,