feat: 港澳台模式

This commit is contained in:
guozhigq
2024-06-29 18:47:04 +08:00
parent 922b815ebd
commit 5621c2d8e3
3 changed files with 35 additions and 8 deletions

View File

@ -27,11 +27,13 @@ class Request {
late bool enableSystemProxy;
late String systemProxyHost;
late String systemProxyPort;
static final RegExp spmPrefixExp = RegExp(r'<meta name="spm_prefix" content="([^"]+?)">');
static final RegExp spmPrefixExp =
RegExp(r'<meta name="spm_prefix" content="([^"]+?)">');
/// 设置cookie
static setCookie() async {
Box userInfoCache = GStrorage.userInfo;
Box setting = GStrorage.setting;
final String cookiePath = await Utils.getCookiePath();
final PersistCookieJar cookieJar = PersistCookieJar(
ignoreExpires: true,
@ -54,7 +56,11 @@ class Request {
}
}
setOptionsHeaders(userInfo, userInfo != null && userInfo.mid != null);
String baseUrlType = 'default';
if (setting.get(SettingBoxKey.enableGATMode, defaultValue: false)) {
baseUrlType = 'bangumi';
}
setBaseUrl(type: baseUrlType);
try {
await buvidActivate();
} catch (e) {
@ -98,8 +104,7 @@ class Request {
List<int>.generate(32, (_) => rand.nextInt(256)) +
List<int>.filled(4, 0) +
[73, 69, 78, 68] +
List<int>.generate(4, (_) => rand.nextInt(256))
);
List<int>.generate(4, (_) => rand.nextInt(256)));
String jsonData = json.encode({
'3064': 1,
@ -110,11 +115,9 @@ class Request {
},
});
await Request().post(
Api.activateBuvidApi,
await Request().post(Api.activateBuvidApi,
data: {'payload': jsonData},
options: Options(contentType: 'application/json')
);
options: Options(contentType: 'application/json'));
}
/*
@ -303,4 +306,17 @@ class Request {
}
return headerUa;
}
static setBaseUrl({String type = 'default'}) {
switch (type) {
case 'default':
dio.options.baseUrl = HttpString.apiBaseUrl;
break;
case 'bangumi':
dio.options.baseUrl = HttpString.bangumiBaseUrl;
break;
default:
dio.options.baseUrl = HttpString.apiBaseUrl;
}
}
}