mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: account manager (#468)
* feat: account manager * remove dep * some fixes * migrate accounts * reimplement clearCookie
This commit is contained in:
committed by
GitHub
parent
94fa0652ac
commit
b15fdfa2ff
@@ -1,10 +1,9 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:PiliPlus/build_config.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/services/loggeer.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/login.dart';
|
||||
import 'package:cookie_jar/cookie_jar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -13,7 +12,6 @@ import 'package:package_info_plus/package_info_plus.dart';
|
||||
import 'package:PiliPlus/models/github/latest.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import '../../http/init.dart';
|
||||
import '../../utils/cache_manage.dart';
|
||||
|
||||
class AboutPage extends StatefulWidget {
|
||||
@@ -250,22 +248,8 @@ Commit Hash: ${BuildConfig.commitHash}''',
|
||||
title: const Text('导出'),
|
||||
onTap: () async {
|
||||
Get.back();
|
||||
dynamic accessKey = GStorage.localCache
|
||||
.get(LocalCacheKey.accessKey, defaultValue: {});
|
||||
dynamic cookies = (await Request.cookieManager.cookieJar
|
||||
.loadForRequest(Uri.parse(HttpString.baseUrl)))
|
||||
.map(
|
||||
(Cookie cookie) => {
|
||||
'name': cookie.name,
|
||||
'value': cookie.value,
|
||||
},
|
||||
)
|
||||
.toList();
|
||||
dynamic res = jsonEncode({
|
||||
'accessKey': accessKey,
|
||||
'cookies': cookies,
|
||||
});
|
||||
Utils.copyText('$res');
|
||||
String res = jsonEncode(Accounts.account.toMap());
|
||||
Utils.copyText(res);
|
||||
// if (context.mounted) {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
@@ -282,9 +266,7 @@ Commit Hash: ${BuildConfig.commitHash}''',
|
||||
Get.back();
|
||||
ClipboardData? data =
|
||||
await Clipboard.getData('text/plain');
|
||||
if (data == null ||
|
||||
data.text == null ||
|
||||
data.text!.isEmpty) {
|
||||
if (data?.text?.isNotEmpty != true) {
|
||||
SmartDialog.showToast('剪贴板无数据');
|
||||
return;
|
||||
}
|
||||
@@ -295,7 +277,7 @@ Commit Hash: ${BuildConfig.commitHash}''',
|
||||
return AlertDialog(
|
||||
title: const Text('是否导入以下登录信息?'),
|
||||
content: SingleChildScrollView(
|
||||
child: Text(data.text!),
|
||||
child: Text(data!.text!),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
@@ -309,14 +291,21 @@ Commit Hash: ${BuildConfig.commitHash}''',
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
try {
|
||||
dynamic res = jsonDecode(data.text!);
|
||||
LoginUtils.onLogin(
|
||||
res['accessKey'],
|
||||
{'cookies': res['cookies']},
|
||||
);
|
||||
final res = (jsonDecode(data.text!)
|
||||
as Map)
|
||||
.map((key, value) => MapEntry(key,
|
||||
LoginAccount.fromJson(value)));
|
||||
Accounts.account
|
||||
.putAll(res)
|
||||
.then((_) => Accounts.refresh())
|
||||
.then((_) {
|
||||
if (Accounts.main.isLogin) {
|
||||
return LoginUtils.onLoginMain();
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
SmartDialog.showToast('导入失败:$e');
|
||||
}
|
||||
@@ -448,6 +437,7 @@ Commit Hash: ${BuildConfig.commitHash}''',
|
||||
GStorage.localCache.clear(),
|
||||
GStorage.video.clear(),
|
||||
GStorage.historyWord.clear(),
|
||||
Accounts.clear(),
|
||||
]);
|
||||
SmartDialog.showToast('重置成功');
|
||||
},
|
||||
|
||||
@@ -2,14 +2,13 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
import 'package:PiliPlus/models/common/reply_type.dart';
|
||||
import 'package:PiliPlus/models/video/reply/data.dart';
|
||||
import 'package:PiliPlus/pages/common/common_controller.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/reply_new/reply_page.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
@@ -31,7 +30,7 @@ abstract class ReplyController extends CommonController {
|
||||
|
||||
late final savedReplies = {};
|
||||
|
||||
late final bool isLogin = GStorage.userInfo.get('userInfoCache') != null;
|
||||
late final bool isLogin = Accounts.main.isLogin;
|
||||
|
||||
CursorReply? cursor;
|
||||
late Rx<Mode> mode = Mode.MAIN_LIST_HOT.obs;
|
||||
@@ -374,10 +373,10 @@ abstract class ReplyController extends CommonController {
|
||||
// biliSendCommAntifraud
|
||||
if (Platform.isAndroid && _biliSendCommAntifraud) {
|
||||
try {
|
||||
List<Cookie> cookies = await Request.cookieManager.cookieJar
|
||||
.loadForRequest(Uri.parse(HttpString.apiBaseUrl));
|
||||
final String cookieString = cookies
|
||||
.map((Cookie cookie) => '${cookie.name}=${cookie.value}')
|
||||
final String cookieString = Accounts.main.cookieJar
|
||||
.toJson()
|
||||
.entries
|
||||
.map((i) => '${i.key}=${i.value}')
|
||||
.join(';');
|
||||
Utils.channel.invokeMethod(
|
||||
'biliSendCommAntifraud',
|
||||
|
||||
@@ -312,7 +312,7 @@ class AuthorPanel extends StatelessWidget {
|
||||
},
|
||||
minLeadingWidth: 0,
|
||||
),
|
||||
if (GStorage.isLogin)
|
||||
if (Accounts.main.isLogin)
|
||||
ListTile(
|
||||
title: Text(
|
||||
'举报',
|
||||
|
||||
@@ -25,7 +25,7 @@ class LiveController extends CommonController {
|
||||
return super.onRefresh();
|
||||
}
|
||||
|
||||
late RxBool isLogin = GStorage.isLogin.obs;
|
||||
late RxBool isLogin = Accounts.main.isLogin.obs;
|
||||
late Rx<LoadingState> followListState = LoadingState.loading().obs;
|
||||
late int followPage = 1;
|
||||
late bool followEnd = false;
|
||||
|
||||
@@ -3,9 +3,9 @@ import 'dart:io';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/icon_button.dart';
|
||||
import 'package:PiliPlus/common/widgets/radio_widget.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/login.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -84,8 +84,8 @@ class LoginPageController extends GetxController
|
||||
if (value['status']) {
|
||||
t.cancel();
|
||||
statusQRCode.value = '扫码成功';
|
||||
await LoginUtils.onLogin(
|
||||
value['data'], value['data']['cookie_info']);
|
||||
await setAccount(
|
||||
value['data'], value['data']['cookie_info']['cookies']);
|
||||
Get.back();
|
||||
} else if (value['code'] == 86038) {
|
||||
t.cancel();
|
||||
@@ -212,31 +212,27 @@ class LoginPageController extends GetxController
|
||||
}
|
||||
try {
|
||||
dynamic result = await Request().get(
|
||||
"https://api.bilibili.com/x/member/web/account",
|
||||
options: Options(
|
||||
headers: {
|
||||
"Cookie": cookieTextController.text,
|
||||
},
|
||||
),
|
||||
"/x/member/web/account",
|
||||
options: Options(headers: {
|
||||
"cookie": cookieTextController.text,
|
||||
}, extra: {
|
||||
'account': AnonymousAccount()
|
||||
}),
|
||||
);
|
||||
if (result.data['code'] == 0) {
|
||||
try {
|
||||
await LoginUtils.onLogin(
|
||||
{'mid': '${result.data['data']['mid']}'},
|
||||
{
|
||||
'cookies':
|
||||
cookieTextController.text.split(';').toList().map((item) {
|
||||
List list = item.split('=').toList();
|
||||
return {
|
||||
'name': list.firstOrNull,
|
||||
'value': list.getOrNull(1),
|
||||
};
|
||||
}).toList()
|
||||
},
|
||||
);
|
||||
if (GStorage.isLogin) {
|
||||
Get.back();
|
||||
}
|
||||
await LoginAccount(
|
||||
BiliCookieJar.fromJson(Map.fromEntries(
|
||||
cookieTextController.text.split(';').map((item) {
|
||||
final list = item.split('=');
|
||||
return MapEntry(list.first, list.skip(1).join());
|
||||
}))),
|
||||
null,
|
||||
null)
|
||||
.onChange();
|
||||
if (!Accounts.main.isLogin) await switchAccountDialog(Get.context!);
|
||||
SmartDialog.showToast('登录成功');
|
||||
Get.back();
|
||||
} catch (e) {
|
||||
SmartDialog.showToast("登录失败: $e");
|
||||
}
|
||||
@@ -434,8 +430,8 @@ class LoginPageController extends GetxController
|
||||
return;
|
||||
}
|
||||
SmartDialog.showToast('正在保存身份信息');
|
||||
await LoginUtils.onLogin(
|
||||
data['token_info'], data['cookie_info']);
|
||||
await setAccount(
|
||||
data['token_info'], data['cookie_info']['cookies']);
|
||||
Get.back();
|
||||
Get.back();
|
||||
},
|
||||
@@ -453,7 +449,7 @@ class LoginPageController extends GetxController
|
||||
return;
|
||||
}
|
||||
SmartDialog.showToast('正在保存身份信息');
|
||||
await LoginUtils.onLogin(data['token_info'], data['cookie_info']);
|
||||
await setAccount(data['token_info'], data['cookie_info']['cookies']);
|
||||
Get.back();
|
||||
} else {
|
||||
// handle login result
|
||||
@@ -516,7 +512,7 @@ class LoginPageController extends GetxController
|
||||
if (res['status']) {
|
||||
SmartDialog.showToast('登录成功');
|
||||
var data = res['data'];
|
||||
await LoginUtils.onLogin(data['token_info'], data['cookie_info']);
|
||||
await setAccount(data['token_info'], data['cookie_info']['cookies']);
|
||||
Get.back();
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
@@ -644,4 +640,82 @@ class LoginPageController extends GetxController
|
||||
geeChallenge?.isNotEmpty == true &&
|
||||
captchaData.token?.isNotEmpty == true;
|
||||
}
|
||||
|
||||
Future<void> setAccount(Map tokenInfo, List cookieInfo) async {
|
||||
await Future.wait([
|
||||
LoginAccount(BiliCookieJar.fromList(cookieInfo),
|
||||
tokenInfo['access_token'], tokenInfo['refresh_token'])
|
||||
.onChange(),
|
||||
AnonymousAccount().logout().then((i) => Request.buvidActive(i))
|
||||
]);
|
||||
if (Accounts.main.isLogin) {
|
||||
SmartDialog.showToast('登录成功');
|
||||
} else {
|
||||
SmartDialog.showToast('登录成功, 请先设置账号模式');
|
||||
await switchAccountDialog(Get.context!);
|
||||
}
|
||||
}
|
||||
|
||||
static Future switchAccountDialog(BuildContext context) {
|
||||
if (Accounts.account.isEmpty) {
|
||||
return SmartDialog.showToast('请先登录');
|
||||
}
|
||||
final selectAccount = Accounts.accountMode
|
||||
.map((key, value) => MapEntry(key, value.mid.toString()));
|
||||
final options = {'0': '0', for (String i in Accounts.account.keys) i: i};
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (context) => StatefulBuilder(builder: (context, setState) {
|
||||
return AlertDialog(
|
||||
title: const Text('选择账号mid, 为0时使用匿名'),
|
||||
titlePadding: const EdgeInsets.only(left: 22, top: 16, right: 22),
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 5),
|
||||
actionsPadding: const EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 10,
|
||||
),
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: AccountType.values
|
||||
.map(
|
||||
(e) => WrapRadioOptionsGroup<String>(
|
||||
groupTitle: e.title,
|
||||
options: options,
|
||||
selectedValue: selectAccount[e],
|
||||
onChanged: (v) => setState(() => selectAccount[e] = v!),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'取消',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
for (var i in selectAccount.entries) {
|
||||
var account =
|
||||
Accounts.account.get(i.value) ?? AnonymousAccount();
|
||||
if (account != Accounts.get(i.key)) {
|
||||
Accounts.set(i.key, account);
|
||||
}
|
||||
}
|
||||
Get.back();
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class MainController extends GetxController {
|
||||
}
|
||||
hideTabBar =
|
||||
GStorage.setting.get(SettingBoxKey.hideTabBar, defaultValue: true);
|
||||
isLogin.value = GStorage.isLogin;
|
||||
isLogin.value = Accounts.main.isLogin;
|
||||
dynamicBadgeMode = DynamicBadgeMode.values[GStorage.setting.get(
|
||||
SettingBoxKey.dynamicBadgeMode,
|
||||
defaultValue: DynamicBadgeMode.number.index)];
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/index.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
@@ -54,10 +53,6 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
||||
|
||||
_getInfo() async {
|
||||
Map<String, String> data = {
|
||||
'access_key': GStorage.localCache
|
||||
.get(LocalCacheKey.accessKey, defaultValue: {})['value'] ??
|
||||
'',
|
||||
'appkey': Constants.appKey,
|
||||
'build': '1462100',
|
||||
'c_locale': 'zh_CN',
|
||||
'channel': 'yingyongbao',
|
||||
@@ -65,19 +60,10 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
||||
'platform': 'android',
|
||||
's_locale': 'zh_CN',
|
||||
'statistics': Constants.statistics,
|
||||
'ts': (DateTime.now().millisecondsSinceEpoch ~/ 1000).toString(),
|
||||
};
|
||||
String sign = Utils.appSign(
|
||||
data,
|
||||
Constants.appKey,
|
||||
Constants.appSec,
|
||||
);
|
||||
data['sign'] = sign;
|
||||
Request()
|
||||
.get(
|
||||
'${HttpString.appBaseUrl}/x/v2/account/myinfo',
|
||||
queryParameters: data,
|
||||
)
|
||||
.get('${HttpString.appBaseUrl}/x/v2/account/myinfo',
|
||||
queryParameters: data)
|
||||
.then((data) {
|
||||
setState(() {
|
||||
if (data.data['code'] == 0) {
|
||||
@@ -329,10 +315,6 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
||||
dynamic datum,
|
||||
}) async {
|
||||
Map<String, String> data = {
|
||||
'access_key': GStorage.localCache
|
||||
.get(LocalCacheKey.accessKey, defaultValue: {})['value'] ??
|
||||
'',
|
||||
'appkey': Constants.appKey,
|
||||
'build': '1462100',
|
||||
'c_locale': 'zh_CN',
|
||||
'channel': 'yingyongbao',
|
||||
@@ -350,12 +332,6 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
||||
else if (type == ProfileType.sex)
|
||||
'sex': datum.toString(),
|
||||
};
|
||||
String sign = Utils.appSign(
|
||||
data,
|
||||
Constants.appKey,
|
||||
Constants.appSec,
|
||||
);
|
||||
data['sign'] = sign;
|
||||
Request()
|
||||
.post(
|
||||
'/x/member/app/${type.name}/update',
|
||||
|
||||
@@ -24,7 +24,7 @@ class MemberCoinPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MemberCoinPageState extends State<MemberCoinPage> {
|
||||
late final _ownerMid = GStorage.ownerMid;
|
||||
late final _ownerMid = Accounts.main.mid;
|
||||
|
||||
late final _ctr = Get.put(
|
||||
MemberCoinController(mid: widget.mid),
|
||||
|
||||
@@ -24,7 +24,7 @@ class MemberLikePage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MemberLikePageState extends State<MemberLikePage> {
|
||||
late final _ownerMid = GStorage.ownerMid;
|
||||
late final _ownerMid = Accounts.main.mid;
|
||||
|
||||
late final _ctr = Get.put(
|
||||
MemberLikeController(mid: widget.mid),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/login.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -20,8 +21,9 @@ class MineController extends GetxController {
|
||||
|
||||
Rx<ThemeType> themeType = ThemeType.system.obs;
|
||||
static Box get setting => GStorage.setting;
|
||||
static RxBool anonymity =
|
||||
(setting.get(SettingBoxKey.anonymity, defaultValue: false) as bool).obs;
|
||||
static RxBool anonymity = (Accounts.account.isNotEmpty &&
|
||||
!Accounts.get(AccountType.heartbeat).isLogin)
|
||||
.obs;
|
||||
ThemeType get nextThemeType =>
|
||||
ThemeType.values[(themeType.value.index + 1) % ThemeType.values.length];
|
||||
|
||||
@@ -36,8 +38,8 @@ class MineController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
onLogin() async {
|
||||
if (!isLogin.value) {
|
||||
onLogin([bool longPress = false]) async {
|
||||
if (!isLogin.value || longPress) {
|
||||
Get.toNamed('/loginPage', preventDuplicates: false);
|
||||
} else {
|
||||
int mid = userInfo.value.mid!;
|
||||
@@ -58,13 +60,13 @@ class MineController extends GetxController {
|
||||
GStorage.userInfo.put('userInfoCache', res['data']);
|
||||
isLogin.value = true;
|
||||
} else {
|
||||
LoginUtils.onLogout();
|
||||
LoginUtils.onLogoutMain();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
SmartDialog.showToast(res['msg']);
|
||||
if (res['msg'] == '账号未登录') {
|
||||
LoginUtils.onLogout();
|
||||
LoginUtils.onLogoutMain();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -79,8 +81,13 @@ class MineController extends GetxController {
|
||||
}
|
||||
|
||||
static onChangeAnonymity(BuildContext context) {
|
||||
if (Accounts.account.isEmpty) {
|
||||
SmartDialog.showToast('请先登录');
|
||||
return;
|
||||
}
|
||||
anonymity.value = !anonymity.value;
|
||||
if (anonymity.value) {
|
||||
Accounts.accountMode[AccountType.heartbeat] = AnonymousAccount();
|
||||
SmartDialog.show(
|
||||
clickMaskDismiss: false,
|
||||
usePenetrate: true,
|
||||
@@ -122,8 +129,8 @@ class MineController extends GetxController {
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
SmartDialog.dismiss();
|
||||
setting.put(SettingBoxKey.anonymity, true);
|
||||
anonymity.value = true;
|
||||
Accounts.set(
|
||||
AccountType.heartbeat, AnonymousAccount());
|
||||
SmartDialog.showToast('已设为永久无痕模式');
|
||||
},
|
||||
child: Text(
|
||||
@@ -136,8 +143,6 @@ class MineController extends GetxController {
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
SmartDialog.dismiss();
|
||||
setting.put(SettingBoxKey.anonymity, false);
|
||||
anonymity.value = true;
|
||||
SmartDialog.showToast('已设为临时无痕模式');
|
||||
},
|
||||
child: Text(
|
||||
@@ -158,7 +163,7 @@ class MineController extends GetxController {
|
||||
},
|
||||
);
|
||||
} else {
|
||||
setting.put(SettingBoxKey.anonymity, false);
|
||||
Accounts.set(AccountType.heartbeat, Accounts.main);
|
||||
SmartDialog.show(
|
||||
clickMaskDismiss: false,
|
||||
usePenetrate: true,
|
||||
|
||||
@@ -129,6 +129,7 @@ class _MinePageState extends State<MinePage> {
|
||||
GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: _mineController.onLogin,
|
||||
onLongPress: () => _mineController.onLogin(true),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:PiliPlus/utils/storage.dart';
|
||||
class RcmdController extends CommonController {
|
||||
late bool enableSaveLastData = GStorage.setting
|
||||
.get(SettingBoxKey.enableSaveLastData, defaultValue: false);
|
||||
late String defaultRcmdType = 'app';
|
||||
late bool appRcmd = true;
|
||||
|
||||
int? lastRefreshAt;
|
||||
late bool savedRcmdTip = GStorage.savedRcmdTip;
|
||||
@@ -14,8 +14,7 @@ class RcmdController extends CommonController {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
defaultRcmdType = GStorage.setting
|
||||
.get(SettingBoxKey.defaultRcmdType, defaultValue: 'app');
|
||||
appRcmd = GStorage.appRcmd;
|
||||
|
||||
currentPage = 0;
|
||||
queryData();
|
||||
@@ -23,15 +22,9 @@ class RcmdController extends CommonController {
|
||||
|
||||
@override
|
||||
Future<LoadingState> customGetData() {
|
||||
return defaultRcmdType == 'app' || defaultRcmdType == 'notLogin'
|
||||
? VideoHttp.rcmdVideoListApp(
|
||||
loginStatus: defaultRcmdType != 'notLogin',
|
||||
freshIdx: currentPage,
|
||||
)
|
||||
: VideoHttp.rcmdVideoList(
|
||||
freshIdx: currentPage,
|
||||
ps: 20,
|
||||
);
|
||||
return appRcmd
|
||||
? VideoHttp.rcmdVideoListApp(freshIdx: currentPage)
|
||||
: VideoHttp.rcmdVideoList(freshIdx: currentPage, ps: 20);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -16,9 +16,7 @@ class RecommendSetting extends StatelessWidget {
|
||||
ListTile(
|
||||
dense: true,
|
||||
subtitle: Text(
|
||||
'¹ 若默认web端推荐不太符合预期,可尝试切换至app端。\n'
|
||||
'¹ 选择“游客模式(notLogin)”,将以空的key请求app推荐接口,但播放页仍会携带用户信息,保证账号能正常记录进度、点赞投币等。\n\n'
|
||||
'² 由于接口未提供关注信息,无法豁免相关视频中的已关注Up。\n\n'
|
||||
'¹ 由于接口未提供关注信息,无法豁免相关视频中的已关注Up。\n\n'
|
||||
'* 其它(如热门视频、手动搜索、链接跳转等)均不受过滤器影响。\n'
|
||||
'* 设定较严苛的条件可导致推荐项数锐减或多次请求,请酌情选择。\n'
|
||||
'* 后续可能会增加更多过滤条件,敬请期待。',
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:PiliPlus/models/common/sponsor_block/skip_type.dart';
|
||||
import 'package:PiliPlus/pages/setting/slide_color_picker.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -66,7 +65,6 @@ class _SponsorBlockPageState extends State<SponsorBlockPage> {
|
||||
Request()
|
||||
.get(
|
||||
'$_blockServer/api/status/uptime',
|
||||
options: Options(extra: {'clearCookie': true}),
|
||||
)
|
||||
.then((res) {
|
||||
setState(() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:PiliPlus/build_config.dart';
|
||||
import 'package:PiliPlus/http/login.dart';
|
||||
import 'package:PiliPlus/pages/about/index.dart';
|
||||
import 'package:PiliPlus/pages/login/controller.dart';
|
||||
import 'package:PiliPlus/pages/setting/extra_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/play_setting.dart';
|
||||
import 'package:PiliPlus/pages/setting/privacy_setting.dart';
|
||||
@@ -9,13 +10,10 @@ import 'package:PiliPlus/pages/setting/video_setting.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/login.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../http/init.dart';
|
||||
|
||||
class _SettingsModel {
|
||||
final String name;
|
||||
final String title;
|
||||
@@ -39,7 +37,7 @@ class SettingPage extends StatefulWidget {
|
||||
|
||||
class _SettingPageState extends State<SettingPage> {
|
||||
late String _type = 'privacySetting';
|
||||
final RxBool _isLogin = GStorage.isLogin.obs;
|
||||
final RxBool _isLogin = Accounts.main.isLogin.obs;
|
||||
TextStyle get _titleStyle => Theme.of(context).textTheme.titleMedium!;
|
||||
TextStyle get _subTitleStyle => Theme.of(context)
|
||||
.textTheme
|
||||
@@ -170,6 +168,12 @@ class _SettingPageState extends State<SettingPage> {
|
||||
: Text(item.subtitle!, style: _subTitleStyle),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () => LoginPageController.switchAccountDialog(context),
|
||||
leading: const Icon(Icons.switch_account_outlined),
|
||||
title: const Text('设置账号模式'),
|
||||
),
|
||||
// TODO: 多账号登出
|
||||
_buildLoginItem,
|
||||
ListTile(
|
||||
tileColor: _getTileColor(_items.last.name),
|
||||
@@ -204,41 +208,36 @@ class _SettingPageState extends State<SettingPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (BuildConfig.isDebug)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
_isLogin.value = false;
|
||||
LoginUtils.onLogout();
|
||||
},
|
||||
child: Text(
|
||||
'仅登出',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
_isLogin.value = false;
|
||||
LoginUtils.onLogoutMain();
|
||||
final account = Accounts.main;
|
||||
Accounts.accountMode
|
||||
.removeWhere((_, a) => a == account);
|
||||
account.logout().then((_) => Accounts.refresh());
|
||||
},
|
||||
child: Text(
|
||||
'仅登出',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
SmartDialog.showLoading();
|
||||
dynamic res = await Request().post(
|
||||
'https://passport.bilibili.com/login/exit/v2',
|
||||
data: {
|
||||
'biliCSRF': await Request.getCsrf(),
|
||||
},
|
||||
options: Options(
|
||||
contentType:
|
||||
Headers.formUrlEncodedContentType,
|
||||
),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
await LoginUtils.onLogout();
|
||||
final res = await LoginHttp.logout(Accounts.main);
|
||||
if (res['status']) {
|
||||
await Accounts.main.logout();
|
||||
await LoginUtils.onLogoutMain();
|
||||
_isLogin.value = false;
|
||||
SmartDialog.dismiss();
|
||||
Get.back();
|
||||
} else {
|
||||
SmartDialog.dismiss();
|
||||
SmartDialog.showToast('${res.data['message']}');
|
||||
SmartDialog.showToast(res['msg'].toString());
|
||||
}
|
||||
},
|
||||
child: const Text('确认'),
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart'
|
||||
show kDragContainerExtentPercentage, displacement;
|
||||
import 'package:PiliPlus/http/interceptor.dart';
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/main.dart';
|
||||
@@ -11,7 +10,6 @@ import 'package:PiliPlus/models/common/audio_normalization.dart';
|
||||
import 'package:PiliPlus/models/common/dynamic_badge_mode.dart';
|
||||
import 'package:PiliPlus/models/common/dynamics_type.dart';
|
||||
import 'package:PiliPlus/models/common/nav_bar_config.dart';
|
||||
import 'package:PiliPlus/models/common/rcmd_type.dart';
|
||||
import 'package:PiliPlus/models/common/reply_sort_type.dart';
|
||||
import 'package:PiliPlus/models/common/super_resolution_type.dart';
|
||||
import 'package:PiliPlus/models/common/theme_type.dart';
|
||||
@@ -35,6 +33,7 @@ import 'package:PiliPlus/pages/setting/widgets/switch_item.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/bottom_progress_behavior.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/fullscreen_mode.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account_manager/account_mgr.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
@@ -1229,35 +1228,19 @@ List<SettingsModel> get videoSettings => [
|
||||
|
||||
List<SettingsModel> get recommendSettings => [
|
||||
SettingsModel(
|
||||
settingsType: SettingsType.normal,
|
||||
title: '首页推荐类型',
|
||||
leading: const Icon(Icons.model_training_outlined),
|
||||
getSubtitle: () => '当前使用「${GStorage.defaultRcmdType}端」推荐¹',
|
||||
onTap: (setState) async {
|
||||
String? result = await showDialog(
|
||||
context: Get.context!,
|
||||
builder: (context) {
|
||||
return SelectDialog<String>(
|
||||
title: '推荐类型',
|
||||
value: GStorage.defaultRcmdType,
|
||||
values: RcmdType.values.map((e) {
|
||||
return {'title': e.labels, 'value': e.values};
|
||||
}).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
if (result != null) {
|
||||
if (result == 'app') {
|
||||
if (GStorage.isLogin.not) {
|
||||
SmartDialog.showToast('尚未登录,无法收到个性化推荐');
|
||||
}
|
||||
settingsType: SettingsType.sw1tch,
|
||||
title: '首页使用app端推荐',
|
||||
subtitle: '若web端推荐不太符合预期,可尝试切换至app端推荐',
|
||||
leading: const Icon(Icons.model_training_outlined),
|
||||
setKey: SettingBoxKey.appRcmd,
|
||||
defaultVal: true,
|
||||
onChanged: (value) {
|
||||
try {
|
||||
Get.find<RcmdController>().appRcmd = value;
|
||||
} catch (e) {
|
||||
debugPrint('$e');
|
||||
}
|
||||
await GStorage.setting.put(SettingBoxKey.defaultRcmdType, result);
|
||||
SmartDialog.showToast('下次启动时生效');
|
||||
setState();
|
||||
}
|
||||
},
|
||||
),
|
||||
}),
|
||||
SettingsModel(
|
||||
settingsType: SettingsType.sw1tch,
|
||||
title: '推荐动态',
|
||||
@@ -1430,7 +1413,7 @@ List<SettingsModel> get recommendSettings => [
|
||||
SettingsModel(
|
||||
settingsType: SettingsType.sw1tch,
|
||||
title: '过滤器也应用于相关视频',
|
||||
subtitle: '视频详情页的相关视频也进行过滤²',
|
||||
subtitle: '视频详情页的相关视频也进行过滤¹',
|
||||
leading: const Icon(Icons.explore_outlined),
|
||||
setKey: SettingBoxKey.applyFilterToRelatedVideos,
|
||||
defaultVal: true,
|
||||
@@ -1442,7 +1425,7 @@ List<SettingsModel> get privacySettings => [
|
||||
SettingsModel(
|
||||
settingsType: SettingsType.normal,
|
||||
onTap: (setState) {
|
||||
if (GStorage.isLogin.not) {
|
||||
if (Accounts.main.isLogin.not) {
|
||||
SmartDialog.showToast('登录后查看');
|
||||
return;
|
||||
}
|
||||
@@ -1472,7 +1455,8 @@ List<SettingsModel> get privacySettings => [
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('查看详情'),
|
||||
content: Text(ApiInterceptor.anonymityList.join('\n')),
|
||||
content: Text(AccountManager.apiTypeSet[AccountType.heartbeat]!
|
||||
.join('\n')),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
@@ -1501,12 +1485,9 @@ List<SettingsModel> get extraSettings => [
|
||||
onTap: () => Get.toNamed('/sponsorBlock'),
|
||||
leading: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
const Icon(Icons.shield_outlined),
|
||||
Icon(
|
||||
Icons.play_arrow_rounded,
|
||||
size: 15,
|
||||
),
|
||||
children: const [
|
||||
Icon(Icons.shield_outlined),
|
||||
Icon(Icons.play_arrow_rounded, size: 15),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -2056,9 +2037,9 @@ List<SettingsModel> get extraSettings => [
|
||||
subtitle: '发送评论后检查评论是否可见',
|
||||
leading: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
const Icon(Icons.shield_outlined),
|
||||
const Icon(Icons.reply, size: 14),
|
||||
children: const [
|
||||
Icon(Icons.shield_outlined),
|
||||
Icon(Icons.reply, size: 14),
|
||||
],
|
||||
),
|
||||
setKey: SettingBoxKey.enableCommAntifraud,
|
||||
@@ -2081,12 +2062,9 @@ List<SettingsModel> get extraSettings => [
|
||||
subtitle: '发布/转发动态后检查动态是否可见',
|
||||
leading: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
const Icon(Icons.shield_outlined),
|
||||
Icon(
|
||||
Icons.motion_photos_on,
|
||||
size: 12,
|
||||
),
|
||||
children: const [
|
||||
Icon(Icons.shield_outlined),
|
||||
Icon(Icons.motion_photos_on, size: 12),
|
||||
],
|
||||
),
|
||||
setKey: SettingBoxKey.enableCreateDynAntifraud,
|
||||
@@ -2097,7 +2075,7 @@ List<SettingsModel> get extraSettings => [
|
||||
title: '屏蔽带货动态',
|
||||
leading: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
children: const [
|
||||
Icon(Icons.shopping_bag_outlined, size: 14),
|
||||
Icon(Icons.not_interested),
|
||||
],
|
||||
@@ -2113,7 +2091,7 @@ List<SettingsModel> get extraSettings => [
|
||||
title: '屏蔽带货评论',
|
||||
leading: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
children: const [
|
||||
Icon(Icons.shopping_bag_outlined, size: 14),
|
||||
Icon(Icons.not_interested),
|
||||
],
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/video/play/CDN.dart';
|
||||
import 'package:PiliPlus/models/video/play/url.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/video_utils.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
@@ -46,23 +45,12 @@ class _SelectDialogState<T> extends State<SelectDialog<T>> {
|
||||
if (result['status']) {
|
||||
VideoItem videoItem = result['data'].dash.video.first;
|
||||
|
||||
late final isLogin = GStorage.isLogin;
|
||||
late final dynamic mid =
|
||||
GStorage.userInfo.get('userInfoCache')?.mid;
|
||||
|
||||
for (CDNService item in CDNService.values) {
|
||||
if (mounted.not) {
|
||||
break;
|
||||
}
|
||||
String videoUrl = VideoUtils.getCdnUrl(videoItem, item.code);
|
||||
Dio dio = Dio()
|
||||
..options.headers['referer'] = 'https://www.bilibili.com/';
|
||||
if (isLogin) {
|
||||
dio.interceptors.add(Request.cookieManager);
|
||||
dio.options.headers['x-bili-mid'] = mid;
|
||||
dio.options.headers['x-bili-aurora-eid'] =
|
||||
IdUtils.genAuroraEid(mid);
|
||||
}
|
||||
Dio dio = Dio()..options.headers['referer'] = HttpString.baseUrl;
|
||||
int maxSize = 8 * 1024 * 1024;
|
||||
int downloaded = 0;
|
||||
int start = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
@@ -26,7 +26,6 @@ import 'package:PiliPlus/pages/video/detail/widgets/send_danmaku_panel.dart';
|
||||
import 'package:PiliPlus/pages/video/detail/widgets/media_list_panel.dart';
|
||||
import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
|
||||
import 'package:floating/floating.dart';
|
||||
@@ -493,17 +492,14 @@ class VideoDetailController extends GetxController
|
||||
late final List listData = [];
|
||||
|
||||
Future _vote(String uuid, int type) async {
|
||||
Request()
|
||||
.post(
|
||||
Request().post(
|
||||
'${GStorage.blockServer}/api/voteOnSponsorTime',
|
||||
queryParameters: {
|
||||
'UUID': uuid,
|
||||
'userID': GStorage.blockUserID,
|
||||
'type': type,
|
||||
},
|
||||
options: options,
|
||||
)
|
||||
.then((res) {
|
||||
).then((res) {
|
||||
SmartDialog.showToast(res.statusCode == 200 ? '投票成功' : '投票失败');
|
||||
});
|
||||
}
|
||||
@@ -522,17 +518,14 @@ class VideoDetailController extends GetxController
|
||||
dense: true,
|
||||
onTap: () {
|
||||
Get.back();
|
||||
Request()
|
||||
.post(
|
||||
Request().post(
|
||||
'${GStorage.blockServer}/api/voteOnSponsorTime',
|
||||
queryParameters: {
|
||||
'UUID': segment.UUID,
|
||||
'userID': GStorage.blockUserID,
|
||||
'category': item.name,
|
||||
},
|
||||
options: options,
|
||||
)
|
||||
.then((res) {
|
||||
).then((res) {
|
||||
SmartDialog.showToast(
|
||||
'类别更改${res.statusCode == 200 ? '成功' : '失败'}');
|
||||
});
|
||||
@@ -725,8 +718,6 @@ class VideoDetailController extends GetxController
|
||||
);
|
||||
}
|
||||
|
||||
Options get options => Options(extra: {'clearCookie': true});
|
||||
|
||||
Future _querySponsorBlock() async {
|
||||
positionSubscription?.cancel();
|
||||
videoLabel.value = '';
|
||||
@@ -738,7 +729,6 @@ class VideoDetailController extends GetxController
|
||||
'videoID': bvid,
|
||||
'cid': cid.value,
|
||||
},
|
||||
options: options,
|
||||
);
|
||||
handleSBData(result);
|
||||
}
|
||||
@@ -940,7 +930,6 @@ class VideoDetailController extends GetxController
|
||||
Request().post(
|
||||
'${GStorage.blockServer}/api/viewedVideoSponsorTime',
|
||||
queryParameters: {'UUID': item.UUID},
|
||||
options: options,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -330,8 +330,7 @@ class _PostPanelState extends CommonCollapseSlidePageState<PostPanel> {
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Request()
|
||||
.post(
|
||||
Request().post(
|
||||
'${GStorage.blockServer}/api/skipSegments',
|
||||
queryParameters: {
|
||||
'videoID': videoDetailController.bvid,
|
||||
@@ -355,9 +354,7 @@ class _PostPanelState extends CommonCollapseSlidePageState<PostPanel> {
|
||||
)
|
||||
.toList(),
|
||||
},
|
||||
options: videoDetailController.options,
|
||||
)
|
||||
.then(
|
||||
).then(
|
||||
(res) {
|
||||
if (res.statusCode == 200) {
|
||||
Get.back();
|
||||
|
||||
@@ -1048,7 +1048,7 @@ class ReplyItem extends StatelessWidget {
|
||||
'/x/v2/reply/report',
|
||||
data: {
|
||||
'add_blacklist': banUid,
|
||||
'csrf': await Request.getCsrf(),
|
||||
'csrf': Accounts.main.csrf,
|
||||
'gaia_source': 'main_h5',
|
||||
'oid': item.oid,
|
||||
'platform': 'android',
|
||||
@@ -1135,7 +1135,7 @@ class ReplyItem extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
dynamic ownerMid = GStorage.ownerMid;
|
||||
int ownerMid = Accounts.main.mid;
|
||||
Color errorColor = Theme.of(context).colorScheme.error;
|
||||
|
||||
return Padding(
|
||||
@@ -1168,7 +1168,7 @@ class ReplyItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (ownerMid != null) ...[
|
||||
if (ownerMid != 0) ...[
|
||||
ListTile(
|
||||
onTap: () => menuActionHandler('delete'),
|
||||
minLeadingWidth: 0,
|
||||
|
||||
@@ -1177,7 +1177,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
dynamic ownerMid = GStorage.ownerMid;
|
||||
int ownerMid = Accounts.main.mid;
|
||||
Color errorColor = Theme.of(context).colorScheme.error;
|
||||
|
||||
return Padding(
|
||||
@@ -1210,7 +1210,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (ownerMid != null) ...[
|
||||
if (ownerMid != 0) ...[
|
||||
ListTile(
|
||||
onTap: () => menuActionHandler('delete'),
|
||||
minLeadingWidth: 0,
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/cache_manage.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:cookie_jar/cookie_jar.dart' as cookie_jar;
|
||||
|
||||
enum _WebviewMenuItem {
|
||||
refresh,
|
||||
@@ -127,10 +127,8 @@ class _WebviewPageNewState extends State<WebviewPageNew> {
|
||||
}
|
||||
break;
|
||||
case _WebviewMenuItem.resetCookie:
|
||||
final List<cookie_jar.Cookie> cookies = await Request
|
||||
.cookieManager.cookieJar
|
||||
.loadForRequest(Uri.parse(HttpString.baseUrl));
|
||||
for (cookie_jar.Cookie item in cookies) {
|
||||
final cookies = Accounts.main.cookieJar.toList();
|
||||
for (var item in cookies) {
|
||||
await CookieManager().setCookie(
|
||||
url: WebUri(item.domain ?? ''),
|
||||
name: item.name,
|
||||
|
||||
Reference in New Issue
Block a user