mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -10,6 +10,7 @@ import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account_manager/account_mgr.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/login_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:archive/archive.dart';
|
||||
@@ -18,7 +19,6 @@ import 'package:dio/dio.dart';
|
||||
import 'package:dio/io.dart';
|
||||
import 'package:dio_http2_adapter/dio_http2_adapter.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart' as web;
|
||||
|
||||
class Request {
|
||||
static const _gzipDecoder = GZipDecoder();
|
||||
@@ -30,25 +30,11 @@ class Request {
|
||||
factory Request() => _instance;
|
||||
|
||||
/// 设置cookie
|
||||
static Future<void> setCookie() async {
|
||||
static void setCookie() {
|
||||
accountManager = AccountManager();
|
||||
dio.interceptors.add(accountManager);
|
||||
Accounts.refresh();
|
||||
final List<Cookie> cookies = Accounts.main.cookieJar.toList();
|
||||
final webManager = web.CookieManager();
|
||||
await 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,
|
||||
),
|
||||
),
|
||||
);
|
||||
LoginUtils.setWebCookie();
|
||||
|
||||
if (Accounts.main.isLogin) {
|
||||
final coin = Pref.userInfoCache?.money;
|
||||
|
||||
@@ -99,6 +99,8 @@ class SearchHttp {
|
||||
case SearchType.article:
|
||||
data = SearchArticleData.fromJson(res.data['data']);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Success(data);
|
||||
} catch (err) {
|
||||
|
||||
@@ -67,7 +67,7 @@ void main() async {
|
||||
HttpOverrides.global = _CustomHttpOverrides();
|
||||
await setupServiceLocator();
|
||||
Request();
|
||||
await Request.setCookie();
|
||||
Request.setCookie();
|
||||
|
||||
SmartDialog.config.toast = SmartConfigToast(
|
||||
displayType: SmartToastType.onlyRefresh,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
enum SearchType {
|
||||
// all,
|
||||
// all('综合'),
|
||||
// 视频:video
|
||||
video('视频', hasHeader: true),
|
||||
// 番剧:media_bangumi,
|
||||
|
||||
@@ -98,11 +98,11 @@ class DynamicItemModel {
|
||||
}
|
||||
idStr = json['item']?['id_str'];
|
||||
// type = json['type']; // int
|
||||
modules = json['item']?['modules'] == null
|
||||
? ItemModulesModel()
|
||||
: ItemModulesModel.fromOpusJson(
|
||||
(json['item']['modules'] as List).cast(),
|
||||
);
|
||||
if (json['item']?['modules'] case List list) {
|
||||
modules = ItemModulesModel.fromOpusJson(list.cast());
|
||||
} else {
|
||||
modules = ItemModulesModel();
|
||||
}
|
||||
|
||||
if (json['fallback'] != null) {
|
||||
fallback = Fallback.fromJson(json['fallback']);
|
||||
@@ -196,7 +196,7 @@ class ItemModulesModel {
|
||||
: ModuleBlocked.fromJson(i['module_blocked']);
|
||||
break;
|
||||
case 'MODULE_TYPE_EXTEND':
|
||||
moduleExtend = (i['module_extend']['items'] as List?)
|
||||
moduleExtend = (i['module_extend']?['items'] as List?)
|
||||
?.map((i) => ModuleTag.fromJson(i))
|
||||
.toList();
|
||||
break;
|
||||
@@ -1286,9 +1286,7 @@ class RichTextNodeItem {
|
||||
text = json['text'];
|
||||
type = json['type'];
|
||||
rid = json['rid'];
|
||||
pics = json['pics'] == null
|
||||
? null
|
||||
: (json['pics'] as List?)
|
||||
pics = (json['pics'] as List?)
|
||||
?.map((e) => OpusPicModel.fromJson(e))
|
||||
.toList();
|
||||
jumpUrl = json['jump_url'];
|
||||
|
||||
@@ -22,36 +22,24 @@ class SearchAllData extends SearchNumData {
|
||||
|
||||
SearchAllData.fromJson(Map<String, dynamic> json) {
|
||||
numResults = (json['numResults'] as num?)?.toInt();
|
||||
if ((json['result'] as List?)?.isNotEmpty == true) {
|
||||
if (json['result'] case List result) {
|
||||
final isRefresh = json['page'] == 1;
|
||||
list = [];
|
||||
for (final item in json['result']) {
|
||||
if ((item['data'] as List?)?.isNotEmpty == true) {
|
||||
for (final item in result) {
|
||||
if (item['data'] case List data) {
|
||||
switch (item['result_type']) {
|
||||
case 'media_bangumi' || 'media_bangumi':
|
||||
if (isRefresh) {
|
||||
list!.add(
|
||||
(item['data'] as List)
|
||||
.map((e) => SearchPgcItemModel.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
list!.addAll(data.map((e) => SearchPgcItemModel.fromJson(e)));
|
||||
}
|
||||
break;
|
||||
case 'bili_user':
|
||||
if (isRefresh) {
|
||||
list!.addAll(
|
||||
(item['data'] as List)
|
||||
.map((e) => SearchUserItemModel.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
list!.addAll(data.map((e) => SearchUserItemModel.fromJson(e)));
|
||||
}
|
||||
break;
|
||||
case 'video':
|
||||
list!.addAll(
|
||||
(item['data'] as List)
|
||||
.map((e) => SearchVideoItemModel.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
list!.addAll(data.map((e) => SearchVideoItemModel.fromJson(e)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ class DanmakuBlockDataModel {
|
||||
rule = <SimpleRule>[];
|
||||
rule1 = <SimpleRule>[];
|
||||
rule2 = <SimpleRule>[];
|
||||
if ((json['rule'] as List?)?.isNotEmpty == true) {
|
||||
for (var e in json['rule']) {
|
||||
if (json['rule'] case List list) {
|
||||
for (var e in list) {
|
||||
SimpleRule item = SimpleRule.fromJson(e);
|
||||
switch (item.type) {
|
||||
case 0:
|
||||
|
||||
@@ -234,7 +234,7 @@ abstract class CommonPublishPageState<T extends CommonPublishPage>
|
||||
'img_size': data.imgSize,
|
||||
'img_src': data.imageUrl,
|
||||
};
|
||||
}).toList(),
|
||||
}),
|
||||
eagerError: true,
|
||||
);
|
||||
SmartDialog.dismiss();
|
||||
|
||||
@@ -202,11 +202,10 @@ class LiveRoomController extends GetxController {
|
||||
if (messages.isEmpty) {
|
||||
LiveHttp.liveRoomDanmaPrefetch(roomId: roomId).then((v) {
|
||||
if (v['status']) {
|
||||
if ((v['data'] as List?)?.isNotEmpty == true) {
|
||||
if (v['data'] case List list) {
|
||||
try {
|
||||
messages.addAll(
|
||||
(v['data'] as List)
|
||||
.map(
|
||||
list.map(
|
||||
(obj) => {
|
||||
'name': obj['user']['base']['name'],
|
||||
'uid': obj['user']['uid'],
|
||||
@@ -216,8 +215,7 @@ class LiveRoomController extends GetxController {
|
||||
? obj['emoticon']
|
||||
: null,
|
||||
},
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => scrollToBottom(),
|
||||
|
||||
@@ -77,7 +77,7 @@ class MemberFavoriteCtr
|
||||
firstEnd.value = res.data['data']['has_more'] == false;
|
||||
if (res.data['data'] != null) {
|
||||
List<SpaceFavItemModel> list =
|
||||
(res.data['data']['list'] as List<dynamic>?)
|
||||
(res.data['data']?['list'] as List<dynamic>?)
|
||||
?.map((item) => SpaceFavItemModel.fromJson(item))
|
||||
.toList() ??
|
||||
<SpaceFavItemModel>[];
|
||||
@@ -107,7 +107,7 @@ class MemberFavoriteCtr
|
||||
secondEnd.value = res.data['data']['has_more'] == false;
|
||||
if (res.data['data'] != null) {
|
||||
List<SpaceFavItemModel> list =
|
||||
(res.data['data']['list'] as List<dynamic>?)
|
||||
(res.data['data']?['list'] as List<dynamic>?)
|
||||
?.map((item) => SpaceFavItemModel.fromJson(item))
|
||||
.toList() ??
|
||||
<SpaceFavItemModel>[];
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:PiliPlus/common/widgets/loading_widget/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_fav/data.dart';
|
||||
import 'package:PiliPlus/models_new/space/space_fav/list.dart';
|
||||
import 'package:PiliPlus/pages/member_favorite/controller.dart';
|
||||
import 'package:PiliPlus/pages/member_favorite/widget/item.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
@@ -123,7 +122,7 @@ class _MemberFavoriteState extends State<MemberFavorite>
|
||||
),
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
children: [
|
||||
...(data.mediaListResponse?.list as List<SpaceFavItemModel>).map(
|
||||
...?data.mediaListResponse?.list?.map(
|
||||
(item) => SizedBox(
|
||||
height: 98,
|
||||
child: MemberFavItem(
|
||||
|
||||
@@ -53,9 +53,7 @@ class _SearchAllPanelState
|
||||
(item) => switch (item) {
|
||||
SearchVideoItemModel() => SizedBox(
|
||||
height: 120,
|
||||
child: VideoCardH(
|
||||
videoItem: item,
|
||||
),
|
||||
child: VideoCardH(videoItem: item),
|
||||
),
|
||||
List<SearchPgcItemModel>() =>
|
||||
item.length == 1
|
||||
|
||||
@@ -535,9 +535,9 @@ List<SettingsModel> get extraSettings => [
|
||||
return SelectDialog<SuperResolutionType>(
|
||||
title: '超分辨率',
|
||||
value: SuperResolutionType.values[Pref.superResolutionType],
|
||||
values: SuperResolutionType.values.map((e) {
|
||||
return (e, e.title);
|
||||
}).toList(),
|
||||
values: SuperResolutionType.values
|
||||
.map((e) => (e, e.title))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -935,9 +935,9 @@ List<SettingsModel> get extraSettings => [
|
||||
return SelectDialog<int>(
|
||||
title: '评论展示',
|
||||
value: Pref.replySortType,
|
||||
values: ReplySortType.values.map((e) {
|
||||
return (e.index, e.title);
|
||||
}).toList(),
|
||||
values: ReplySortType.values
|
||||
.map((e) => (e.index, e.title))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -961,9 +961,10 @@ List<SettingsModel> get extraSettings => [
|
||||
return SelectDialog<int>(
|
||||
title: '动态展示',
|
||||
value: Pref.defaultDynamicType,
|
||||
values: DynamicsTabType.values.sublist(0, 4).map((e) {
|
||||
return (e.index, e.label);
|
||||
}).toList(),
|
||||
values: DynamicsTabType.values
|
||||
.sublist(0, 4)
|
||||
.map((e) => (e.index, e.label))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -986,9 +987,7 @@ List<SettingsModel> get extraSettings => [
|
||||
return SelectDialog<MemberTabType>(
|
||||
title: '用户页默认展示TAB',
|
||||
value: Pref.memberTab,
|
||||
values: MemberTabType.values.map((e) {
|
||||
return (e, e.title);
|
||||
}).toList(),
|
||||
values: MemberTabType.values.map((e) => (e, e.title)).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -223,9 +223,9 @@ List<SettingsModel> get playSettings => [
|
||||
return SelectDialog<int>(
|
||||
title: '默认全屏方向',
|
||||
value: Pref.fullScreenMode,
|
||||
values: FullScreenMode.values.map((e) {
|
||||
return (e.index, e.desc);
|
||||
}).toList(),
|
||||
values: FullScreenMode.values
|
||||
.map((e) => (e.index, e.desc))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -248,9 +248,9 @@ List<SettingsModel> get playSettings => [
|
||||
return SelectDialog<int>(
|
||||
title: '底部进度条展示',
|
||||
value: Pref.btmProgressBehavior,
|
||||
values: BtmProgressBehavior.values.map((e) {
|
||||
return (e.index, e.desc);
|
||||
}).toList(),
|
||||
values: BtmProgressBehavior.values
|
||||
.map((e) => (e.index, e.desc))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -104,9 +104,7 @@ List<SettingsModel> get styleSettings => [
|
||||
return SelectDialog<Transition>(
|
||||
title: '页面过渡动画',
|
||||
value: CustomGetPage.pageTransition,
|
||||
values: Transition.values.map((e) {
|
||||
return (e, e.name);
|
||||
}).toList(),
|
||||
values: Transition.values.map((e) => (e, e.name)).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -203,9 +201,7 @@ List<SettingsModel> get styleSettings => [
|
||||
return SelectDialog<UpPanelPosition>(
|
||||
title: '动态页UP主显示位置',
|
||||
value: Pref.upPanelPosition,
|
||||
values: UpPanelPosition.values.map((e) {
|
||||
return (e, e.label);
|
||||
}).toList(),
|
||||
values: UpPanelPosition.values.map((e) => (e, e.label)).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -239,9 +235,7 @@ List<SettingsModel> get styleSettings => [
|
||||
return SelectDialog<DynamicBadgeMode>(
|
||||
title: '动态未读标记',
|
||||
value: Pref.dynamicBadgeType,
|
||||
values: DynamicBadgeMode.values.map((e) {
|
||||
return (e, e.desc);
|
||||
}).toList(),
|
||||
values: DynamicBadgeMode.values.map((e) => (e, e.desc)).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -272,9 +266,7 @@ List<SettingsModel> get styleSettings => [
|
||||
return SelectDialog<DynamicBadgeMode>(
|
||||
title: '消息未读标记',
|
||||
value: Pref.msgBadgeMode,
|
||||
values: DynamicBadgeMode.values.map((e) {
|
||||
return (e, e.desc);
|
||||
}).toList(),
|
||||
values: DynamicBadgeMode.values.map((e) => (e, e.desc)).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -557,11 +549,7 @@ List<SettingsModel> get styleSettings => [
|
||||
return SelectDialog<ThemeType>(
|
||||
title: '主题模式',
|
||||
value: Pref.themeType,
|
||||
values: ThemeType.values.map(
|
||||
(e) {
|
||||
return (e, e.desc);
|
||||
},
|
||||
).toList(),
|
||||
values: ThemeType.values.map((e) => (e, e.desc)).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -608,9 +596,9 @@ List<SettingsModel> get styleSettings => [
|
||||
return SelectDialog<int>(
|
||||
title: '首页启动页',
|
||||
value: Pref.defaultHomePage,
|
||||
values: NavigationBarType.values.map((e) {
|
||||
return (e.index, e.label);
|
||||
}).toList(),
|
||||
values: NavigationBarType.values
|
||||
.map((e) => (e.index, e.label))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -132,9 +132,9 @@ List<SettingsModel> get videoSettings => [
|
||||
return SelectDialog<int>(
|
||||
title: '蜂窝网络画质',
|
||||
value: Pref.defaultVideoQaCellular,
|
||||
values: VideoQuality.values.reversed.map((e) {
|
||||
return (e.code, e.desc);
|
||||
}).toList(),
|
||||
values: VideoQuality.values.reversed
|
||||
.map((e) => (e.code, e.desc))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -185,9 +185,9 @@ List<SettingsModel> get videoSettings => [
|
||||
return SelectDialog<int>(
|
||||
title: '蜂窝网络音质',
|
||||
value: Pref.defaultAudioQaCellular,
|
||||
values: AudioQuality.values.reversed.map((e) {
|
||||
return (e.code, e.desc);
|
||||
}).toList(),
|
||||
values: AudioQuality.values.reversed
|
||||
.map((e) => (e.code, e.desc))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -238,9 +238,9 @@ List<SettingsModel> get videoSettings => [
|
||||
return SelectDialog<int>(
|
||||
title: '直播默认画质',
|
||||
value: Pref.liveQualityCellular,
|
||||
values: LiveQuality.values.map((e) {
|
||||
return (e.code, e.description);
|
||||
}).toList(),
|
||||
values: LiveQuality.values
|
||||
.map((e) => (e.code, e.description))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -288,9 +288,9 @@ List<SettingsModel> get videoSettings => [
|
||||
return SelectDialog<String>(
|
||||
title: '次选解码格式',
|
||||
value: Pref.secondDecode,
|
||||
values: VideoDecodeFormatType.values.map((e) {
|
||||
return (e.code, e.description);
|
||||
}).toList(),
|
||||
values: VideoDecodeFormatType.values
|
||||
.map((e) => (e.code, e.description))
|
||||
.toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -330,8 +330,7 @@ List<SettingsModel> get videoSettings => [
|
||||
return SelectDialog<String>(
|
||||
title: '视频同步',
|
||||
value: Pref.videoSync,
|
||||
values:
|
||||
[
|
||||
values: const [
|
||||
'audio',
|
||||
'display-resample',
|
||||
'display-resample-vdrop',
|
||||
@@ -341,9 +340,7 @@ List<SettingsModel> get videoSettings => [
|
||||
'display-adrop',
|
||||
'display-desync',
|
||||
'desync',
|
||||
].map((e) {
|
||||
return (e, e);
|
||||
}).toList(),
|
||||
].map((e) => (e, e)).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -365,9 +362,13 @@ List<SettingsModel> get videoSettings => [
|
||||
return SelectDialog<String>(
|
||||
title: '硬解模式',
|
||||
value: Pref.hardwareDecoding,
|
||||
values: ['auto', 'auto-copy', 'auto-safe', 'no', 'yes'].map((e) {
|
||||
return (e, e);
|
||||
}).toList(),
|
||||
values: const [
|
||||
'auto',
|
||||
'auto-copy',
|
||||
'auto-safe',
|
||||
'no',
|
||||
'yes',
|
||||
].map((e) => (e, e)).toList(),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -98,9 +98,7 @@ class _SettingsSearchPageState extends SearchState<SettingsSearchPage> {
|
||||
? const HttpError()
|
||||
: SliverWaterfallFlow.extent(
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
children: [
|
||||
..._list.map((item) => item.widget),
|
||||
],
|
||||
children: _list.map((item) => item.widget).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -110,8 +110,7 @@ class _AiDetailState extends CommonCollapseSlidePageState<AiConclusionPanel> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
if (item.partOutline?.isNotEmpty == true)
|
||||
...item.partOutline!.map(
|
||||
...?item.partOutline?.map(
|
||||
(item) => Wrap(
|
||||
children: [
|
||||
SelectableText.rich(
|
||||
|
||||
@@ -764,8 +764,7 @@ class VideoDetailController extends GetxController
|
||||
|
||||
return segmentModel;
|
||||
},
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
|
||||
// _segmentProgressList
|
||||
@@ -774,7 +773,7 @@ class VideoDetailController extends GetxController
|
||||
double start = (e.segment.first / duration).clamp(0.0, 1.0);
|
||||
double end = (e.segment.second / duration).clamp(0.0, 1.0);
|
||||
return Segment(start, end, _getColor(e.segmentType));
|
||||
}).toList(),
|
||||
}),
|
||||
);
|
||||
|
||||
if (positionSubscription == null &&
|
||||
|
||||
@@ -393,7 +393,6 @@ class ReplyItemGrpc extends StatelessWidget {
|
||||
],
|
||||
if (replyItem.replyControl.cardLabels
|
||||
.map((item) => item.textContent)
|
||||
.toList()
|
||||
.contains('热评'))
|
||||
Text(
|
||||
'热评',
|
||||
|
||||
@@ -1641,12 +1641,12 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
|
||||
onTap: handlePlay,
|
||||
child: Obx(
|
||||
() => NetworkImgLayer(
|
||||
radius: 0,
|
||||
quality: 60,
|
||||
src: videoDetailController.cover.value,
|
||||
width: width,
|
||||
height: height,
|
||||
boxFit: BoxFit.cover,
|
||||
fadeOutDuration: const Duration(milliseconds: 120),
|
||||
fadeInDuration: const Duration(milliseconds: 120),
|
||||
forceUseCacheWidth: true,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -2,10 +2,9 @@ import 'dart:io';
|
||||
|
||||
import 'package:PiliPlus/http/ua_type.dart';
|
||||
import 'package:PiliPlus/models/common/webview_menu_type.dart';
|
||||
import 'package:PiliPlus/utils/accounts.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/login_utils.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
@@ -111,18 +110,7 @@ class _WebviewPageState extends State<WebviewPage> {
|
||||
}
|
||||
break;
|
||||
case WebviewMenuItem.resetCookie:
|
||||
final cookies = Accounts.main.cookieJar.toList();
|
||||
for (var item in cookies) {
|
||||
await CookieManager().setCookie(
|
||||
url: WebUri(item.domain ?? ''),
|
||||
name: item.name,
|
||||
value: item.value,
|
||||
path: item.path ?? '',
|
||||
domain: item.domain,
|
||||
isSecure: item.secure,
|
||||
isHttpOnly: item.httpOnly,
|
||||
);
|
||||
}
|
||||
await LoginUtils.setWebCookie();
|
||||
SmartDialog.showToast('设置成功,刷新或重新打开网页');
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -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>(
|
||||
shareListRes.data.sessionList.map<UserModel>(
|
||||
(item) => UserModel(
|
||||
mid: item.talkerId.toInt(),
|
||||
name: item.talkerUname,
|
||||
avatar: item.talkerIcon,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
);
|
||||
} 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