feat: migrate platform login scenes and native login flows

This commit is contained in:
2026-09-06 09:06:00 +08:00
parent f2a948f059
commit 695d3be25c
140 changed files with 7599 additions and 4397 deletions
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "8650f2a7-9471-4a3e-bec9-0aecf6405cdb",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,42 @@
import type { RemoteConfig } from '../config/remote-config.ts';
/** Defaults owned here reproduce 04_Data.js and Game_Surface_3 Debugger. */
const LOGIN_DEFAULTS = Object.freeze({ deviceLogin:0, showVisitor:0, qqLogin:0,
avatarUrl:'https://projectimage.tscce.cn/image_132/', avatarRange:[100,10000] as readonly number[],
hiddenVisitor:true });
export interface LoginPolicy {
deviceLogin:boolean; showVisitor:boolean; qqLogin:boolean; hiddenVisitor:boolean;
avatarUrl:string; avatarRange:readonly number[];
}
function flag(value:unknown, name:string):boolean {
if (![0,1,false,true].includes(value as number)) throw Error(`Invalid login config ${name}`);
return Boolean(value);
}
export function resolveLoginPolicy(remote:RemoteConfig):LoginPolicy {
const hallValue=remote.getValue('hall_config');
if (hallValue != null && (typeof hallValue!=='object' || Array.isArray(hallValue))) throw Error('Invalid hall_config');
const hall=hallValue as Record<string,unknown> | null;
// Legacy hall_config merge precedes hallConfigName top-level overrides.
const hallField=(name:'showVisitor'|'qqLogin')=> {
const override=remote.getValue(name);
if(override!=null) return override;
return hall && Object.prototype.hasOwnProperty.call(hall,name)?hall[name]:LOGIN_DEFAULTS[name];
};
const sourceField=(name:'deviceLogin'|'avatarUrl'|'avatarRange')=> {
const value=remote.getValue(name);return value==null?LOGIN_DEFAULTS[name]:value;
};
const avatarUrl=sourceField('avatarUrl'),range=sourceField('avatarRange');
if(typeof avatarUrl!=='string')throw Error('Invalid login config avatarUrl');
if(!Array.isArray(range)||range.length!==2||range.some(v=>!Number.isInteger(v))||range[1]<=range[0])throw Error('Invalid login config avatarRange');
return Object.freeze({deviceLogin:flag(sourceField('deviceLogin'),'deviceLogin'),
showVisitor:flag(hallField('showVisitor'),'showVisitor'),qqLogin:flag(hallField('qqLogin'),'qqLogin'),
hiddenVisitor:LOGIN_DEFAULTS.hiddenVisitor,avatarUrl,avatarRange:Object.freeze([...range])});
}
/** Assignment order is significant: JumpWxAuth applies showVisitor/QQ after cache hiding. */
export function loginButtons(policy:LoginPolicy, versionState:0|1, cached:boolean) {
const account=versionState===0&&cached;
let wechat=!policy.deviceLogin&&!account;
let visitor=!account;
if(versionState===0){visitor=false;if(policy.showVisitor){wechat=false;visitor=true;}}
return {wechat,visitor,phone:policy.deviceLogin&&!account,quick:false,qq:policy.qqLogin,account};
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "fe78702a-5e02-4006-844c-15123d950d80",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "093506bf-570f-47f8-9f4d-0a87d78cba2e",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "024324ab-1239-4568-9b72-5f957e32ba15",
"files": [],
"subMetas": {},
"userData": {}
}
@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "e6f7adfb-42be-43ed-a658-73aac741e2f2",
"files": [],
"subMetas": {},
"userData": {}
}