mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 调整设置,支持导入导出,代码优化
This commit is contained in:
@@ -84,6 +84,7 @@ class _AboutPageState extends State<AboutPage> {
|
||||
() => ListTile(
|
||||
onTap: () => _aboutController.tapOnVersion(),
|
||||
title: const Text('当前版本'),
|
||||
leading: const Icon(Icons.commit_outlined),
|
||||
trailing: Text(_aboutController.currentVersion.value,
|
||||
style: subTitleStyle),
|
||||
),
|
||||
@@ -92,6 +93,7 @@ class _AboutPageState extends State<AboutPage> {
|
||||
() => ListTile(
|
||||
onTap: () => _aboutController.onUpdate(),
|
||||
title: const Text('最新版本'),
|
||||
leading: const Icon(Icons.flag_outlined),
|
||||
trailing: Text(
|
||||
_aboutController.isLoading.value
|
||||
? '正在获取'
|
||||
@@ -117,6 +119,7 @@ class _AboutPageState extends State<AboutPage> {
|
||||
),
|
||||
ListTile(
|
||||
onTap: () => _aboutController.githubUrl(),
|
||||
leading: const Icon(Icons.star_outline_outlined),
|
||||
title: const Text('Github开源仓库'),
|
||||
trailing: Text(
|
||||
'github.com/orz12/pilipala',
|
||||
@@ -125,6 +128,7 @@ class _AboutPageState extends State<AboutPage> {
|
||||
),
|
||||
ListTile(
|
||||
onTap: () => _aboutController.feedback(),
|
||||
leading: const Icon(Icons.feedback_outlined),
|
||||
title: const Text('问题反馈'),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
@@ -134,33 +138,37 @@ class _AboutPageState extends State<AboutPage> {
|
||||
),
|
||||
ListTile(
|
||||
onTap: () => _aboutController.qqGroup(),
|
||||
title: const Text('QQ群:392176105'),
|
||||
trailing: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 16,
|
||||
color: outline,
|
||||
leading: const Icon(Icons.group_add_outlined),
|
||||
title: const Text('QQ群'),
|
||||
trailing: Text(
|
||||
'392176105',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () => _aboutController.tgChanel(),
|
||||
onTap: () => _aboutController.tgChannel(),
|
||||
leading: const Icon(Icons.group_add_outlined),
|
||||
title: const Text('TG频道'),
|
||||
trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () => _aboutController.webSiteUrl(),
|
||||
title: const Text('访问官网'),
|
||||
leading: const Icon(Icons.language),
|
||||
title: const Text('官网'),
|
||||
trailing: Text(
|
||||
'https://pilipalanet.mysxl.cn/pilipala-x',
|
||||
'pilipalanet.mysxl.cn/pilipala-x',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () => _aboutController.aPay(),
|
||||
leading: const Icon(Icons.wallet_giftcard_outlined),
|
||||
title: const Text('赞赏'),
|
||||
trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () => _aboutController.logs(),
|
||||
leading: const Icon(Icons.bug_report_outlined),
|
||||
title: const Text('错误日志'),
|
||||
trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline),
|
||||
),
|
||||
@@ -169,11 +177,78 @@ class _AboutPageState extends State<AboutPage> {
|
||||
await CacheManage().clearCacheAll();
|
||||
getCacheSize();
|
||||
},
|
||||
leading: const Icon(Icons.delete_outline),
|
||||
title: const Text('清除缓存'),
|
||||
subtitle: Text('图片及网络缓存 $cacheSize', style: subTitleStyle),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('导入/导出设置'),
|
||||
dense: false,
|
||||
leading: const Icon(Icons.import_export_outlined),
|
||||
onTap: () {
|
||||
SmartDialog.show(
|
||||
useSystem: true,
|
||||
builder: (BuildContext context) {
|
||||
return SimpleDialog(
|
||||
title: const Text('导入/导出设置'),
|
||||
children: [
|
||||
ListTile(
|
||||
title: const Text('导出设置至剪贴板'),
|
||||
onTap: () async {
|
||||
SmartDialog.dismiss();
|
||||
String data = await GStrorage.exportAllSettings();
|
||||
Clipboard.setData(ClipboardData(text: data));
|
||||
SmartDialog.showToast('已复制到剪贴板');
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('从剪贴板导入设置'),
|
||||
onTap: () async {
|
||||
SmartDialog.dismiss();
|
||||
ClipboardData? data = await Clipboard.getData('text/plain');
|
||||
if (data == null || data.text == null || data.text!.isEmpty) {
|
||||
SmartDialog.showToast('剪贴板无数据');
|
||||
return;
|
||||
}
|
||||
SmartDialog.show(
|
||||
useSystem: true,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('是否导入如下设置?'),
|
||||
content: Text(data.text!),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
SmartDialog.dismiss();
|
||||
try{
|
||||
await GStrorage.importAllSettings(data.text!);
|
||||
SmartDialog.showToast('导入成功');
|
||||
} catch (e) {
|
||||
SmartDialog.showToast('导入失败:$e');
|
||||
}
|
||||
},
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
ListTile(
|
||||
title: const Text('重置所有设置'),
|
||||
leading: const Icon(Icons.settings_backup_restore_outlined),
|
||||
onTap: () {
|
||||
SmartDialog.show(
|
||||
useSystem: true,
|
||||
@@ -191,6 +266,8 @@ class _AboutPageState extends State<AboutPage> {
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
GStrorage.setting.clear();
|
||||
GStrorage.localCache.clear();
|
||||
GStrorage.video.clear();
|
||||
SmartDialog.showToast('重置成功');
|
||||
SmartDialog.dismiss();
|
||||
},
|
||||
@@ -312,24 +389,24 @@ class AboutController extends GetxController {
|
||||
useSystem: true,
|
||||
animationType: SmartAnimationType.centerFade_otherSlide,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
return SimpleDialog(
|
||||
title: const Text('问题反馈'),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () => launchUrl(
|
||||
children: [
|
||||
ListTile(
|
||||
title: const Text('GitHub Issue'),
|
||||
onTap: () => launchUrl(
|
||||
Uri.parse('https://github.com/orz12/pilipala/issues'),
|
||||
// 系统自带浏览器打开
|
||||
mode: LaunchMode.externalApplication,
|
||||
),
|
||||
child: const Text('GitHub Issue'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => launchUrl(
|
||||
ListTile(
|
||||
title: const Text('腾讯兔小巢'),
|
||||
onTap: () => launchUrl(
|
||||
Uri.parse('https://support.qq.com/embed/phone/637735'),
|
||||
// 系统自带浏览器打开
|
||||
mode: LaunchMode.externalApplication,
|
||||
),
|
||||
child: const Text('腾讯兔小巢'),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -355,7 +432,7 @@ class AboutController extends GetxController {
|
||||
}
|
||||
|
||||
// tg频道
|
||||
tgChanel() {
|
||||
tgChannel() {
|
||||
Clipboard.setData(
|
||||
const ClipboardData(text: 'https://t.me/+162zlPtZlT9hNWVl'),
|
||||
);
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import 'package:easy_debounce/easy_throttle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPalaX/common/skeleton/video_card_h.dart';
|
||||
import 'package:PiliPalaX/common/widgets/http_error.dart';
|
||||
import 'package:PiliPalaX/common/widgets/no_data.dart';
|
||||
import 'package:PiliPalaX/pages/history/widgets/item.dart';
|
||||
|
||||
import '../../common/constants.dart';
|
||||
|
||||
@@ -68,7 +68,7 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
||||
void setTabConfig() async {
|
||||
defaultTabs = [...tabsConfig];
|
||||
tabbarSort = settingStorage.get(SettingBoxKey.tabbarSort,
|
||||
defaultValue: ['live', 'rcmd', 'hot', 'bangumi']);
|
||||
defaultValue: ['live', 'rcmd', 'hot', 'bangumi']).map<String>((i) => i.toString()).toList();
|
||||
defaultTabs.retainWhere(
|
||||
(item) => tabbarSort.contains((item['type'] as TabType).id));
|
||||
defaultTabs.sort((a, b) => tabbarSort
|
||||
|
||||
@@ -184,12 +184,14 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
duration: const Duration(milliseconds: 500),
|
||||
height: snapshot.data ? top + 52 : top,
|
||||
padding: EdgeInsets.fromLTRB(14, top + 6, 14, 0),
|
||||
child: UserInfoWidget(
|
||||
top: top,
|
||||
ctr: ctr,
|
||||
userLogin: isUserLoggedIn,
|
||||
userFace: ctr?.userFace.value,
|
||||
callback: () => callback!(),
|
||||
child: Obx(
|
||||
() => UserInfoWidget(
|
||||
top: top,
|
||||
ctr: ctr,
|
||||
userLogin: isUserLoggedIn,
|
||||
userFace: ctr?.userFace.value,
|
||||
callback: () => callback!(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -219,18 +221,18 @@ class UserInfoWidget extends StatelessWidget {
|
||||
return Row(
|
||||
children: [
|
||||
SearchBar(ctr: ctr),
|
||||
if (userLogin.value) ...[
|
||||
const SizedBox(width: 4),
|
||||
ClipRect(
|
||||
child: IconButton(
|
||||
tooltip: '消息',
|
||||
onPressed: () => Get.toNamed('/whisper'),
|
||||
icon: const Icon(
|
||||
Icons.notifications_none,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
const SizedBox(width: 4),
|
||||
Obx(() => userLogin.value
|
||||
? ClipRect(
|
||||
child: IconButton(
|
||||
tooltip: '消息',
|
||||
onPressed: () => Get.toNamed('/whisper'),
|
||||
icon: const Icon(
|
||||
Icons.notifications_none,
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink()),
|
||||
const SizedBox(width: 8),
|
||||
Semantics(
|
||||
label: "我的",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:floating/floating.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
@@ -31,7 +31,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
int? _lastSelectTime; //上次点击时间
|
||||
Box setting = GStrorage.setting;
|
||||
late bool enableMYBar;
|
||||
late bool horizontalScreen;
|
||||
late bool adaptiveNavBar;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -40,7 +40,8 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
_mainController.pageController =
|
||||
PageController(initialPage: _mainController.selectedIndex);
|
||||
enableMYBar = setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
||||
horizontalScreen = setting.get(SettingBoxKey.horizontalScreen, defaultValue: false);
|
||||
adaptiveNavBar =
|
||||
setting.get(SettingBoxKey.adaptiveNavBar, defaultValue: false);
|
||||
}
|
||||
|
||||
void setIndex(int value) async {
|
||||
@@ -112,134 +113,137 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
||||
onPopInvoked: (bool didPop) async {
|
||||
_mainController.onBackPressed(context);
|
||||
},
|
||||
child: horizontalScreen
|
||||
? AdaptiveScaffold(
|
||||
body: (_) => PageView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _mainController.pageController,
|
||||
onPageChanged: (index) {
|
||||
_mainController.selectedIndex = index;
|
||||
setState(() {});
|
||||
},
|
||||
children: _mainController.pages,
|
||||
),
|
||||
destinations: _mainController.navigationBars.map((e) => NavigationDestination(
|
||||
icon: Badge(
|
||||
label: _mainController.dynamicBadgeType ==
|
||||
DynamicBadgeMode.number
|
||||
? Text(e['count'].toString())
|
||||
: null,
|
||||
padding: const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||
isLabelVisible:
|
||||
_mainController.dynamicBadgeType !=
|
||||
DynamicBadgeMode.hidden &&
|
||||
e['count'] > 0,
|
||||
child: e['icon'],
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
textColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.onInverseSurface,
|
||||
),
|
||||
selectedIcon: e['selectIcon'],
|
||||
label: e['label'],
|
||||
)).toList(),
|
||||
onSelectedIndexChange: (value) => setIndex(value),
|
||||
selectedIndex: _mainController.selectedIndex,
|
||||
useDrawer: false
|
||||
)
|
||||
: Scaffold(
|
||||
extendBody: true,
|
||||
body: PageView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _mainController.pageController,
|
||||
onPageChanged: (index) {
|
||||
_mainController.selectedIndex = index;
|
||||
setState(() {});
|
||||
},
|
||||
children: _mainController.pages,
|
||||
),
|
||||
bottomNavigationBar: StreamBuilder(
|
||||
stream: _mainController.hideTabBar
|
||||
? _mainController.bottomBarStream.stream
|
||||
: StreamController<bool>.broadcast().stream,
|
||||
initialData: true,
|
||||
builder: (context, AsyncSnapshot snapshot) {
|
||||
return AnimatedSlide(
|
||||
curve: Curves.easeInOutCubicEmphasized,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
offset: Offset(0, snapshot.data ? 0 : 1),
|
||||
child: enableMYBar
|
||||
? NavigationBar(
|
||||
onDestinationSelected: (value) => setIndex(value),
|
||||
selectedIndex: _mainController.selectedIndex,
|
||||
destinations: <Widget>[
|
||||
..._mainController.navigationBars.map((e) {
|
||||
return NavigationDestination(
|
||||
icon: Badge(
|
||||
label: _mainController.dynamicBadgeType ==
|
||||
DynamicBadgeMode.number
|
||||
? Text(e['count'].toString())
|
||||
: null,
|
||||
padding: const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||
isLabelVisible:
|
||||
_mainController.dynamicBadgeType !=
|
||||
DynamicBadgeMode.hidden &&
|
||||
e['count'] > 0,
|
||||
child: e['icon'],
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
textColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.onInverseSurface,
|
||||
),
|
||||
selectedIcon: e['selectIcon'],
|
||||
label: e['label'],
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
)
|
||||
: BottomNavigationBar(
|
||||
currentIndex: _mainController.selectedIndex,
|
||||
onTap: (value) => setIndex(value),
|
||||
iconSize: 16,
|
||||
selectedFontSize: 12,
|
||||
unselectedFontSize: 12,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
// selectedItemColor:
|
||||
// Theme.of(context).colorScheme.primary, // 选中项的颜色
|
||||
// unselectedItemColor:
|
||||
// Theme.of(context).colorScheme.onSurface,
|
||||
items: [
|
||||
..._mainController.navigationBars.map((e) {
|
||||
return BottomNavigationBarItem(
|
||||
icon: Badge(
|
||||
label: _mainController.dynamicBadgeType ==
|
||||
DynamicBadgeMode.number
|
||||
? Text(e['count'].toString())
|
||||
: null,
|
||||
padding: const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||
isLabelVisible:
|
||||
_mainController.dynamicBadgeType !=
|
||||
DynamicBadgeMode.hidden &&
|
||||
e['count'] > 0,
|
||||
child: e['icon'],
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
textColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.onInverseSurface,
|
||||
),
|
||||
activeIcon: e['selectIcon'],
|
||||
label: e['label'],
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
child: adaptiveNavBar
|
||||
? AdaptiveScaffold(
|
||||
body: (_) => PageView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _mainController.pageController,
|
||||
onPageChanged: (index) {
|
||||
_mainController.selectedIndex = index;
|
||||
setState(() {});
|
||||
},
|
||||
children: _mainController.pages,
|
||||
),
|
||||
destinations: _mainController.navigationBars
|
||||
.map((e) => NavigationDestination(
|
||||
icon: Badge(
|
||||
label: _mainController.dynamicBadgeType ==
|
||||
DynamicBadgeMode.number
|
||||
? Text(e['count'].toString())
|
||||
: null,
|
||||
padding: const EdgeInsets.fromLTRB(2, 0, 2, 0),
|
||||
isLabelVisible: _mainController.dynamicBadgeType !=
|
||||
DynamicBadgeMode.hidden &&
|
||||
e['count'] > 0,
|
||||
child: e['icon'],
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
textColor:
|
||||
Theme.of(context).colorScheme.onInverseSurface,
|
||||
),
|
||||
selectedIcon: e['selectIcon'],
|
||||
label: e['label'],
|
||||
))
|
||||
.toList(),
|
||||
onSelectedIndexChange: (value) => setIndex(value),
|
||||
selectedIndex: _mainController.selectedIndex,
|
||||
extendedNavigationRailWidth: 180,
|
||||
transitionDuration: const Duration(milliseconds: 500),
|
||||
useDrawer: true)
|
||||
: Scaffold(
|
||||
extendBody: true,
|
||||
body: PageView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
controller: _mainController.pageController,
|
||||
onPageChanged: (index) {
|
||||
_mainController.selectedIndex = index;
|
||||
setState(() {});
|
||||
},
|
||||
children: _mainController.pages,
|
||||
),
|
||||
bottomNavigationBar: StreamBuilder(
|
||||
stream: _mainController.hideTabBar
|
||||
? _mainController.bottomBarStream.stream
|
||||
: StreamController<bool>.broadcast().stream,
|
||||
initialData: true,
|
||||
builder: (context, AsyncSnapshot snapshot) {
|
||||
return AnimatedSlide(
|
||||
curve: Curves.easeInOutCubicEmphasized,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
offset: Offset(0, snapshot.data ? 0 : 1),
|
||||
child: enableMYBar
|
||||
? NavigationBar(
|
||||
onDestinationSelected: (value) => setIndex(value),
|
||||
selectedIndex: _mainController.selectedIndex,
|
||||
destinations: <Widget>[
|
||||
..._mainController.navigationBars.map((e) {
|
||||
return NavigationDestination(
|
||||
icon: Badge(
|
||||
label: _mainController.dynamicBadgeType ==
|
||||
DynamicBadgeMode.number
|
||||
? Text(e['count'].toString())
|
||||
: null,
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||
isLabelVisible:
|
||||
_mainController.dynamicBadgeType !=
|
||||
DynamicBadgeMode.hidden &&
|
||||
e['count'] > 0,
|
||||
child: e['icon'],
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
textColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.onInverseSurface,
|
||||
),
|
||||
selectedIcon: e['selectIcon'],
|
||||
label: e['label'],
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
)
|
||||
: BottomNavigationBar(
|
||||
currentIndex: _mainController.selectedIndex,
|
||||
onTap: (value) => setIndex(value),
|
||||
iconSize: 16,
|
||||
selectedFontSize: 12,
|
||||
unselectedFontSize: 12,
|
||||
type: BottomNavigationBarType.fixed,
|
||||
// selectedItemColor:
|
||||
// Theme.of(context).colorScheme.primary, // 选中项的颜色
|
||||
// unselectedItemColor:
|
||||
// Theme.of(context).colorScheme.onSurface,
|
||||
items: [
|
||||
..._mainController.navigationBars.map((e) {
|
||||
return BottomNavigationBarItem(
|
||||
icon: Badge(
|
||||
label: _mainController.dynamicBadgeType ==
|
||||
DynamicBadgeMode.number
|
||||
? Text(e['count'].toString())
|
||||
: null,
|
||||
padding:
|
||||
const EdgeInsets.fromLTRB(6, 0, 6, 0),
|
||||
isLabelVisible:
|
||||
_mainController.dynamicBadgeType !=
|
||||
DynamicBadgeMode.hidden &&
|
||||
e['count'] > 0,
|
||||
child: e['icon'],
|
||||
backgroundColor:
|
||||
Theme.of(context).colorScheme.primary,
|
||||
textColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.onInverseSurface,
|
||||
),
|
||||
activeIcon: e['selectIcon'],
|
||||
label: e['label'],
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +79,16 @@ class _MediaPageState extends State<MediaPage>
|
||||
),
|
||||
),
|
||||
),
|
||||
trailing: IconButton(
|
||||
tooltip: '设置',
|
||||
onPressed: () {
|
||||
Get.toNamed('/setting');
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.settings_outlined,
|
||||
size: 20,
|
||||
),
|
||||
)
|
||||
),
|
||||
for (var i in mediaController.list) ...[
|
||||
ListTile(
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'dart:async';
|
||||
import 'package:PiliPalaX/common/constants.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -28,8 +27,6 @@ class _RankPageState extends State<RankPage>
|
||||
TabController(vsync: this, length: _rankController.tabs.length);
|
||||
_selectedTabIndex = _rankController.initialIndex.value;
|
||||
_rankController.tabController.addListener(() {
|
||||
print("_rankController.tabController.index");
|
||||
print(_rankController.tabController.index);
|
||||
if (!_rankController.tabController.indexIsChanging) {
|
||||
// _rankController.onRefresh();
|
||||
setState(() {
|
||||
|
||||
@@ -21,7 +21,6 @@ class ExtraSetting extends StatefulWidget {
|
||||
class _ExtraSettingState extends State<ExtraSetting> {
|
||||
Box setting = GStrorage.setting;
|
||||
final SettingController settingController = Get.put(SettingController());
|
||||
static Box localCache = GStrorage.localCache;
|
||||
late dynamic defaultReplySort;
|
||||
late dynamic defaultDynamicType;
|
||||
late dynamic enableSystemProxy;
|
||||
@@ -45,9 +44,9 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
enableSystemProxy =
|
||||
setting.get(SettingBoxKey.enableSystemProxy, defaultValue: false);
|
||||
defaultSystemProxyHost =
|
||||
localCache.get(LocalCacheKey.systemProxyHost, defaultValue: '');
|
||||
setting.get(SettingBoxKey.systemProxyHost, defaultValue: '');
|
||||
defaultSystemProxyPort =
|
||||
localCache.get(LocalCacheKey.systemProxyPort, defaultValue: '');
|
||||
setting.get(SettingBoxKey.systemProxyPort, defaultValue: '');
|
||||
}
|
||||
|
||||
// 设置代理
|
||||
@@ -111,8 +110,8 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
localCache.put(LocalCacheKey.systemProxyHost, systemProxyHost);
|
||||
localCache.put(LocalCacheKey.systemProxyPort, systemProxyPort);
|
||||
setting.put(SettingBoxKey.systemProxyHost, systemProxyHost);
|
||||
setting.put(SettingBoxKey.systemProxyPort, systemProxyPort);
|
||||
SmartDialog.dismiss();
|
||||
// Request.dio;
|
||||
},
|
||||
@@ -143,9 +142,10 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
body: ListView(
|
||||
children: [
|
||||
Obx(
|
||||
() => ListTile(
|
||||
() => ListTile(
|
||||
enableFeedback: true,
|
||||
onTap: () => settingController.onOpenFeedBack(),
|
||||
leading: const Icon(Icons.vibration_outlined),
|
||||
title: Text('震动反馈', style: titleStyle),
|
||||
subtitle: Text('请确定手机设置中已开启震动反馈', style: subTitleStyle),
|
||||
trailing: Transform.scale(
|
||||
@@ -153,13 +153,13 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
scale: 0.8,
|
||||
child: Switch(
|
||||
thumbIcon: MaterialStateProperty.resolveWith<Icon?>(
|
||||
(Set<MaterialState> states) {
|
||||
if (states.isNotEmpty &&
|
||||
states.first == MaterialState.selected) {
|
||||
return const Icon(Icons.done);
|
||||
}
|
||||
return null; // All other states will use the default thumbIcon.
|
||||
}),
|
||||
(Set<MaterialState> states) {
|
||||
if (states.isNotEmpty &&
|
||||
states.first == MaterialState.selected) {
|
||||
return const Icon(Icons.done);
|
||||
}
|
||||
return null; // All other states will use the default thumbIcon.
|
||||
}),
|
||||
value: settingController.feedBackEnable.value,
|
||||
onChanged: (value) => settingController.onOpenFeedBack()),
|
||||
),
|
||||
@@ -168,12 +168,14 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
const SetSwitchItem(
|
||||
title: '大家都在搜',
|
||||
subTitle: '是否展示「大家都在搜」',
|
||||
leading: Icon(Icons.data_thresholding_outlined),
|
||||
setKey: SettingBoxKey.enableHotKey,
|
||||
defaultVal: true,
|
||||
),
|
||||
SetSwitchItem(
|
||||
title: '搜索默认词',
|
||||
subTitle: '是否展示搜索框默认词',
|
||||
leading: const Icon(Icons.whatshot_outlined),
|
||||
setKey: SettingBoxKey.enableSearchWord,
|
||||
defaultVal: true,
|
||||
callFn: (val) {
|
||||
@@ -183,30 +185,35 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
const SetSwitchItem(
|
||||
title: '快速收藏',
|
||||
subTitle: '点按收藏至默认,长按选择文件夹',
|
||||
leading: Icon(Icons.bookmark_add_outlined),
|
||||
setKey: SettingBoxKey.enableQuickFav,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '评论区搜索关键词',
|
||||
subTitle: '展示评论区搜索关键词',
|
||||
leading: Icon(Icons.search_outlined),
|
||||
setKey: SettingBoxKey.enableWordRe,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '启用ai总结',
|
||||
subTitle: '视频详情页开启ai总结',
|
||||
leading: Icon(Icons.engineering_outlined),
|
||||
setKey: SettingBoxKey.enableAi,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '消息页禁用“收到的赞”功能',
|
||||
subTitle: '禁止打开入口,降低网络社交依赖',
|
||||
leading: Icon(Icons.beach_access_outlined),
|
||||
setKey: SettingBoxKey.disableLikeMsg,
|
||||
defaultVal: false,
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('评论展示', style: titleStyle),
|
||||
leading: const Icon(Icons.whatshot_outlined),
|
||||
subtitle: Text(
|
||||
'当前优先展示「${ReplySortType.values[defaultReplySort].titles}」',
|
||||
style: subTitleStyle,
|
||||
@@ -233,6 +240,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('动态展示', style: titleStyle),
|
||||
leading: const Icon(Icons.dynamic_feed_outlined),
|
||||
subtitle: Text(
|
||||
'当前优先展示「${DynamicsType.values[defaultDynamicType].labels}」',
|
||||
style: subTitleStyle,
|
||||
@@ -259,6 +267,7 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
ListTile(
|
||||
enableFeedback: true,
|
||||
onTap: () => twoFADialog(),
|
||||
leading: const Icon(Icons.airplane_ticket_outlined),
|
||||
title: Text('设置代理', style: titleStyle),
|
||||
subtitle: Text('设置代理 host:port', style: subTitleStyle),
|
||||
trailing: Transform.scale(
|
||||
@@ -287,12 +296,14 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
||||
const SetSwitchItem(
|
||||
title: '自动清除缓存',
|
||||
subTitle: '每次启动时清除缓存',
|
||||
leading: Icon(Icons.auto_delete_outlined),
|
||||
setKey: SettingBoxKey.autoClearCache,
|
||||
defaultVal: false,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '检查更新',
|
||||
subTitle: '每次启动时检查是否需要更新',
|
||||
leading: Icon(Icons.system_update_alt_outlined),
|
||||
setKey: SettingBoxKey.autoUpdate,
|
||||
defaultVal: false,
|
||||
),
|
||||
|
||||
@@ -22,10 +22,6 @@ class _HiddenSettingState extends State<HiddenSetting> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
TextStyle titleStyle = Theme.of(context).textTheme.titleMedium!;
|
||||
TextStyle subTitleStyle = Theme.of(context)
|
||||
.textTheme
|
||||
.labelMedium!
|
||||
.copyWith(color: Theme.of(context).colorScheme.outline);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: false,
|
||||
|
||||
@@ -65,30 +65,35 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
const SetSwitchItem(
|
||||
title: '弹幕开关',
|
||||
subTitle: '是否展示弹幕',
|
||||
leading: Icon(Icons.comment_outlined),
|
||||
setKey: SettingBoxKey.enableShowDanmaku,
|
||||
defaultVal: false,
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
onTap: () => Get.toNamed('/playSpeedSet'),
|
||||
leading: const Icon(Icons.speed_outlined),
|
||||
title: Text('倍速设置', style: titleStyle),
|
||||
subtitle: Text('设置视频播放速度', style: subTitleStyle),
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '自动播放',
|
||||
subTitle: '进入详情页自动播放',
|
||||
leading: Icon(Icons.motion_photos_auto_outlined),
|
||||
setKey: SettingBoxKey.autoPlayEnable,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '双击快退/快进',
|
||||
subTitle: '左侧双击快退,右侧双击快进',
|
||||
leading: Icon(Icons.touch_app_outlined),
|
||||
setKey: SettingBoxKey.enableQuickDouble,
|
||||
defaultVal: true,
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('自动启用字幕', style: titleStyle),
|
||||
leading: const Icon(Icons.closed_caption_outlined),
|
||||
subtitle: Text(
|
||||
'当前选择偏好:'
|
||||
'${SubtitlePreferenceCode.fromCode(defaultSubtitlePreference)!.description}',
|
||||
@@ -116,30 +121,35 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
const SetSwitchItem(
|
||||
title: '竖屏扩大展示',
|
||||
subTitle: '小屏竖屏视频宽高比由16:9扩大至4:5(!暂不支持临时收起)',
|
||||
leading: Icon(Icons.expand_outlined),
|
||||
setKey: SettingBoxKey.enableVerticalExpand,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '自动全屏',
|
||||
subTitle: '视频开始播放时进入全屏',
|
||||
leading: Icon(Icons.fullscreen_outlined),
|
||||
setKey: SettingBoxKey.enableAutoEnter,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '自动退出全屏',
|
||||
subTitle: '视频结束播放时退出全屏',
|
||||
leading: Icon(Icons.fullscreen_exit_outlined),
|
||||
setKey: SettingBoxKey.enableAutoExit,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '全向旋转',
|
||||
subTitle: '非全屏时可受重力转为临时全屏,若系统锁定旋转仍异常触发请关闭,无异常可保持开启',
|
||||
subTitle: '小屏可受重力转为临时全屏,若系统锁定旋转仍触发请关闭,关闭会影响横屏适配',
|
||||
leading: Icon(Icons.screen_rotation_alt_outlined),
|
||||
setKey: SettingBoxKey.allowRotateScreen,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '后台播放',
|
||||
subTitle: '进入后台时继续播放',
|
||||
leading: Icon(Icons.motion_photos_pause_outlined),
|
||||
setKey: SettingBoxKey.continuePlayInBackground,
|
||||
defaultVal: true,
|
||||
),
|
||||
@@ -147,6 +157,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
SetSwitchItem(
|
||||
title: '后台画中画',
|
||||
subTitle: '进入后台时以小窗形式(PiP)播放',
|
||||
leading: const Icon(Icons.picture_in_picture_outlined),
|
||||
setKey: SettingBoxKey.autoPiP,
|
||||
defaultVal: false,
|
||||
callFn: (val) {
|
||||
@@ -160,26 +171,30 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
const SetSwitchItem(
|
||||
title: '画中画不加载弹幕',
|
||||
subTitle: '当弹幕开关开启时,小窗屏蔽弹幕以获得较好的体验',
|
||||
leading: Icon(Icons.comments_disabled_outlined),
|
||||
setKey: SettingBoxKey.pipNoDanmaku,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '全屏手势反向',
|
||||
subTitle: '默认播放器中部向上滑动进入全屏,向下退出\n开启后向下全屏,向上退出',
|
||||
leading: Icon(Icons.swap_vert_outlined),
|
||||
setKey: SettingBoxKey.fullScreenGestureReverse,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '观看人数',
|
||||
subTitle: '展示同时在看人数',
|
||||
leading: Icon(Icons.people_outlined),
|
||||
setKey: SettingBoxKey.enableOnlineTotal,
|
||||
defaultVal: false,
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('默认全屏方式', style: titleStyle),
|
||||
title: Text('默认全屏方向', style: titleStyle),
|
||||
leading: const Icon(Icons.open_with_outlined),
|
||||
subtitle: Text(
|
||||
'当前全屏方式:${FullScreenModeCode.fromCode(defaultFullScreenMode)!.description}',
|
||||
'当前全屏方向:${FullScreenModeCode.fromCode(defaultFullScreenMode)!.description}',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
onTap: () async {
|
||||
@@ -187,7 +202,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SelectDialog<int>(
|
||||
title: '默认全屏方式',
|
||||
title: '默认全屏方向',
|
||||
value: defaultFullScreenMode,
|
||||
values: FullScreenMode.values.map((e) {
|
||||
return {'title': e.description, 'value': e.code};
|
||||
@@ -204,6 +219,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('底部进度条展示', style: titleStyle),
|
||||
leading: const Icon(Icons.border_bottom_outlined),
|
||||
subtitle: Text(
|
||||
'当前展示方式:${BtmProgresBehaviorCode.fromCode(defaultBtmProgressBehavior)!.description}',
|
||||
style: subTitleStyle,
|
||||
@@ -230,6 +246,7 @@ class _PlaySettingState extends State<PlaySetting> {
|
||||
const SetSwitchItem(
|
||||
title: '后台音频服务',
|
||||
subTitle: '避免画中画没有播放暂停功能',
|
||||
leading: Icon(Icons.volume_up_outlined),
|
||||
setKey: SettingBoxKey.enableBackgroundPlay,
|
||||
defaultVal: true,
|
||||
),
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:PiliPalaX/utils/cookie.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
@@ -6,6 +8,11 @@ import 'package:PiliPalaX/http/interceptor_anonymity.dart';
|
||||
import 'package:PiliPalaX/http/member.dart';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
|
||||
import '../../http/user.dart';
|
||||
import '../../models/user/info.dart';
|
||||
import '../../utils/login.dart';
|
||||
import '../home/controller.dart';
|
||||
import '../media/controller.dart';
|
||||
import '../mine/controller.dart';
|
||||
|
||||
class PrivacySetting extends StatefulWidget {
|
||||
@@ -18,13 +25,16 @@ class PrivacySetting extends StatefulWidget {
|
||||
class _PrivacySettingState extends State<PrivacySetting> {
|
||||
bool userLogin = false;
|
||||
Box userInfoCache = GStrorage.userInfo;
|
||||
var userInfo;
|
||||
UserInfoData? userInfo;
|
||||
late bool hiddenSettingUnlocked;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
userInfo = userInfoCache.get('userInfoCache');
|
||||
userLogin = userInfo != null;
|
||||
hiddenSettingUnlocked = GStrorage.setting
|
||||
.get(SettingBoxKey.hiddenSettingUnlocked, defaultValue: false);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -56,6 +66,7 @@ class _PrivacySettingState extends State<PrivacySetting> {
|
||||
dense: false,
|
||||
title: Text('黑名单管理', style: titleStyle),
|
||||
subtitle: Text('已拉黑用户', style: subTitleStyle),
|
||||
leading: const Icon(Icons.block),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
@@ -66,15 +77,33 @@ class _PrivacySettingState extends State<PrivacySetting> {
|
||||
},
|
||||
dense: false,
|
||||
title: Text('刷新access_key', style: titleStyle),
|
||||
leading: const Icon(Icons.perm_device_info_outlined),
|
||||
subtitle: Text(
|
||||
'access_key是app端的用户凭证,用于推荐接口。刷新将使用cookie请求新的access_key,小概率导致其他设备下线。若发现app端推荐内容不是个性化内容,可尝试刷新',
|
||||
'用于app端推荐接口的用户凭证。刷新有小概率导致其他设备下线。若app端未推荐个性化内容,可尝试刷新或清除本app数据后重新登录',
|
||||
style: subTitleStyle),
|
||||
),
|
||||
if (hiddenSettingUnlocked)
|
||||
ListTile(
|
||||
title: Text(
|
||||
'导入/导出cookie',
|
||||
style: titleStyle,
|
||||
),
|
||||
subtitle: Text(
|
||||
'cookie代表您的登录状态,仅供高级用户使用',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
leading: const Icon(Icons.cookie_outlined),
|
||||
dense: false,
|
||||
onTap: () {
|
||||
import_export_cookies(titleStyle, subTitleStyle);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
MineController.onChangeAnonymity(context);
|
||||
setState(() {});
|
||||
},
|
||||
leading: const Icon(Icons.privacy_tip_outlined),
|
||||
dense: false,
|
||||
title: Text(MineController.anonymity ? '退出无痕模式' : '进入无痕模式',
|
||||
style: titleStyle),
|
||||
@@ -104,6 +133,7 @@ class _PrivacySettingState extends State<PrivacySetting> {
|
||||
},
|
||||
);
|
||||
},
|
||||
leading: const Icon(Icons.flag_outlined),
|
||||
dense: false,
|
||||
title: Text('了解无痕模式', style: titleStyle),
|
||||
subtitle: Text('查看无痕模式作用的API列表', style: subTitleStyle),
|
||||
@@ -112,4 +142,146 @@ class _PrivacySettingState extends State<PrivacySetting> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void import_export_cookies(TextStyle titleStyle, TextStyle subTitleStyle) {
|
||||
SmartDialog.show(
|
||||
useSystem: true,
|
||||
builder: (BuildContext context) {
|
||||
return SimpleDialog(
|
||||
title: const Text('导入/导出cookie', style: TextStyle(color: Colors.red)),
|
||||
children: [
|
||||
ListTile(
|
||||
title: Text(
|
||||
'导出cookie至剪贴板',
|
||||
style: titleStyle.copyWith(color: Colors.red),
|
||||
),
|
||||
leading: const Icon(
|
||||
Icons.warning_amber,
|
||||
color: Colors.red,
|
||||
),
|
||||
subtitle: Text(
|
||||
'泄露账号cookie等同于绕过账号密码与验证码直接登录,可导致隐私泄露、风控、毁号、盗号等各类问题。\n'
|
||||
'你应妥善保管该cookie且仅供自己使用。你承诺,不会利用本服务进行任何违法或不当的活动。你承诺,对所进行的一切活动'
|
||||
'(包括但不限于网上点击同意或提交各类规则协议或购买服务、分享资讯或图片等)负全部责任。\n'
|
||||
'你承诺、理解、同意并确认,在你的账户遭到未获授权的使用,或者发生其他任何安全问题时,'
|
||||
'作者不对上述情形产生的任何直接或间接的遗失或损害承担责任。',
|
||||
style: subTitleStyle.copyWith(color: Colors.redAccent),
|
||||
),
|
||||
dense: false,
|
||||
onTap: () async {
|
||||
await SmartDialog.dismiss();
|
||||
if (!userLogin) {
|
||||
SmartDialog.showToast('请先登录');
|
||||
return;
|
||||
}
|
||||
final String cookie = await CookieTool.exportCookie();
|
||||
await SmartDialog.show(
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('导出cookie(危险)',
|
||||
style: TextStyle(color: Colors.red)),
|
||||
content: Text(cookie),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await SmartDialog.dismiss();
|
||||
await Clipboard.setData(
|
||||
ClipboardData(text: cookie));
|
||||
},
|
||||
child: const Text('复制(危险)',
|
||||
style: TextStyle(color: Colors.red)),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await SmartDialog.dismiss();
|
||||
},
|
||||
child: const Text('取消'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
ListTile(
|
||||
title: Text(
|
||||
'从剪贴板导入cookie',
|
||||
style: titleStyle,
|
||||
),
|
||||
leading: const Icon(
|
||||
Icons.warning_amber,
|
||||
color: Colors.red,
|
||||
),
|
||||
subtitle: Text(
|
||||
'导入将覆盖当前登录状态,你应自行对利用服务从事的所有行为及结果承担责任,请慎用',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
dense: false,
|
||||
onTap: () async {
|
||||
await SmartDialog.dismiss();
|
||||
ClipboardData? data = await Clipboard.getData('text/plain');
|
||||
if (data == null || data.text == null || data.text == '') {
|
||||
SmartDialog.showToast('未检测到剪贴板内容');
|
||||
return;
|
||||
}
|
||||
await SmartDialog.show(
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('导入剪贴板中的cookie'),
|
||||
content: Text(data.text!),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await SmartDialog.dismiss();
|
||||
},
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
await SmartDialog.dismiss();
|
||||
final String cookie = data.text!;
|
||||
try {
|
||||
await CookieTool.importCookie(cookie);
|
||||
await SmartDialog.showToast('已导入');
|
||||
await CookieTool.onSet();
|
||||
final result = await UserHttp.userInfo();
|
||||
if (result['status'] &&
|
||||
result['data'].isLogin) {
|
||||
SmartDialog.showToast('登录成功,当前采用「'
|
||||
'${GStrorage.setting.get(SettingBoxKey.defaultRcmdType, defaultValue: 'web')}'
|
||||
'端」推荐');
|
||||
Box userInfoCache = GStrorage.userInfo;
|
||||
await userInfoCache.put(
|
||||
'userInfoCache', result['data']);
|
||||
final HomeController homeCtr =
|
||||
Get.find<HomeController>();
|
||||
homeCtr.updateLoginStatus(true);
|
||||
homeCtr.userFace.value = result['data'].face;
|
||||
final MediaController mediaCtr =
|
||||
Get.find<MediaController>();
|
||||
mediaCtr.mid = result['data'].mid;
|
||||
await LoginUtils.refreshLoginStatus(true);
|
||||
Get.back();
|
||||
} else {
|
||||
// 获取用户信息失败
|
||||
SmartDialog.showNotify(
|
||||
msg:
|
||||
'登录失败,请检查cookie是否正确,${result['message']}',
|
||||
notifyType: NotifyType.warning);
|
||||
}
|
||||
} catch (e) {
|
||||
SmartDialog.showToast('导入失败:$e');
|
||||
}
|
||||
},
|
||||
child: const Text('确认'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
||||
centerTitle: false,
|
||||
titleSpacing: 0,
|
||||
title: Text(
|
||||
'推荐设置',
|
||||
'推荐流设置',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
@@ -66,6 +66,7 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('首页推荐类型', style: titleStyle),
|
||||
leading: const Icon(Icons.model_training_outlined),
|
||||
subtitle: Text(
|
||||
'当前使用「$defaultRcmdType端」推荐¹',
|
||||
style: subTitleStyle,
|
||||
@@ -131,12 +132,14 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
||||
const SetSwitchItem(
|
||||
title: '推荐动态',
|
||||
subTitle: '是否在推荐内容中展示动态(仅app端)',
|
||||
leading: Icon(Icons.motion_photos_on_outlined),
|
||||
setKey: SettingBoxKey.enableRcmdDynamic,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '首页推荐刷新',
|
||||
subTitle: '下拉刷新时保留上次内容',
|
||||
leading: Icon(Icons.refresh),
|
||||
setKey: SettingBoxKey.enableSaveLastData,
|
||||
defaultVal: false,
|
||||
),
|
||||
@@ -144,6 +147,7 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
||||
const Divider(height: 1),
|
||||
ListTile(
|
||||
dense: false,
|
||||
leading: const Icon(Icons.thumb_up_outlined),
|
||||
title: Text('点赞率过滤', style: titleStyle),
|
||||
subtitle: Text(
|
||||
'过滤掉点赞数/播放量「小于$minLikeRatioForRecommend%」的推荐视频(仅web端)',
|
||||
@@ -172,6 +176,7 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('视频时长过滤', style: titleStyle),
|
||||
leading: const Icon(Icons.timelapse_outlined),
|
||||
subtitle: Text(
|
||||
'过滤掉时长「小于$minDurationForRcmd秒」的推荐视频',
|
||||
style: subTitleStyle,
|
||||
@@ -199,6 +204,7 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
||||
SetSwitchItem(
|
||||
title: '已关注Up豁免推荐过滤',
|
||||
subTitle: '推荐中已关注用户发布的内容不会被过滤',
|
||||
leading: const Icon(Icons.favorite_border_outlined),
|
||||
setKey: SettingBoxKey.exemptFilterForFollowed,
|
||||
defaultVal: true,
|
||||
callFn: (_) => {RecommendFilter.update},
|
||||
@@ -234,6 +240,7 @@ class _RecommendSettingState extends State<RecommendSetting> {
|
||||
SetSwitchItem(
|
||||
title: '过滤器也应用于相关视频',
|
||||
subTitle: '视频详情页的相关视频也进行过滤²',
|
||||
leading: const Icon(Icons.explore_outlined),
|
||||
setKey: SettingBoxKey.applyFilterToRelatedVideos,
|
||||
defaultVal: true,
|
||||
callFn: (_) => {RecommendFilter.update},
|
||||
|
||||
@@ -63,7 +63,8 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
children: [
|
||||
SetSwitchItem(
|
||||
title: '横屏适配',
|
||||
subTitle: '开启该项启用横屏布局与逻辑(测试)',
|
||||
subTitle: '启用横屏布局与逻辑,适用于平板等设备',
|
||||
leading: const Icon(Icons.phonelink_outlined),
|
||||
setKey: SettingBoxKey.horizontalScreen,
|
||||
defaultVal: false,
|
||||
callFn: (value) {
|
||||
@@ -75,15 +76,24 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
SmartDialog.showToast('已关闭横屏适配');
|
||||
}
|
||||
}),
|
||||
const SetSwitchItem(
|
||||
title: '自适应底栏/侧边栏',
|
||||
subTitle: '横竖屏自动切换(其它底栏设置失效)',
|
||||
leading: Icon(Icons.chrome_reader_mode_outlined),
|
||||
setKey: SettingBoxKey.adaptiveNavBar,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: 'MD3样式底栏',
|
||||
subTitle: '符合Material You设计规范的底栏,关闭可使底栏变窄',
|
||||
subTitle: 'Material You设计规范底栏,关闭可变窄',
|
||||
leading: Icon(Icons.design_services_outlined),
|
||||
setKey: SettingBoxKey.enableMYBar,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '首页顶栏收起',
|
||||
subTitle: '首页列表滑动时,收起顶栏',
|
||||
leading: Icon(Icons.vertical_align_top_outlined),
|
||||
setKey: SettingBoxKey.hideSearchBar,
|
||||
defaultVal: false,
|
||||
needReboot: true,
|
||||
@@ -91,6 +101,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
const SetSwitchItem(
|
||||
title: '首页底栏收起',
|
||||
subTitle: '首页列表滑动时,收起底栏',
|
||||
leading: Icon(Icons.vertical_align_bottom_outlined),
|
||||
setKey: SettingBoxKey.hideTabBar,
|
||||
defaultVal: false,
|
||||
needReboot: true,
|
||||
@@ -98,6 +109,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
const SetSwitchItem(
|
||||
title: '首页背景渐变',
|
||||
setKey: SettingBoxKey.enableGradientBg,
|
||||
leading: Icon(Icons.gradient_outlined),
|
||||
defaultVal: true,
|
||||
needReboot: true,
|
||||
),
|
||||
@@ -123,11 +135,12 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
leading: const Icon(Icons.calendar_view_week_outlined),
|
||||
dense: false,
|
||||
title: Text('最大列宽(dp)基准', style: titleStyle),
|
||||
title: Text('列表宽度(dp)上限', style: titleStyle),
|
||||
subtitle: Text(
|
||||
'当前:${maxRowWidth.toInt()}dp,屏幕宽度:${MediaQuery.of(context).size.width.toPrecision(2)}dp。'
|
||||
'该值决定列表在不同屏宽下的列数,部分列表会根据系数折算宽度',
|
||||
'当前:${maxRowWidth.toInt()}dp,屏幕宽度:${MediaQuery.of(context).size.width.toPrecision(2)}dp。'
|
||||
'宽度越小列数越多,横条、大卡会2倍折算',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
),
|
||||
@@ -187,6 +200,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
},
|
||||
title: Text('图片质量', style: titleStyle),
|
||||
subtitle: Text('选择合适的图片清晰度,上限100%', style: subTitleStyle),
|
||||
leading: const Icon(Icons.image_outlined),
|
||||
trailing: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Obx(
|
||||
@@ -218,8 +232,9 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
setting.put(SettingBoxKey.defaultToastOp, result);
|
||||
}
|
||||
},
|
||||
title: Text('Toast不透明度', style: titleStyle),
|
||||
subtitle: Text('自定义Toast不透明度', style: subTitleStyle),
|
||||
leading: const Icon(Icons.opacity_outlined),
|
||||
title: Text('气泡提示不透明度', style: titleStyle),
|
||||
subtitle: Text('自定义气泡提示(Toast)不透明度', style: subTitleStyle),
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
@@ -242,6 +257,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
Get.forceAppUpdate();
|
||||
}
|
||||
},
|
||||
leading: const Icon(Icons.flashlight_on_outlined),
|
||||
title: Text('主题模式', style: titleStyle),
|
||||
subtitle: Obx(() => Text(
|
||||
'当前模式:${settingController.themeType.value.description}',
|
||||
@@ -251,6 +267,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
dense: false,
|
||||
onTap: () => settingController.setDynamicBadgeMode(context),
|
||||
title: Text('动态未读标记', style: titleStyle),
|
||||
leading: const Icon(Icons.motion_photos_on_outlined),
|
||||
subtitle: Obx(() => Text(
|
||||
'当前标记样式:${settingController.dynamicBadgeType.value.description}',
|
||||
style: subTitleStyle)),
|
||||
@@ -258,6 +275,7 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
ListTile(
|
||||
dense: false,
|
||||
onTap: () => Get.toNamed('/colorSetting'),
|
||||
leading: const Icon(Icons.color_lens_outlined),
|
||||
title: Text('应用主题', style: titleStyle),
|
||||
subtitle: Obx(() => Text(
|
||||
'当前主题:${colorSelectController.type.value == 0 ? '动态取色' : '指定颜色'}',
|
||||
@@ -266,12 +284,14 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
const SetSwitchItem(
|
||||
title: '默认展示评论区',
|
||||
subTitle: '在视频详情页默认切换至评论区页',
|
||||
leading: Icon(Icons.mode_comment_outlined),
|
||||
setKey: SettingBoxKey.defaultShowComment,
|
||||
defaultVal: false,
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
onTap: () => settingController.seteDefaultHomePage(context),
|
||||
leading: const Icon(Icons.home_outlined),
|
||||
title: Text('默认启动页', style: titleStyle),
|
||||
subtitle: Obx(() => Text(
|
||||
'当前启动页:${defaultNavigationBars.firstWhere((e) => e['id'] == settingController.defaultHomePage.value)['label']}',
|
||||
@@ -281,18 +301,21 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
dense: false,
|
||||
onTap: () => Get.toNamed('/fontSizeSetting'),
|
||||
title: Text('字体大小', style: titleStyle),
|
||||
leading: const Icon(Icons.format_size_outlined),
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
onTap: () => Get.toNamed('/tabbarSetting'),
|
||||
title: Text('首页标签页', style: titleStyle),
|
||||
subtitle: Text('删除或调换首页标签页', style: subTitleStyle),
|
||||
leading: const Icon(Icons.toc_outlined),
|
||||
),
|
||||
if (Platform.isAndroid)
|
||||
ListTile(
|
||||
dense: false,
|
||||
onTap: () => Get.toNamed('/displayModeSetting'),
|
||||
title: Text('屏幕帧率', style: titleStyle),
|
||||
leading: const Icon(Icons.autofps_select_outlined),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
@@ -21,6 +21,8 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
late dynamic defaultAudioQa;
|
||||
late dynamic defaultDecode;
|
||||
late dynamic secondDecode;
|
||||
late dynamic hardwareDecoding;
|
||||
late dynamic videoSync;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -33,6 +35,10 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
defaultValue: VideoDecodeFormats.values.last.code);
|
||||
secondDecode = setting.get(SettingBoxKey.secondDecode,
|
||||
defaultValue: VideoDecodeFormats.values[1].code);
|
||||
hardwareDecoding = setting.get(SettingBoxKey.hardwareDecoding,
|
||||
defaultValue: Platform.isAndroid ? 'auto-safe' : 'auto');
|
||||
videoSync =
|
||||
setting.get(SettingBoxKey.videoSync, defaultValue: 'display-resample');
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -55,31 +61,36 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
children: [
|
||||
const SetSwitchItem(
|
||||
title: '开启硬解',
|
||||
subTitle: '以较低功耗播放视频,若遇异常卡死,请尝试关闭',
|
||||
subTitle: '以较低功耗播放视频,若异常卡死请关闭',
|
||||
leading: Icon(Icons.flash_on_outlined),
|
||||
setKey: SettingBoxKey.enableHA,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '亮度记忆',
|
||||
subTitle: '返回时自动调整视频亮度',
|
||||
leading: Icon(Icons.brightness_6_outlined),
|
||||
setKey: SettingBoxKey.enableAutoBrightness,
|
||||
defaultVal: false,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '免登录1080P',
|
||||
subTitle: '免登录查看1080P视频',
|
||||
leading: Icon(Icons.hd_outlined),
|
||||
setKey: SettingBoxKey.p1080,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: 'CDN优化',
|
||||
subTitle: '使用优质CDN线路',
|
||||
leading: Icon(Icons.network_check_outlined),
|
||||
setKey: SettingBoxKey.enableCDN,
|
||||
defaultVal: true,
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('默认画质', style: titleStyle),
|
||||
leading: const Icon(Icons.video_settings_outlined),
|
||||
subtitle: Text(
|
||||
'当前画质:${VideoQualityCode.fromCode(defaultVideoQa)!.description!}',
|
||||
style: subTitleStyle,
|
||||
@@ -106,6 +117,7 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('默认音质', style: titleStyle),
|
||||
leading: const Icon(Icons.audiotrack_outlined),
|
||||
subtitle: Text(
|
||||
'当前音质:${AudioQualityCode.fromCode(defaultAudioQa)!.description!}',
|
||||
style: subTitleStyle,
|
||||
@@ -132,6 +144,7 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('首选解码格式', style: titleStyle),
|
||||
leading: const Icon(Icons.movie_creation_outlined),
|
||||
subtitle: Text(
|
||||
'首选解码格式:${VideoDecodeFormatsCode.fromCode(defaultDecode)!.description!},请根据设备支持情况与需求调整',
|
||||
style: subTitleStyle,
|
||||
@@ -162,6 +175,7 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
'非杜比视频次选:${VideoDecodeFormatsCode.fromCode(secondDecode)!.description!},仍无则选择首个提供的解码格式',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
leading: const Icon(Icons.swap_horizontal_circle_outlined),
|
||||
onTap: () async {
|
||||
String? result = await showDialog(
|
||||
context: context,
|
||||
@@ -184,16 +198,84 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
if (Platform.isAndroid)
|
||||
const SetSwitchItem(
|
||||
title: '优先使用 OpenSL ES 输出音频',
|
||||
leading: Icon(Icons.speaker_outlined),
|
||||
subTitle: '关闭则优先使用AudioTrack输出音频(此项即mpv的--ao)',
|
||||
setKey: SettingBoxKey.useOpenSLES,
|
||||
defaultVal: true,
|
||||
),
|
||||
const SetSwitchItem(
|
||||
title: '扩大缓冲区',
|
||||
subTitle: '默认缓冲区为视频5MB/直播32MB,开启后为视频32MB/直播64MB,但会延长首次加载时间',
|
||||
leading: Icon(Icons.storage_outlined),
|
||||
subTitle: '默认缓冲区为视频5MB/直播32MB,开启后为32MB/64MB,加载时间变长',
|
||||
setKey: SettingBoxKey.expandBuffer,
|
||||
defaultVal: false,
|
||||
),
|
||||
//video-sync
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('视频同步', style: titleStyle),
|
||||
leading: const Icon(Icons.view_timeline_outlined),
|
||||
subtitle: Text(
|
||||
'当前:$videoSync(此项即mpv的--video-sync)',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
onTap: () async {
|
||||
String? result = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SelectDialog<String>(
|
||||
title: '视频同步',
|
||||
value: videoSync,
|
||||
values: [
|
||||
'audio',
|
||||
'display-resample',
|
||||
'display-resample-vdrop',
|
||||
'display-resample-desync',
|
||||
'display-tempo',
|
||||
'display-vdrop',
|
||||
'display-adrop',
|
||||
'display-desync',
|
||||
'desync'
|
||||
].map((e) {
|
||||
return {'title': e, 'value': e};
|
||||
}).toList());
|
||||
},
|
||||
);
|
||||
if (result != null) {
|
||||
setting.put(SettingBoxKey.videoSync, result);
|
||||
videoSync = result;
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
title: Text('硬解模式', style: titleStyle),
|
||||
leading: const Icon(Icons.memory_outlined),
|
||||
subtitle: Text(
|
||||
'当前:$hardwareDecoding(此项即mpv的--hwdec)',
|
||||
style: subTitleStyle,
|
||||
),
|
||||
onTap: () async {
|
||||
String? result = await showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SelectDialog<String>(
|
||||
title: '硬解模式',
|
||||
value: hardwareDecoding,
|
||||
values: ['auto', 'auto-copy', 'auto-safe', 'no', 'yes']
|
||||
.map((e) {
|
||||
return {'title': e, 'value': e};
|
||||
}).toList());
|
||||
},
|
||||
);
|
||||
if (result != null) {
|
||||
setting.put(SettingBoxKey.hardwareDecoding, result);
|
||||
hardwareDecoding = result;
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -69,7 +69,7 @@ class SettingPage extends StatelessWidget {
|
||||
() => Visibility(
|
||||
visible: settingController.hiddenSettingUnlocked.value,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.developer_mode_outlined),
|
||||
leading: const Icon(Icons.developer_board_outlined),
|
||||
onTap: () => Get.toNamed('/hiddenSetting'),
|
||||
dense: false,
|
||||
title: const Text('开发人员选项'),
|
||||
|
||||
@@ -11,6 +11,7 @@ class SetSwitchItem extends StatefulWidget {
|
||||
final bool? defaultVal;
|
||||
final Function? callFn;
|
||||
final bool? needReboot;
|
||||
final Widget? leading;
|
||||
|
||||
const SetSwitchItem({
|
||||
this.title,
|
||||
@@ -19,6 +20,7 @@ class SetSwitchItem extends StatefulWidget {
|
||||
this.defaultVal,
|
||||
this.callFn,
|
||||
this.needReboot,
|
||||
this.leading,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@@ -66,6 +68,7 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
|
||||
subtitle: widget.subTitle != null
|
||||
? Text(widget.subTitle!, style: subTitleStyle)
|
||||
: null,
|
||||
leading: widget.leading,
|
||||
trailing: Transform.scale(
|
||||
alignment: Alignment.centerRight, // 缩放Switch的大小后保持右侧对齐, 避免右侧空隙过大
|
||||
scale: 0.8,
|
||||
|
||||
@@ -56,6 +56,7 @@ class VideoDetailController extends GetxController
|
||||
RxBool isShowCover = true.obs;
|
||||
// 硬解
|
||||
RxBool enableHA = true.obs;
|
||||
RxString hwdec = 'auto-safe'.obs;
|
||||
|
||||
/// 本地存储
|
||||
Box userInfoCache = GStrorage.userInfo;
|
||||
@@ -117,7 +118,8 @@ class VideoDetailController extends GetxController
|
||||
autoPlay.value =
|
||||
setting.get(SettingBoxKey.autoPlayEnable, defaultValue: true);
|
||||
enableHA.value = setting.get(SettingBoxKey.enableHA, defaultValue: true);
|
||||
|
||||
hwdec.value = setting.get(SettingBoxKey.hardwareDecoding,
|
||||
defaultValue: Platform.isAndroid ? 'auto-safe' : 'auto');
|
||||
if (userInfo == null ||
|
||||
localCache.get(LocalCacheKey.historyPause) == true) {
|
||||
enableHeart = false;
|
||||
@@ -270,6 +272,7 @@ class VideoDetailController extends GetxController
|
||||
),
|
||||
// 硬解
|
||||
enableHA: enableHA.value,
|
||||
hwdec: hwdec.value,
|
||||
seekTo: seekToTime ?? defaultST,
|
||||
duration: duration ?? data.timeLength == null
|
||||
? null
|
||||
@@ -300,109 +303,112 @@ class VideoDetailController extends GetxController
|
||||
'该视频为专属视频,仅提供试看',
|
||||
displayTime: const Duration(seconds: 3),
|
||||
);
|
||||
}
|
||||
if (data.dash == null && data.durl != null) {
|
||||
videoUrl = data.durl!.first.url!;
|
||||
audioUrl = '';
|
||||
defaultST = Duration.zero;
|
||||
firstVideo = VideoItem();
|
||||
// 实际为FLV/MP4格式,但已被淘汰,这里仅做兜底处理
|
||||
firstVideo = VideoItem(
|
||||
id: data.quality!,
|
||||
baseUrl: videoUrl,
|
||||
codecs: 'avc1',
|
||||
quality: VideoQualityCode.fromCode(data.quality!)!
|
||||
);
|
||||
currentDecodeFormats = VideoDecodeFormatsCode.fromString('avc1')!;
|
||||
currentVideoQa = VideoQualityCode.fromCode(data.quality!)!;
|
||||
if (autoPlay.value) {
|
||||
await playerInit();
|
||||
isShowCover.value = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
final List<VideoItem> allVideosList = data.dash!.video!;
|
||||
try {
|
||||
// 当前可播放的最高质量视频
|
||||
int currentHighVideoQa = allVideosList.first.quality!.code;
|
||||
// 预设的画质为null,则当前可用的最高质量
|
||||
cacheVideoQa ??= currentHighVideoQa;
|
||||
int resVideoQa = currentHighVideoQa;
|
||||
if (cacheVideoQa! <= currentHighVideoQa) {
|
||||
// 如果预设的画质低于当前最高
|
||||
final List<int> numbers = data.acceptQuality!
|
||||
.where((e) => e <= currentHighVideoQa)
|
||||
.toList();
|
||||
resVideoQa = Utils.findClosestNumber(cacheVideoQa!, numbers);
|
||||
}
|
||||
currentVideoQa = VideoQualityCode.fromCode(resVideoQa)!;
|
||||
|
||||
/// 取出符合当前画质的videoList
|
||||
final List<VideoItem> videosList =
|
||||
allVideosList.where((e) => e.quality!.code == resVideoQa).toList();
|
||||
|
||||
/// 优先顺序 设置中指定解码格式 -> 当前可选的首个解码格式
|
||||
final List<FormatItem> supportFormats = data.supportFormats!;
|
||||
// 根据画质选编码格式
|
||||
final List supportDecodeFormats =
|
||||
supportFormats.firstWhere((e) => e.quality == resVideoQa).codecs!;
|
||||
// 默认从设置中取AV1
|
||||
currentDecodeFormats = VideoDecodeFormatsCode.fromString(cacheDecode)!;
|
||||
VideoDecodeFormats secondDecodeFormats =
|
||||
VideoDecodeFormatsCode.fromString(cacheSecondDecode)!;
|
||||
try {
|
||||
// 当前视频没有对应格式返回第一个
|
||||
int flag = 0;
|
||||
for (var i in supportDecodeFormats) {
|
||||
if (i.startsWith(currentDecodeFormats.code)) {
|
||||
flag = 1;
|
||||
break;
|
||||
} else if (i.startsWith(secondDecodeFormats.code)) {
|
||||
flag = 2;
|
||||
}
|
||||
}
|
||||
if (flag == 2) {
|
||||
currentDecodeFormats = secondDecodeFormats;
|
||||
} else if (flag == 0) {
|
||||
currentDecodeFormats =
|
||||
VideoDecodeFormatsCode.fromString(supportDecodeFormats.first)!;
|
||||
}
|
||||
} catch (err) {
|
||||
SmartDialog.showToast('DecodeFormats error: $err');
|
||||
}
|
||||
|
||||
/// 取出符合当前解码格式的videoItem
|
||||
try {
|
||||
firstVideo = videosList.firstWhere(
|
||||
(e) => e.codecs!.startsWith(currentDecodeFormats.code));
|
||||
} catch (_) {
|
||||
firstVideo = videosList.first;
|
||||
}
|
||||
videoUrl = enableCDN
|
||||
? VideoUtils.getCdnUrl(firstVideo)
|
||||
: (firstVideo.backupUrl ?? firstVideo.baseUrl!);
|
||||
} catch (err) {
|
||||
SmartDialog.showToast('firstVideo error: $err');
|
||||
if (data.dash == null) {
|
||||
SmartDialog.showToast('视频资源不存在');
|
||||
isShowCover.value = false;
|
||||
return result;
|
||||
}
|
||||
final List<VideoItem> allVideosList = data.dash!.video!;
|
||||
print("allVideosList:${allVideosList}");
|
||||
// 当前可播放的最高质量视频
|
||||
int currentHighVideoQa = allVideosList.first.quality!.code;
|
||||
// 预设的画质为null,则当前可用的最高质量
|
||||
cacheVideoQa ??= currentHighVideoQa;
|
||||
int resVideoQa = currentHighVideoQa;
|
||||
if (cacheVideoQa! <= currentHighVideoQa) {
|
||||
// 如果预设的画质低于当前最高
|
||||
final List<int> numbers =
|
||||
data.acceptQuality!.where((e) => e <= currentHighVideoQa).toList();
|
||||
resVideoQa = Utils.findClosestNumber(cacheVideoQa!, numbers);
|
||||
}
|
||||
currentVideoQa = VideoQualityCode.fromCode(resVideoQa)!;
|
||||
|
||||
/// 取出符合当前画质的videoList
|
||||
final List<VideoItem> videosList =
|
||||
allVideosList.where((e) => e.quality!.code == resVideoQa).toList();
|
||||
|
||||
/// 优先顺序 设置中指定解码格式 -> 当前可选的首个解码格式
|
||||
final List<FormatItem> supportFormats = data.supportFormats!;
|
||||
// 根据画质选编码格式
|
||||
final List supportDecodeFormats = supportFormats
|
||||
.firstWhere((e) => e.quality == resVideoQa,
|
||||
orElse: () => supportFormats.first)
|
||||
.codecs!;
|
||||
// 默认从设置中取AV1
|
||||
currentDecodeFormats = VideoDecodeFormatsCode.fromString(cacheDecode)!;
|
||||
VideoDecodeFormats secondDecodeFormats =
|
||||
VideoDecodeFormatsCode.fromString(cacheSecondDecode)!;
|
||||
// 当前视频没有对应格式返回第一个
|
||||
int flag = 0;
|
||||
for (var i in supportDecodeFormats) {
|
||||
if (i.startsWith(currentDecodeFormats.code)) {
|
||||
flag = 1;
|
||||
break;
|
||||
} else if (i.startsWith(secondDecodeFormats.code)) {
|
||||
flag = 2;
|
||||
}
|
||||
}
|
||||
if (flag == 2) {
|
||||
currentDecodeFormats = secondDecodeFormats;
|
||||
} else if (flag == 0) {
|
||||
currentDecodeFormats =
|
||||
VideoDecodeFormatsCode.fromString(supportDecodeFormats.first)!;
|
||||
}
|
||||
|
||||
/// 取出符合当前解码格式的videoItem
|
||||
firstVideo = videosList.firstWhere(
|
||||
(e) => e.codecs!.startsWith(currentDecodeFormats.code),
|
||||
orElse: () => videosList.first);
|
||||
|
||||
videoUrl = enableCDN
|
||||
? VideoUtils.getCdnUrl(firstVideo)
|
||||
: (firstVideo.backupUrl ?? firstVideo.baseUrl!);
|
||||
|
||||
/// 优先顺序 设置中指定质量 -> 当前可选的最高质量
|
||||
late AudioItem? firstAudio;
|
||||
final List<AudioItem> audiosList = data.dash!.audio!;
|
||||
|
||||
try {
|
||||
if (data.dash!.dolby?.audio?.isNotEmpty == true) {
|
||||
// 杜比
|
||||
audiosList.insert(0, data.dash!.dolby!.audio!.first);
|
||||
}
|
||||
if (data.dash!.dolby?.audio != null && data.dash!.dolby!.audio!.isNotEmpty) {
|
||||
// 杜比
|
||||
audiosList.insert(0, data.dash!.dolby!.audio!.first);
|
||||
}
|
||||
|
||||
if (data.dash!.flac?.audio != null) {
|
||||
// 无损
|
||||
audiosList.insert(0, data.dash!.flac!.audio!);
|
||||
}
|
||||
if (data.dash!.flac?.audio != null) {
|
||||
// 无损
|
||||
audiosList.insert(0, data.dash!.flac!.audio!);
|
||||
}
|
||||
|
||||
if (audiosList.isNotEmpty) {
|
||||
final List<int> numbers = audiosList.map((map) => map.id!).toList();
|
||||
int closestNumber = Utils.findClosestNumber(cacheAudioQa, numbers);
|
||||
if (!numbers.contains(cacheAudioQa) &&
|
||||
numbers.any((e) => e > cacheAudioQa)) {
|
||||
closestNumber = 30280;
|
||||
}
|
||||
firstAudio = audiosList.firstWhere((e) => e.id == closestNumber);
|
||||
} else {
|
||||
firstAudio = AudioItem();
|
||||
if (audiosList.isNotEmpty) {
|
||||
final List<int> numbers = audiosList.map((map) => map.id!).toList();
|
||||
int closestNumber = Utils.findClosestNumber(cacheAudioQa, numbers);
|
||||
if (!numbers.contains(cacheAudioQa) &&
|
||||
numbers.any((e) => e > cacheAudioQa)) {
|
||||
closestNumber = 30280;
|
||||
}
|
||||
} catch (err) {
|
||||
firstAudio = audiosList.isNotEmpty ? audiosList.first : AudioItem();
|
||||
SmartDialog.showToast('firstAudio error: $err');
|
||||
firstAudio = audiosList.firstWhere((e) => e.id == closestNumber,
|
||||
orElse: () => audiosList.first);
|
||||
} else {
|
||||
firstAudio = AudioItem();
|
||||
}
|
||||
|
||||
audioUrl = enableCDN
|
||||
|
||||
@@ -18,7 +18,6 @@ import 'package:PiliPalaX/utils/feed_back.dart';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:PiliPalaX/utils/utils.dart';
|
||||
|
||||
import '../../../../utils/id_utils.dart';
|
||||
import 'widgets/action_item.dart';
|
||||
import 'widgets/action_row_item.dart';
|
||||
import 'widgets/fav_panel.dart';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:PiliPalaX/common/constants.dart';
|
||||
import 'package:PiliPalaX/utils/feed_back.dart';
|
||||
|
||||
class ActionItem extends StatelessWidget {
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:PiliPalaX/models/video_detail_res.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/index.dart';
|
||||
import 'package:PiliPalaX/utils/id_utils.dart';
|
||||
|
||||
class SeasonPanel extends StatefulWidget {
|
||||
const SeasonPanel({
|
||||
|
||||
@@ -109,7 +109,6 @@ class _VideoReplyNewDialogState extends State<VideoReplyNewDialog>
|
||||
@override
|
||||
void didChangeMetrics() {
|
||||
super.didChangeMetrics();
|
||||
final String routePath = Get.currentRoute;
|
||||
if (!mounted) return;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
|
||||
@@ -66,8 +66,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
RxBool isFullScreen = false.obs;
|
||||
late StreamSubscription<bool> fullScreenStatusListener;
|
||||
late final MethodChannel onUserLeaveHintListener;
|
||||
late AnimationController _animationController;
|
||||
late Animation<double> _animation;
|
||||
StreamSubscription<Duration>? _bufferedListener;
|
||||
|
||||
@override
|
||||
@@ -292,29 +290,33 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
if (mounted) {
|
||||
setState(() => {});
|
||||
}
|
||||
super.didPopNext();
|
||||
videoDetailController.isFirstTime = false;
|
||||
final bool autoplay = autoPlayEnable;
|
||||
videoDetailController.playerInit(autoplay: autoplay);
|
||||
await videoDetailController.playerInit(autoplay: autoplay);
|
||||
|
||||
/// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回
|
||||
videoDetailController.autoPlay.value =
|
||||
!videoDetailController.isShowCover.value;
|
||||
videoIntroController.isPaused = false;
|
||||
if (autoplay) {
|
||||
// await Future.delayed(const Duration(milliseconds: 300));
|
||||
if (plPlayerController?.buffered.value == Duration.zero) {
|
||||
_bufferedListener = plPlayerController?.buffered.listen((p0) {
|
||||
if (p0 > Duration.zero) {
|
||||
_bufferedListener!.cancel();
|
||||
plPlayerController?.seekTo(videoDetailController.defaultST);
|
||||
plPlayerController?.play();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
plPlayerController?.seekTo(videoDetailController.defaultST);
|
||||
plPlayerController?.play();
|
||||
}
|
||||
}
|
||||
// if (autoplay) {
|
||||
// // await Future.delayed(const Duration(milliseconds: 300));
|
||||
// print(plPlayerController);
|
||||
// if (plPlayerController?.buffered.value == Duration.zero) {
|
||||
// _bufferedListener = plPlayerController?.buffered.listen((p0) {
|
||||
// print("p0");
|
||||
// print(p0);
|
||||
// if (p0 > Duration.zero) {
|
||||
// _bufferedListener!.cancel();
|
||||
// plPlayerController?.seekTo(videoDetailController.defaultST);
|
||||
// plPlayerController?.play();
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// plPlayerController?.seekTo(videoDetailController.defaultST);
|
||||
// plPlayerController?.play();
|
||||
// }
|
||||
// }
|
||||
Future.delayed(const Duration(milliseconds: 600), () {
|
||||
AutoOrientation.fullAutoMode();
|
||||
});
|
||||
@@ -322,7 +324,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
if (plPlayerController != null) {
|
||||
listenFullScreenStatus();
|
||||
}
|
||||
super.didPopNext();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -409,6 +410,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
child: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
// systemOverlayStyle: const SystemUiOverlayStyle(
|
||||
// statusBarColor: Colors.transparent,
|
||||
// statusBarIconBrightness: Brightness.light),
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
@@ -417,10 +421,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
() {
|
||||
double videoheight = context.width * 9 / 16;
|
||||
final double videowidth = context.width;
|
||||
print(videoDetailController.tabCtr.index);
|
||||
// print(videoDetailController.tabCtr.index);
|
||||
if (enableVerticalExpand &&
|
||||
plPlayerController?.direction.value == 'vertical' &&
|
||||
videoDetailController.tabCtr.index != 1) {
|
||||
plPlayerController?.direction.value == 'vertical') {
|
||||
videoheight = context.width * 5 / 4;
|
||||
}
|
||||
if (MediaQuery.of(context).orientation ==
|
||||
@@ -812,6 +815,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
child: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
// systemOverlayStyle: const SystemUiOverlayStyle(
|
||||
// statusBarColor: Colors.transparent,
|
||||
// statusBarIconBrightness: Brightness.dark),
|
||||
),
|
||||
),
|
||||
body: childWhenDisabledLandscapeInner)
|
||||
|
||||
@@ -20,10 +20,8 @@ import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:PiliPalaX/http/danmaku.dart';
|
||||
import 'package:PiliPalaX/services/shutdown_timer_service.dart';
|
||||
import '../../../../models/video_detail_res.dart';
|
||||
import '../../../../services/service_locator.dart';
|
||||
import '../introduction/index.dart';
|
||||
import 'package:marquee/marquee.dart';
|
||||
import '../../../danmaku/controller.dart';
|
||||
|
||||
class HeaderControl extends StatefulWidget implements PreferredSizeWidget {
|
||||
const HeaderControl({
|
||||
@@ -440,6 +438,10 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
|
||||
/// 选择画质
|
||||
void showSetVideoQa() {
|
||||
if (videoInfo.dash == null) {
|
||||
SmartDialog.showToast('当前视频不支持选择画质');
|
||||
return;
|
||||
}
|
||||
final List<FormatItem> videoFormat = videoInfo.supportFormats!;
|
||||
final VideoQuality currentVideoQa = widget.videoDetailCtr!.currentVideoQa;
|
||||
|
||||
@@ -634,9 +636,13 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
final VideoItem firstVideo = widget.videoDetailCtr!.firstVideo;
|
||||
// 当前视频可用的解码格式
|
||||
final List<FormatItem> videoFormat = videoInfo.supportFormats!;
|
||||
final List list = videoFormat
|
||||
final List? list = videoFormat
|
||||
.firstWhere((FormatItem e) => e.quality == firstVideo.quality!.code)
|
||||
.codecs!;
|
||||
.codecs;
|
||||
if (list == null) {
|
||||
SmartDialog.showToast('当前视频不支持选择解码格式');
|
||||
return;
|
||||
}
|
||||
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
|
||||
@@ -118,7 +118,7 @@ class WebviewController extends GetxController {
|
||||
content = '${content + url}; \n';
|
||||
}
|
||||
try {
|
||||
await SetCookie.onSet();
|
||||
await CookieTool.onSet();
|
||||
final result = await UserHttp.userInfo();
|
||||
if (result['status'] && result['data'].isLogin) {
|
||||
SmartDialog.showToast('登录成功,当前采用「'
|
||||
|
||||
Reference in New Issue
Block a user