mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-21 01:26:59 +08:00
@@ -25,28 +25,28 @@ import 'package:get/get.dart';
|
||||
class LoginUtils {
|
||||
static final random = Random();
|
||||
|
||||
static Future setWebCookie([Account? account]) async {
|
||||
final cookies = (account ?? Accounts.main).cookieJar.toList();
|
||||
final webManager = web.CookieManager();
|
||||
return Future.wait(
|
||||
cookies.map(
|
||||
(cookie) => webManager.setCookie(
|
||||
url: web.WebUri(cookie.domain ?? ''),
|
||||
name: cookie.name,
|
||||
value: cookie.value,
|
||||
path: cookie.path ?? '/',
|
||||
domain: cookie.domain,
|
||||
isSecure: cookie.secure,
|
||||
isHttpOnly: cookie.httpOnly,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static Future<void> onLoginMain() async {
|
||||
final account = Accounts.main;
|
||||
GrpcReq.updateHeaders(account.accessKey);
|
||||
try {
|
||||
final cookies = account.cookieJar.toList();
|
||||
final webManager = web.CookieManager();
|
||||
Future.wait([
|
||||
...cookies.map(
|
||||
(item) => webManager.setCookie(
|
||||
url: web.WebUri(item.domain ?? ''),
|
||||
name: item.name,
|
||||
value: item.value,
|
||||
path: item.path ?? '',
|
||||
domain: item.domain,
|
||||
isSecure: item.secure,
|
||||
isHttpOnly: item.httpOnly,
|
||||
),
|
||||
),
|
||||
]);
|
||||
} catch (e) {
|
||||
SmartDialog.showToast('设置登录态失败,$e');
|
||||
}
|
||||
setWebCookie(account);
|
||||
final result = await UserHttp.userInfo();
|
||||
if (result.isSuccess) {
|
||||
final UserInfoData data = result.data;
|
||||
|
||||
@@ -67,15 +67,13 @@ class PageUtils {
|
||||
final shareListRes = await ImGrpc.shareList(size: 3);
|
||||
if (shareListRes.isSuccess && shareListRes.data.sessionList.isNotEmpty) {
|
||||
userList.addAll(
|
||||
shareListRes.data.sessionList
|
||||
.map<UserModel>(
|
||||
(item) => UserModel(
|
||||
mid: item.talkerId.toInt(),
|
||||
name: item.talkerUname,
|
||||
avatar: item.talkerIcon,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
shareListRes.data.sessionList.map<UserModel>(
|
||||
(item) => UserModel(
|
||||
mid: item.talkerId.toInt(),
|
||||
name: item.talkerUname,
|
||||
avatar: item.talkerIcon,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (context.mounted) {
|
||||
UserModel? userModel = await Navigator.of(context).push(
|
||||
|
||||
@@ -70,10 +70,7 @@ class Utils {
|
||||
String baseDirectory,
|
||||
List<String> shaders,
|
||||
) {
|
||||
List<String> absolutePaths = shaders.map((shader) {
|
||||
return path.join(baseDirectory, shader);
|
||||
}).toList();
|
||||
return absolutePaths.join(':');
|
||||
return shaders.map((shader) => path.join(baseDirectory, shader)).join(':');
|
||||
}
|
||||
|
||||
static final numericRegex = RegExp(r'^[\d\.]+$');
|
||||
|
||||
Reference in New Issue
Block a user