mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 三方登录由TV端替换为HD版
This commit is contained in:
@@ -10,10 +10,10 @@ class StyleString {
|
||||
|
||||
class Constants {
|
||||
// 27eb53fc9058f8c3 移动端 Android
|
||||
// 4409e2ce8ffd12b8 TV端
|
||||
static const String appKey = '4409e2ce8ffd12b8';
|
||||
// 4409e2ce8ffd12b8 HD版
|
||||
static const String appKey = 'dfca71928277209b';
|
||||
// 59b43e04ad6965f34319062b478f83dd TV端
|
||||
static const String appSec = '59b43e04ad6965f34319062b478f83dd';
|
||||
static const String appSec = 'b5475a8825547a4fc26c7d518eaaa02e';
|
||||
static const String thirdSign = '04224646d1fea004e79606d3b038c84a';
|
||||
static const String thirdApi =
|
||||
'https://www.mcbbs.net/template/mcbbs/image/special_photo_bg.png';
|
||||
|
||||
@@ -461,12 +461,12 @@ class Api {
|
||||
static const getWebKey = '${HttpString.passBaseUrl}/x/passport-login/web/key';
|
||||
|
||||
/// cookie转access_key
|
||||
static const cookieToKey =
|
||||
static const qrcodeConfirm =
|
||||
'${HttpString.passBaseUrl}/x/passport-tv-login/h5/qrcode/confirm';
|
||||
|
||||
/// 申请二维码(TV端)
|
||||
static const getTVCode =
|
||||
'https://passport.snm0516.aisee.tv/x/passport-tv-login/qrcode/auth_code';
|
||||
'https://passport.bilibili.com/x/passport-tv-login/qrcode/auth_code';
|
||||
|
||||
///扫码登录(TV端)
|
||||
static const qrcodePoll =
|
||||
|
||||
@@ -377,11 +377,14 @@ class MemberHttp {
|
||||
|
||||
// 获取TV authCode
|
||||
static Future getTVCode() async {
|
||||
SmartDialog.showLoading();
|
||||
SmartDialog.showLoading(msg: "正在申请HD版二维码...");
|
||||
var params = {
|
||||
'appkey': Constants.appKey,
|
||||
// 'local_id': 'Y952A395BB157D305D8A8340FC2AAECECE17',
|
||||
'local_id': '0',
|
||||
'ts': (DateTime.now().millisecondsSinceEpoch ~/ 1000).toString(),
|
||||
'ts': DateTime.now().millisecondsSinceEpoch.toString(),
|
||||
'platform': 'android',
|
||||
'mobi_app': 'android_hd',
|
||||
};
|
||||
String sign = Utils.appSign(
|
||||
params,
|
||||
@@ -390,7 +393,10 @@ class MemberHttp {
|
||||
);
|
||||
var res = await Request()
|
||||
.post(Api.getTVCode, queryParameters: {...params, 'sign': sign});
|
||||
SmartDialog.dismiss();
|
||||
print(res.data);
|
||||
if (res.data['code'] == 0) {
|
||||
print("getTVCode");
|
||||
return {
|
||||
'status': true,
|
||||
'data': res.data['data']['auth_code'],
|
||||
@@ -400,7 +406,7 @@ class MemberHttp {
|
||||
return {
|
||||
'status': false,
|
||||
'data': [],
|
||||
'msg': res.data['message'],
|
||||
'msg': res.data,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -409,22 +415,45 @@ class MemberHttp {
|
||||
static Future cookieToKey() async {
|
||||
var authCodeRes = await getTVCode();
|
||||
if (authCodeRes['status']) {
|
||||
var res = await Request().post(Api.cookieToKey, queryParameters: {
|
||||
SmartDialog.showLoading(msg: "正在确认登录...");
|
||||
var confirmRes = await Request().post(Api.qrcodeConfirm, queryParameters: {
|
||||
'auth_code': authCodeRes['data'],
|
||||
'build': 708200,
|
||||
'local_id': '0',
|
||||
'build': 1442100,
|
||||
'scanning_type': 1,
|
||||
'csrf': await Request.getCsrf(),
|
||||
});
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
await qrcodePoll(authCodeRes['data']);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': [], 'msg': '操作成功'};
|
||||
print("confirmRes");
|
||||
print(confirmRes);
|
||||
SmartDialog.dismiss();
|
||||
if (confirmRes.data['code'] != 0) {
|
||||
return {
|
||||
'status': false,
|
||||
'data': [],
|
||||
'msg': "确认登录失败:${confirmRes.data['message']}",
|
||||
};
|
||||
}
|
||||
SmartDialog.showLoading(msg: "等待500毫秒...");
|
||||
await Future.delayed(const Duration(milliseconds: 500));
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showLoading(msg: "正在获取登录结果(含access_key)...");
|
||||
var res = await qrcodePoll(authCodeRes['data']);
|
||||
SmartDialog.dismiss();
|
||||
if (res['status']) {
|
||||
return {'status': true, 'data': [], 'msg': res['message']};
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
'data': [],
|
||||
'msg': res.data['message'],
|
||||
'msg': "登录结果获取失败:${res.data['message']}",
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
'data': [],
|
||||
'msg': "TV版二维码申请失败:${authCodeRes['msg']}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +471,6 @@ class MemberHttp {
|
||||
);
|
||||
var res = await Request()
|
||||
.post(Api.qrcodePoll, queryParameters: {...params, 'sign': sign});
|
||||
SmartDialog.dismiss();
|
||||
if (res.data['code'] == 0) {
|
||||
String accessKey = res.data['data']['access_token'];
|
||||
Box localCache = GStrorage.localCache;
|
||||
@@ -450,7 +478,7 @@ class MemberHttp {
|
||||
var userInfo = userInfoCache.get('userInfoCache');
|
||||
localCache.put(
|
||||
LocalCacheKey.accessKey, {'mid': userInfo.mid, 'value': accessKey});
|
||||
return {'status': true, 'data': [], 'msg': '操作成功'};
|
||||
return {'status': true, 'data': [], 'message': '操作成功,当前获取的access_key为:$accessKey'};
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
|
||||
@@ -69,11 +69,17 @@ class _PrivacySettingState extends State<PrivacySetting> {
|
||||
leading: const Icon(Icons.block),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
onTap: () async {
|
||||
if (!userLogin) {
|
||||
SmartDialog.showToast('请先登录');
|
||||
return;
|
||||
}
|
||||
var res = await MemberHttp.cookieToKey();
|
||||
if (res['status']) {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
} else {
|
||||
SmartDialog.showToast('刷新失败:${res['msg']}');
|
||||
}
|
||||
MemberHttp.cookieToKey();
|
||||
},
|
||||
dense: false,
|
||||
title: Text('刷新access_key', style: titleStyle),
|
||||
|
||||
Reference in New Issue
Block a user