mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 08:08:19 +08:00
allow desktop login by pwd
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -10,6 +10,7 @@ import 'package:PiliPlus/models/common/account_type.dart';
|
|||||||
import 'package:PiliPlus/models/login/model.dart';
|
import 'package:PiliPlus/models/login/model.dart';
|
||||||
import 'package:PiliPlus/utils/accounts.dart';
|
import 'package:PiliPlus/utils/accounts.dart';
|
||||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||||
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -25,23 +26,23 @@ class LoginPageController extends GetxController
|
|||||||
final TextEditingController smsCodeTextController = TextEditingController();
|
final TextEditingController smsCodeTextController = TextEditingController();
|
||||||
final TextEditingController cookieTextController = TextEditingController();
|
final TextEditingController cookieTextController = TextEditingController();
|
||||||
|
|
||||||
RxMap<String, dynamic> codeInfo = RxMap<String, dynamic>({});
|
late final RxMap<String, dynamic> codeInfo = RxMap<String, dynamic>({});
|
||||||
|
|
||||||
late TabController tabController;
|
late final TabController tabController;
|
||||||
|
|
||||||
late final Gt3FlutterPlugin captcha = Gt3FlutterPlugin();
|
late final Gt3FlutterPlugin captcha = Gt3FlutterPlugin();
|
||||||
|
|
||||||
CaptchaDataModel captchaData = CaptchaDataModel();
|
late final CaptchaDataModel captchaData = CaptchaDataModel();
|
||||||
RxInt qrCodeLeftTime = 180.obs;
|
late final RxInt qrCodeLeftTime = 180.obs;
|
||||||
RxString statusQRCode = ''.obs;
|
late final RxString statusQRCode = ''.obs;
|
||||||
|
|
||||||
late final List<Map<String, dynamic>> internationalDialingPrefix =
|
late final List<Map<String, dynamic>> internationalDialingPrefix =
|
||||||
Constants.internationalDialingPrefix;
|
Constants.internationalDialingPrefix;
|
||||||
late Map<String, dynamic> selectedCountryCodeId =
|
late Map<String, dynamic> selectedCountryCodeId =
|
||||||
internationalDialingPrefix.first;
|
internationalDialingPrefix.first;
|
||||||
String captchaKey = '';
|
late String captchaKey = '';
|
||||||
RxInt smsSendCooldown = 0.obs;
|
late final RxInt smsSendCooldown = 0.obs;
|
||||||
int smsSendTimestamp = 0;
|
late int smsSendTimestamp = 0;
|
||||||
|
|
||||||
// 定时器
|
// 定时器
|
||||||
Timer? qrCodeTimer;
|
Timer? qrCodeTimer;
|
||||||
@@ -79,7 +80,7 @@ class LoginPageController extends GetxController
|
|||||||
if (qrCodeLeftTime <= 0) {
|
if (qrCodeLeftTime <= 0) {
|
||||||
t.cancel();
|
t.cancel();
|
||||||
statusQRCode.value = '二维码已过期,请刷新';
|
statusQRCode.value = '二维码已过期,请刷新';
|
||||||
qrCodeLeftTime = 0.obs;
|
qrCodeLeftTime.value = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@ class LoginPageController extends GetxController
|
|||||||
Get.back();
|
Get.back();
|
||||||
} else if (value['code'] == 86038) {
|
} else if (value['code'] == 86038) {
|
||||||
t.cancel();
|
t.cancel();
|
||||||
qrCodeLeftTime = 0.obs;
|
qrCodeLeftTime.value = 0;
|
||||||
} else {
|
} else {
|
||||||
statusQRCode.value = value['msg'];
|
statusQRCode.value = value['msg'];
|
||||||
}
|
}
|
||||||
@@ -290,6 +291,9 @@ class LoginPageController extends GetxController
|
|||||||
}
|
}
|
||||||
if (data['status'] == 2) {
|
if (data['status'] == 2) {
|
||||||
SmartDialog.showToast(data['message']);
|
SmartDialog.showToast(data['message']);
|
||||||
|
if (!Utils.isMobile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// return;
|
// return;
|
||||||
//{"code":0,"message":"0","ttl":1,"data":{"status":2,"message":"本次登录环境存在风险, 需使用手机号进行验证或绑定","url":"https://passport.bilibili.com/h5-app/passport/risk/verify?tmp_token=9e785433940891dfa78f033fb7928181&request_id=e5a6d6480df04097870be56c6e60f7ef&source=risk","token_info":null,"cookie_info":null,"sso":null,"is_new":false,"is_tourist":false}}
|
//{"code":0,"message":"0","ttl":1,"data":{"status":2,"message":"本次登录环境存在风险, 需使用手机号进行验证或绑定","url":"https://passport.bilibili.com/h5-app/passport/risk/verify?tmp_token=9e785433940891dfa78f033fb7928181&request_id=e5a6d6480df04097870be56c6e60f7ef&source=risk","token_info":null,"cookie_info":null,"sso":null,"is_new":false,"is_tourist":false}}
|
||||||
String url = data['url']!;
|
String url = data['url']!;
|
||||||
@@ -313,6 +317,7 @@ class LoginPageController extends GetxController
|
|||||||
SmartDialog.showToast("当前账号未支持手机号验证,请尝试其它登录方式");
|
SmartDialog.showToast("当前账号未支持手机号验证,请尝试其它登录方式");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextEditingController textFieldController = TextEditingController();
|
TextEditingController textFieldController = TextEditingController();
|
||||||
String captchaKey = '';
|
String captchaKey = '';
|
||||||
Get.dialog(
|
Get.dialog(
|
||||||
@@ -474,7 +479,7 @@ class LoginPageController extends GetxController
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
).whenComplete(textFieldController.dispose);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -493,7 +498,7 @@ class LoginPageController extends GetxController
|
|||||||
case 0:
|
case 0:
|
||||||
// login success
|
// login success
|
||||||
break;
|
break;
|
||||||
case -105:
|
case -105 when (Utils.isMobile):
|
||||||
String captureUrl = res['data']['url'];
|
String captureUrl = res['data']['url'];
|
||||||
Uri captureUri = Uri.parse(captureUrl);
|
Uri captureUri = Uri.parse(captureUrl);
|
||||||
captchaData.token = captureUri.queryParameters['recaptcha_token']!;
|
captchaData.token = captureUri.queryParameters['recaptcha_token']!;
|
||||||
|
|||||||
@@ -191,7 +191,6 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
enabled: isMobile,
|
|
||||||
controller: _loginPageCtr.usernameTextController,
|
controller: _loginPageCtr.usernameTextController,
|
||||||
inputFormatters: [FilteringTextInputFormatter.deny(RegExp(r"\s"))],
|
inputFormatters: [FilteringTextInputFormatter.deny(RegExp(r"\s"))],
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
@@ -209,7 +208,6 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||||
child: TextField(
|
child: TextField(
|
||||||
enabled: isMobile,
|
|
||||||
obscureText: !showPassword,
|
obscureText: !showPassword,
|
||||||
keyboardType: TextInputType.visiblePassword,
|
keyboardType: TextInputType.visiblePassword,
|
||||||
inputFormatters: [FilteringTextInputFormatter.deny(RegExp(r"\s"))],
|
inputFormatters: [FilteringTextInputFormatter.deny(RegExp(r"\s"))],
|
||||||
@@ -231,9 +229,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Checkbox(
|
Checkbox(
|
||||||
value: showPassword,
|
value: showPassword,
|
||||||
onChanged: isMobile
|
onChanged: (value) => setState(() => showPassword = value!),
|
||||||
? (value) => setState(() => showPassword = value!)
|
|
||||||
: null,
|
|
||||||
),
|
),
|
||||||
const Text('显示密码'),
|
const Text('显示密码'),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
@@ -312,7 +308,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
OutlinedButton.icon(
|
OutlinedButton.icon(
|
||||||
onPressed: isMobile ? _loginPageCtr.loginByPassword : null,
|
onPressed: _loginPageCtr.loginByPassword,
|
||||||
icon: const Icon(Icons.login),
|
icon: const Icon(Icons.login),
|
||||||
label: const Text('登录'),
|
label: const Text('登录'),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user