新增模拟未登录推荐,独立推荐设置,新增accesskey风控警告,统一推荐逻辑
This commit is contained in:
@ -46,7 +46,9 @@ class VideoHttp {
|
|||||||
setting.get(SettingBoxKey.blackMidsList, defaultValue: [-1]);
|
setting.get(SettingBoxKey.blackMidsList, defaultValue: [-1]);
|
||||||
for (var i in res.data['data']['item']) {
|
for (var i in res.data['data']['item']) {
|
||||||
//过滤掉live与ad,以及拉黑用户
|
//过滤掉live与ad,以及拉黑用户
|
||||||
if (i['goto'] == 'av' && !blackMidsList.contains(i['owner']['mid'])) {
|
if (i['goto'] == 'av' &&
|
||||||
|
(i['owner'] != null &&
|
||||||
|
!blackMidsList.contains(i['owner']['mid']))) {
|
||||||
list.add(RecVideoItemModel.fromJson(i));
|
list.add(RecVideoItemModel.fromJson(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,7 +61,9 @@ class VideoHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future rcmdVideoListApp({int? ps, required int freshIdx}) async {
|
// 添加额外的loginState变量模拟未登录状态
|
||||||
|
static Future rcmdVideoListApp(
|
||||||
|
{bool loginStatus = true, required int freshIdx}) async {
|
||||||
try {
|
try {
|
||||||
var res = await Request().get(
|
var res = await Request().get(
|
||||||
Api.recommendListApp,
|
Api.recommendListApp,
|
||||||
@ -72,9 +76,11 @@ class VideoHttp {
|
|||||||
'device_name': 'vivo',
|
'device_name': 'vivo',
|
||||||
'pull': freshIdx == 0 ? 'true' : 'false',
|
'pull': freshIdx == 0 ? 'true' : 'false',
|
||||||
'appkey': Constants.appKey,
|
'appkey': Constants.appKey,
|
||||||
'access_key': localCache
|
'access_key': loginStatus
|
||||||
.get(LocalCacheKey.accessKey, defaultValue: {})['value'] ??
|
? (localCache.get(LocalCacheKey.accessKey,
|
||||||
''
|
defaultValue: {})['value'] ??
|
||||||
|
'')
|
||||||
|
: ''
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
@ -92,7 +98,7 @@ class VideoHttp {
|
|||||||
}
|
}
|
||||||
return {'status': true, 'data': list};
|
return {'status': true, 'data': list};
|
||||||
} else {
|
} else {
|
||||||
return {'status': false, 'data': [], 'msg': ''};
|
return {'status': false, 'data': [], 'msg': res.data['message']};
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return {'status': false, 'data': [], 'msg': err.toString()};
|
return {'status': false, 'data': [], 'msg': err.toString()};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// 首页推荐类型
|
// 首页推荐类型
|
||||||
enum RcmdType { web, app }
|
enum RcmdType { web, app, notLogin }
|
||||||
|
|
||||||
extension RcmdTypeExtension on RcmdType {
|
extension RcmdTypeExtension on RcmdType {
|
||||||
String get values => ['web', 'app'][index];
|
String get values => ['web', 'app', 'notLogin'][index];
|
||||||
String get labels => ['web端', 'app端'][index];
|
String get labels => ['web端', 'app端', '模拟未登录'][index];
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ import 'package:pilipala/utils/storage.dart';
|
|||||||
class RcmdController extends GetxController {
|
class RcmdController extends GetxController {
|
||||||
final ScrollController scrollController = ScrollController();
|
final ScrollController scrollController = ScrollController();
|
||||||
int _currentPage = 0;
|
int _currentPage = 0;
|
||||||
RxList<RecVideoItemAppModel> appVideoList = <RecVideoItemAppModel>[].obs;
|
// RxList<RecVideoItemAppModel> appVideoList = <RecVideoItemAppModel>[].obs;
|
||||||
RxList<RecVideoItemModel> webVideoList = <RecVideoItemModel>[].obs;
|
// RxList<RecVideoItemModel> webVideoList = <RecVideoItemModel>[].obs;
|
||||||
bool isLoadingMore = true;
|
bool isLoadingMore = true;
|
||||||
OverlayEntry? popupDialog;
|
OverlayEntry? popupDialog;
|
||||||
Box recVideo = GStrorage.recVideo;
|
Box recVideo = GStrorage.recVideo;
|
||||||
@ -18,6 +18,7 @@ class RcmdController extends GetxController {
|
|||||||
RxInt crossAxisCount = 2.obs;
|
RxInt crossAxisCount = 2.obs;
|
||||||
late bool enableSaveLastData;
|
late bool enableSaveLastData;
|
||||||
late String defaultRcmdType = 'web';
|
late String defaultRcmdType = 'web';
|
||||||
|
late RxList<dynamic> videoList;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -37,85 +38,59 @@ class RcmdController extends GetxController {
|
|||||||
setting.get(SettingBoxKey.enableSaveLastData, defaultValue: false);
|
setting.get(SettingBoxKey.enableSaveLastData, defaultValue: false);
|
||||||
defaultRcmdType =
|
defaultRcmdType =
|
||||||
setting.get(SettingBoxKey.defaultRcmdType, defaultValue: 'web');
|
setting.get(SettingBoxKey.defaultRcmdType, defaultValue: 'web');
|
||||||
|
if (defaultRcmdType == 'web'){
|
||||||
|
videoList = <RecVideoItemModel>[].obs;
|
||||||
|
} else {
|
||||||
|
videoList = <RecVideoItemAppModel>[].obs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取推荐
|
// 获取推荐
|
||||||
Future queryRcmdFeed(type) async {
|
Future queryRcmdFeed(type) async {
|
||||||
print(defaultRcmdType);
|
|
||||||
if (defaultRcmdType == 'app') {
|
|
||||||
return await queryRcmdFeedApp(type);
|
|
||||||
}
|
|
||||||
if (defaultRcmdType == 'web') {
|
|
||||||
return await queryRcmdFeedWeb(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取app端推荐
|
|
||||||
Future queryRcmdFeedApp(type) async {
|
|
||||||
if (isLoadingMore == false) {
|
if (isLoadingMore == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (type == 'onRefresh') {
|
if (type == 'onRefresh') {
|
||||||
_currentPage = 0;
|
_currentPage = 0;
|
||||||
}
|
}
|
||||||
var res = await VideoHttp.rcmdVideoListApp(
|
late final Map<String,dynamic> res;
|
||||||
|
switch (defaultRcmdType) {
|
||||||
|
case 'app': case 'notLogin':
|
||||||
|
res = await VideoHttp.rcmdVideoListApp(
|
||||||
|
loginStatus: defaultRcmdType != 'notLogin',
|
||||||
freshIdx: _currentPage,
|
freshIdx: _currentPage,
|
||||||
);
|
);
|
||||||
if (res['status']) {
|
break;
|
||||||
if (type == 'init') {
|
default: //'web'
|
||||||
if (appVideoList.isNotEmpty) {
|
res = await VideoHttp.rcmdVideoList(
|
||||||
appVideoList.addAll(res['data']);
|
freshIdx: _currentPage,
|
||||||
} else {
|
|
||||||
appVideoList.value = res['data'];
|
|
||||||
}
|
|
||||||
} else if (type == 'onRefresh') {
|
|
||||||
if (enableSaveLastData) {
|
|
||||||
appVideoList.insertAll(0, res['data']);
|
|
||||||
} else {
|
|
||||||
appVideoList.value = res['data'];
|
|
||||||
}
|
|
||||||
} else if (type == 'onLoad') {
|
|
||||||
appVideoList.addAll(res['data']);
|
|
||||||
}
|
|
||||||
recVideo.put('cacheList', res['data']);
|
|
||||||
_currentPage += 1;
|
|
||||||
}
|
|
||||||
isLoadingMore = false;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取web端推荐
|
|
||||||
Future queryRcmdFeedWeb(type) async {
|
|
||||||
if (isLoadingMore == false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (type == 'onRefresh') {
|
|
||||||
_currentPage = 0;
|
|
||||||
}
|
|
||||||
var res = await VideoHttp.rcmdVideoList(
|
|
||||||
ps: 20,
|
ps: 20,
|
||||||
freshIdx: _currentPage,
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
if (res['status']) {
|
if (res['status']) {
|
||||||
if (type == 'init') {
|
if (type == 'init') {
|
||||||
if (webVideoList.isNotEmpty) {
|
if (videoList.isNotEmpty) {
|
||||||
webVideoList.addAll(res['data']);
|
videoList.addAll(res['data']);
|
||||||
} else {
|
} else {
|
||||||
webVideoList.value = res['data'];
|
videoList.value = res['data'];
|
||||||
}
|
}
|
||||||
} else if (type == 'onRefresh') {
|
} else if (type == 'onRefresh') {
|
||||||
if (enableSaveLastData) {
|
if (enableSaveLastData) {
|
||||||
webVideoList.insertAll(0, res['data']);
|
videoList.insertAll(0, res['data']);
|
||||||
} else {
|
} else {
|
||||||
webVideoList.value = res['data'];
|
videoList.value = res['data'];
|
||||||
}
|
}
|
||||||
} else if (type == 'onLoad') {
|
} else if (type == 'onLoad') {
|
||||||
webVideoList.addAll(res['data']);
|
videoList.addAll(res['data']);
|
||||||
|
}
|
||||||
|
if (defaultRcmdType != 'web') {
|
||||||
|
recVideo.put('cacheList', res['data']);
|
||||||
}
|
}
|
||||||
_currentPage += 1;
|
_currentPage += 1;
|
||||||
|
} else {
|
||||||
|
Get.snackbar('提示', res['msg']);
|
||||||
}
|
}
|
||||||
isLoadingMore = false;
|
isLoadingMore = false;
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下拉刷新
|
// 下拉刷新
|
||||||
@ -129,7 +104,7 @@ class RcmdController extends GetxController {
|
|||||||
queryRcmdFeed('onLoad');
|
queryRcmdFeed('onLoad');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回顶部并刷新
|
// 返回顶部
|
||||||
void animateToTop() async {
|
void animateToTop() async {
|
||||||
if (scrollController.offset >=
|
if (scrollController.offset >=
|
||||||
MediaQuery.of(Get.context!).size.height * 5) {
|
MediaQuery.of(Get.context!).size.height * 5) {
|
||||||
|
@ -91,54 +91,18 @@ class _RcmdPageState extends State<RcmdPage>
|
|||||||
SliverPadding(
|
SliverPadding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.fromLTRB(0, StyleString.safeSpace, 0, 0),
|
const EdgeInsets.fromLTRB(0, StyleString.safeSpace, 0, 0),
|
||||||
sliver: FutureBuilder(
|
sliver: Obx(() {
|
||||||
future: _futureBuilderFuture,
|
// 使用Obx来监听数据的变化
|
||||||
builder: (context, snapshot) {
|
if (_rcmdController.isLoadingMore) {
|
||||||
if (snapshot.connectionState == ConnectionState.done) {
|
// 如果正在加载,则显示骨架屏
|
||||||
Map data = snapshot.data as Map;
|
|
||||||
if (data['status']) {
|
|
||||||
return Platform.isAndroid || Platform.isIOS
|
|
||||||
? Obx(
|
|
||||||
() => contentGrid(
|
|
||||||
_rcmdController,
|
|
||||||
_rcmdController.defaultRcmdType == 'web'
|
|
||||||
? _rcmdController.webVideoList
|
|
||||||
: _rcmdController.appVideoList),
|
|
||||||
)
|
|
||||||
: SliverLayoutBuilder(
|
|
||||||
builder: (context, boxConstraints) {
|
|
||||||
return Obx(
|
|
||||||
() => contentGrid(
|
|
||||||
_rcmdController,
|
|
||||||
_rcmdController.defaultRcmdType == 'web'
|
|
||||||
? _rcmdController.webVideoList
|
|
||||||
: _rcmdController.appVideoList),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return HttpError(
|
|
||||||
errMsg: data['msg'],
|
|
||||||
fn: () {
|
|
||||||
setState(() {
|
|
||||||
_futureBuilderFuture =
|
|
||||||
_rcmdController.queryRcmdFeed('init');
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 缓存数据
|
|
||||||
// if (_rcmdController.videoList.isNotEmpty) {
|
|
||||||
// return contentGrid(
|
|
||||||
// _rcmdController, _rcmdController.videoList);
|
|
||||||
// }
|
|
||||||
// // 骨架屏
|
|
||||||
// else {
|
|
||||||
return contentGrid(_rcmdController, []);
|
return contentGrid(_rcmdController, []);
|
||||||
// }
|
} else {
|
||||||
|
// 显示视频列表
|
||||||
|
return contentGrid(
|
||||||
|
_rcmdController,
|
||||||
|
_rcmdController.videoList);
|
||||||
}
|
}
|
||||||
},
|
}),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
LoadingMore(ctr: _rcmdController)
|
LoadingMore(ctr: _rcmdController)
|
||||||
],
|
],
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:pilipala/http/member.dart';
|
|
||||||
import 'package:pilipala/models/common/dynamics_type.dart';
|
import 'package:pilipala/models/common/dynamics_type.dart';
|
||||||
import 'package:pilipala/models/common/rcmd_type.dart';
|
|
||||||
import 'package:pilipala/models/common/reply_sort_type.dart';
|
import 'package:pilipala/models/common/reply_sort_type.dart';
|
||||||
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
||||||
import 'package:pilipala/utils/storage.dart';
|
import 'package:pilipala/utils/storage.dart';
|
||||||
@ -20,23 +18,16 @@ class ExtraSetting extends StatefulWidget {
|
|||||||
class _ExtraSettingState extends State<ExtraSetting> {
|
class _ExtraSettingState extends State<ExtraSetting> {
|
||||||
Box setting = GStrorage.setting;
|
Box setting = GStrorage.setting;
|
||||||
static Box localCache = GStrorage.localCache;
|
static Box localCache = GStrorage.localCache;
|
||||||
late dynamic defaultRcmdType;
|
|
||||||
late dynamic defaultReplySort;
|
late dynamic defaultReplySort;
|
||||||
late dynamic defaultDynamicType;
|
late dynamic defaultDynamicType;
|
||||||
late dynamic enableSystemProxy;
|
late dynamic enableSystemProxy;
|
||||||
late String defaultSystemProxyHost;
|
late String defaultSystemProxyHost;
|
||||||
late String defaultSystemProxyPort;
|
late String defaultSystemProxyPort;
|
||||||
Box userInfoCache = GStrorage.userInfo;
|
|
||||||
var userInfo;
|
|
||||||
bool userLogin = false;
|
bool userLogin = false;
|
||||||
var accessKeyInfo;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
// 首页默认推荐类型
|
|
||||||
defaultRcmdType =
|
|
||||||
setting.get(SettingBoxKey.defaultRcmdType, defaultValue: 'web');
|
|
||||||
// 默认优先显示最新评论
|
// 默认优先显示最新评论
|
||||||
defaultReplySort =
|
defaultReplySort =
|
||||||
setting.get(SettingBoxKey.replySortType, defaultValue: 0);
|
setting.get(SettingBoxKey.replySortType, defaultValue: 0);
|
||||||
@ -49,9 +40,6 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
localCache.get(LocalCacheKey.systemProxyHost, defaultValue: '');
|
localCache.get(LocalCacheKey.systemProxyHost, defaultValue: '');
|
||||||
defaultSystemProxyPort =
|
defaultSystemProxyPort =
|
||||||
localCache.get(LocalCacheKey.systemProxyPort, defaultValue: '');
|
localCache.get(LocalCacheKey.systemProxyPort, defaultValue: '');
|
||||||
userInfo = userInfoCache.get('userInfoCache');
|
|
||||||
userLogin = userInfo != null;
|
|
||||||
accessKeyInfo = localCache.get(LocalCacheKey.accessKey, defaultValue: null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置代理
|
// 设置代理
|
||||||
@ -159,12 +147,6 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
setKey: SettingBoxKey.enableSearchWord,
|
setKey: SettingBoxKey.enableSearchWord,
|
||||||
defaultVal: true,
|
defaultVal: true,
|
||||||
),
|
),
|
||||||
const SetSwitchItem(
|
|
||||||
title: '推荐动态',
|
|
||||||
subTitle: '是否在推荐内容中展示动态',
|
|
||||||
setKey: SettingBoxKey.enableRcmdDynamic,
|
|
||||||
defaultVal: true,
|
|
||||||
),
|
|
||||||
const SetSwitchItem(
|
const SetSwitchItem(
|
||||||
title: '快速收藏',
|
title: '快速收藏',
|
||||||
subTitle: '点按收藏至默认,长按选择文件夹',
|
subTitle: '点按收藏至默认,长按选择文件夹',
|
||||||
@ -177,50 +159,6 @@ class _ExtraSettingState extends State<ExtraSetting> {
|
|||||||
setKey: SettingBoxKey.enableWordRe,
|
setKey: SettingBoxKey.enableWordRe,
|
||||||
defaultVal: false,
|
defaultVal: false,
|
||||||
),
|
),
|
||||||
const SetSwitchItem(
|
|
||||||
title: '首页推荐刷新',
|
|
||||||
subTitle: '下拉刷新时保留上次内容',
|
|
||||||
setKey: SettingBoxKey.enableSaveLastData,
|
|
||||||
defaultVal: false,
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
dense: false,
|
|
||||||
title: Text('首页推荐类型', style: titleStyle),
|
|
||||||
subtitle: Text(
|
|
||||||
'当前使用「$defaultRcmdType端」推荐',
|
|
||||||
style: subTitleStyle,
|
|
||||||
),
|
|
||||||
onTap: () async {
|
|
||||||
String? result = await showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return SelectDialog<String>(
|
|
||||||
title: '推荐类型',
|
|
||||||
value: defaultRcmdType,
|
|
||||||
values: RcmdType.values.map((e) {
|
|
||||||
return {'title': e.labels, 'value': e.values};
|
|
||||||
}).toList(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
if (result != null) {
|
|
||||||
if (result == 'app') {
|
|
||||||
// app端推荐需要access_key
|
|
||||||
if (accessKeyInfo == null) {
|
|
||||||
if (!userLogin) {
|
|
||||||
SmartDialog.showToast('请先登录');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await MemberHttp.cookieToKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
defaultRcmdType = result;
|
|
||||||
setting.put(SettingBoxKey.defaultRcmdType, result);
|
|
||||||
SmartDialog.showToast('下次启动时生效');
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SetSwitchItem(
|
const SetSwitchItem(
|
||||||
title: '启用ai总结',
|
title: '启用ai总结',
|
||||||
subTitle: '视频详情页开启ai总结',
|
subTitle: '视频详情页开启ai总结',
|
||||||
|
137
lib/pages/setting/recommend_setting.dart
Normal file
137
lib/pages/setting/recommend_setting.dart
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:pilipala/http/member.dart';
|
||||||
|
import 'package:pilipala/models/common/rcmd_type.dart';
|
||||||
|
import 'package:pilipala/pages/setting/widgets/select_dialog.dart';
|
||||||
|
import 'package:pilipala/utils/storage.dart';
|
||||||
|
|
||||||
|
import 'widgets/switch_item.dart';
|
||||||
|
|
||||||
|
class RecommendSetting extends StatefulWidget {
|
||||||
|
const RecommendSetting({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<RecommendSetting> createState() => _RecommendSettingState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _RecommendSettingState extends State<RecommendSetting> {
|
||||||
|
Box setting = GStrorage.setting;
|
||||||
|
static Box localCache = GStrorage.localCache;
|
||||||
|
late dynamic defaultRcmdType;
|
||||||
|
Box userInfoCache = GStrorage.userInfo;
|
||||||
|
late dynamic userInfo;
|
||||||
|
bool userLogin = false;
|
||||||
|
late dynamic accessKeyInfo;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
// 首页默认推荐类型
|
||||||
|
defaultRcmdType =
|
||||||
|
setting.get(SettingBoxKey.defaultRcmdType, defaultValue: 'web');
|
||||||
|
userInfo = userInfoCache.get('userInfoCache');
|
||||||
|
userLogin = userInfo != null;
|
||||||
|
accessKeyInfo = localCache.get(LocalCacheKey.accessKey, defaultValue: null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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,
|
||||||
|
titleSpacing: 0,
|
||||||
|
title: Text(
|
||||||
|
'推荐设置',
|
||||||
|
style: Theme.of(context).textTheme.titleMedium,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
children: [
|
||||||
|
const SetSwitchItem(
|
||||||
|
title: '推荐动态',
|
||||||
|
subTitle: '是否在推荐内容中展示动态',
|
||||||
|
setKey: SettingBoxKey.enableRcmdDynamic,
|
||||||
|
defaultVal: true,
|
||||||
|
),
|
||||||
|
const SetSwitchItem(
|
||||||
|
title: '首页推荐刷新',
|
||||||
|
subTitle: '下拉刷新时保留上次内容',
|
||||||
|
setKey: SettingBoxKey.enableSaveLastData,
|
||||||
|
defaultVal: false,
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
dense: false,
|
||||||
|
title: Text('首页推荐类型', style: titleStyle),
|
||||||
|
subtitle: Text(
|
||||||
|
'当前使用「$defaultRcmdType端」推荐',
|
||||||
|
style: subTitleStyle,
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
String? result = await showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return SelectDialog<String>(
|
||||||
|
title: '推荐类型',
|
||||||
|
value: defaultRcmdType,
|
||||||
|
values: RcmdType.values.map((e) {
|
||||||
|
return {'title': e.labels, 'value': e.values};
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (result != null) {
|
||||||
|
if (result == 'app') {
|
||||||
|
// app端推荐需要access_key
|
||||||
|
if (accessKeyInfo == null) {
|
||||||
|
if (!userLogin) {
|
||||||
|
SmartDialog.showToast('请先登录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 显示一个确认框,告知用户可能会导致账号被风控
|
||||||
|
SmartDialog.show(
|
||||||
|
animationType: SmartAnimationType.centerFade_otherSlide,
|
||||||
|
builder: (context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text('提示'),
|
||||||
|
content: const Text(
|
||||||
|
'使用app端推荐需获取access_key,有小概率触发风控导致账号退出(在官方app重新登录即可解除),是否继续?'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
result = null;
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
},
|
||||||
|
child: const Text('取消'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
SmartDialog.dismiss();
|
||||||
|
await MemberHttp.cookieToKey();
|
||||||
|
},
|
||||||
|
child: const Text('确定'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result != null) {
|
||||||
|
defaultRcmdType = result;
|
||||||
|
setting.put(SettingBoxKey.defaultRcmdType, result);
|
||||||
|
SmartDialog.showToast('下次启动时生效');
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -24,6 +24,11 @@ class SettingPage extends StatelessWidget {
|
|||||||
dense: false,
|
dense: false,
|
||||||
title: const Text('隐私设置'),
|
title: const Text('隐私设置'),
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
onTap: () => Get.toNamed('/recommendSetting'),
|
||||||
|
dense: false,
|
||||||
|
title: const Text('推荐设置'),
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
onTap: () => Get.toNamed('/playSetting'),
|
onTap: () => Get.toNamed('/playSetting'),
|
||||||
dense: false,
|
dense: false,
|
||||||
|
@ -37,6 +37,7 @@ import '../pages/setting/pages/color_select.dart';
|
|||||||
import '../pages/setting/pages/display_mode.dart';
|
import '../pages/setting/pages/display_mode.dart';
|
||||||
import '../pages/setting/pages/font_size_select.dart';
|
import '../pages/setting/pages/font_size_select.dart';
|
||||||
import '../pages/setting/pages/play_speed_set.dart';
|
import '../pages/setting/pages/play_speed_set.dart';
|
||||||
|
import '../pages/setting/recommend_setting.dart';
|
||||||
import '../pages/setting/play_setting.dart';
|
import '../pages/setting/play_setting.dart';
|
||||||
import '../pages/setting/privacy_setting.dart';
|
import '../pages/setting/privacy_setting.dart';
|
||||||
import '../pages/setting/style_setting.dart';
|
import '../pages/setting/style_setting.dart';
|
||||||
@ -100,7 +101,8 @@ class Routes {
|
|||||||
// 二级回复
|
// 二级回复
|
||||||
CustomGetPage(
|
CustomGetPage(
|
||||||
name: '/replyReply', page: () => const VideoReplyReplyPanel()),
|
name: '/replyReply', page: () => const VideoReplyReplyPanel()),
|
||||||
|
// 推荐设置
|
||||||
|
CustomGetPage(name: '/recommendSetting', page: () => const RecommendSetting()),
|
||||||
// 播放设置
|
// 播放设置
|
||||||
CustomGetPage(name: '/playSetting', page: () => const PlaySetting()),
|
CustomGetPage(name: '/playSetting', page: () => const PlaySetting()),
|
||||||
// 外观设置
|
// 外观设置
|
||||||
|
@ -120,17 +120,19 @@ class SettingBoxKey {
|
|||||||
/// 隐私
|
/// 隐私
|
||||||
blackMidsList = 'blackMidsList',
|
blackMidsList = 'blackMidsList',
|
||||||
|
|
||||||
|
/// 推荐
|
||||||
|
enableRcmdDynamic = 'enableRcmdDynamic',
|
||||||
|
defaultRcmdType = 'defaultRcmdType',
|
||||||
|
enableSaveLastData = 'enableSaveLastData',
|
||||||
|
|
||||||
/// 其他
|
/// 其他
|
||||||
autoUpdate = 'autoUpdate',
|
autoUpdate = 'autoUpdate',
|
||||||
defaultRcmdType = 'defaultRcmdType',
|
|
||||||
replySortType = 'replySortType',
|
replySortType = 'replySortType',
|
||||||
defaultDynamicType = 'defaultDynamicType',
|
defaultDynamicType = 'defaultDynamicType',
|
||||||
enableHotKey = 'enableHotKey',
|
enableHotKey = 'enableHotKey',
|
||||||
enableQuickFav = 'enableQuickFav',
|
enableQuickFav = 'enableQuickFav',
|
||||||
enableWordRe = 'enableWordRe',
|
enableWordRe = 'enableWordRe',
|
||||||
enableSearchWord = 'enableSearchWord',
|
enableSearchWord = 'enableSearchWord',
|
||||||
enableRcmdDynamic = 'enableRcmdDynamic',
|
|
||||||
enableSaveLastData = 'enableSaveLastData',
|
|
||||||
enableSystemProxy = 'enableSystemProxy',
|
enableSystemProxy = 'enableSystemProxy',
|
||||||
enableAi = 'enableAi';
|
enableAi = 'enableAi';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user