* opt: marquee

* fix: bangumi seek

* opt: post panel

* opt: remove deprecated code

* opt: singleton dynController

* fix: music scheme

* feat: MemberVideo jump keep position

* tweak
This commit is contained in:
My-Responsitories
2025-09-04 20:29:02 +08:00
committed by GitHub
parent e8a674ca2a
commit 172389b12b
51 changed files with 1314 additions and 1227 deletions

View File

@@ -242,12 +242,12 @@ class PiliScheme {
case 'comment':
if (path.startsWith("/detail/")) {
// bilibili://comment/detail/17/832703053858603029/238686570016/?subType=0&anchor=238686628816&showEnter=1&extraIntentId=0&scene=1&enterName=%E6%9F%A5%E7%9C%8B%E5%8A%A8%E6%80%81%E8%AF%A6%E6%83%85&enterUri=bilibili://following/detail/832703053858603029
List<String> pathSegments = uri.pathSegments;
Map<String, String> queryParameters = uri.queryParameters;
int type = int.parse(pathSegments[1]); // business_id
int oid = int.parse(pathSegments[2]); // subject_id
int rootId = int.parse(pathSegments[3]); // root_id // target_id
int? rpId =
final pathSegments = uri.pathSegments;
final queryParameters = uri.queryParameters;
final type = int.parse(pathSegments[1]); // business_id
final oid = int.parse(pathSegments[2]); // subject_id
final rootId = int.parse(pathSegments[3]); // root_id // target_id
final rpId =
queryParameters['anchor'] !=
null // source_id
? int.tryParse(queryParameters['anchor']!)
@@ -255,34 +255,39 @@ class PiliScheme {
// int subType = int.parse(queryParameters['subType'] ?? '0');
// int extraIntentId =
// int.parse(queryParameters['extraIntentId'] ?? '0');
final enterUri = queryParameters['enterUri'];
Get.to(
arguments: {
'oid': oid,
'rpid': rootId,
'id': rpId,
'type': type,
'enterUri': queryParameters['enterUri'],
'enterUri': enterUri,
},
() => Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: const Text('评论详情'),
actions: [
IconButton(
tooltip: '前往',
onPressed: () {
String? enterUri = queryParameters['enterUri'];
if (enterUri != null) {
routePush(Uri.parse(enterUri));
} else {
routePush(
Uri.parse('bilibili://following/detail/$oid'),
);
}
},
icon: const Icon(Icons.open_in_new),
),
],
actions:
enterUri != null || const [11, 16, 17].contains(type)
? [
IconButton(
tooltip: '前往',
onPressed: () {
if (enterUri != null) {
routePush(Uri.parse(enterUri));
} else {
routePush(
Uri.parse(
'bilibili://following/detail/$oid',
),
);
}
},
icon: const Icon(Icons.open_in_new),
),
]
: null,
),
body: ViewSafeArea(
child: VideoReplyReplyPanel(
@@ -729,9 +734,12 @@ class PiliScheme {
case 'bangumi':
// www.bilibili.com/bangumi/play/ep{eid}?start_progress={offset}&thumb_up_dm_id={dmid}
// if (kDebugMode) debugPrint('番剧');
final queryParameters = uri.queryParameters;
bool hasMatch = PageUtils.viewPgcFromUri(
path,
progress: uri.queryParameters['start_progress'],
progress:
queryParameters['start_progress'] ??
queryParameters['dm_progress'],
);
if (hasMatch) {
return true;

View File

@@ -2,17 +2,12 @@ import 'dart:async';
import 'dart:io';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:path_provider/path_provider.dart';
class CacheManage {
CacheManage._internal();
static final CacheManage cacheManage = CacheManage._internal();
factory CacheManage() => cacheManage;
abstract class CacheManage {
// 获取缓存目录
Future<double> loadApplicationCache() async {
static Future<double> loadApplicationCache() async {
/// clear all of image in memory
// clearMemoryImageCache();
/// get ImageCache
@@ -47,7 +42,9 @@ class CacheManage {
}
// 循环计算文件的大小(递归)
Future<double> getTotalSizeOfFilesInDir(final FileSystemEntity file) async {
static Future<double> getTotalSizeOfFilesInDir(
final FileSystemEntity file,
) async {
if (file is File) {
int length = await file.length();
return double.parse(length.toString());
@@ -76,7 +73,7 @@ class CacheManage {
}
/// 清除 Documents 目录下的 DioCache.db
Future<void> clearApplicationCache() async {
static Future<void> clearApplicationCache() async {
Directory directory = await getApplicationDocumentsDirectory();
if (directory.existsSync()) {
String dioCacheFileName =
@@ -103,7 +100,7 @@ class CacheManage {
}
/// 递归方式删除目录及文件
Future<void> deleteDirectory(FileSystemEntity file) async {
static Future<void> deleteDirectory(FileSystemEntity file) async {
if (file is Directory) {
final List<FileSystemEntity> children = file.listSync();
for (final FileSystemEntity child in children) {
@@ -112,4 +109,18 @@ class CacheManage {
}
await file.delete();
}
static Future<void> autoClearCache() async {
if (Pref.autoClearCache) {
await CacheManage.clearLibraryCache();
} else {
final maxCacheSize = Pref.maxCacheSize;
if (maxCacheSize != 0) {
final currCache = await loadApplicationCache();
if (currCache >= maxCacheSize) {
await CacheManage.clearLibraryCache();
}
}
}
}
}

View File

@@ -52,7 +52,7 @@ extension ContextExtensions on BuildContext {
double get devicePixelRatio => MediaQuery.devicePixelRatioOf(this);
/// similar to [MediaQuery.of(this).textScaleFactor]
double get textScaleFactor => MediaQuery.textScaleFactorOf(this);
TextScaler get textScaler => MediaQuery.textScalerOf(this);
/// get the shortestSide from screen
double get mediaQueryShortestSide => mediaQuerySize.shortestSide;

View File

@@ -223,3 +223,8 @@ extension FileExt on File {
extension SizeExt on Size {
bool get isPortrait => width < 600 || height >= width;
}
extension GetExt on GetInterface {
S putOrFind<S>(InstanceBuilderCallback<S> dep, {String? tag}) =>
GetInstance().putOrFind(dep, tag: tag);
}

View File

@@ -292,14 +292,14 @@ class PageUtils {
static Future<void> pushDynFromId({id, rid, bool off = false}) async {
SmartDialog.showLoading();
var res = await DynamicsHttp.dynamicDetail(
final res = await DynamicsHttp.dynamicDetail(
id: id,
rid: rid,
type: rid != null ? 2 : null,
);
SmartDialog.dismiss();
if (res['status']) {
DynamicItemModel data = res['data'];
if (res.isSuccess) {
final data = res.data;
if (data.basic?.commentType == 12) {
toDupNamed(
'/articlePage',
@@ -313,13 +313,13 @@ class PageUtils {
toDupNamed(
'/dynamicDetail',
arguments: {
'item': res['data'],
'item': data,
},
off: off,
);
}
} else {
SmartDialog.showToast(res['msg']);
res.toast();
}
}

View File

@@ -3,7 +3,6 @@ import 'dart:convert';
import 'dart:io';
import 'dart:math';
import 'package:PiliPlus/common/widgets/radio_widget.dart';
import 'package:PiliPlus/grpc/bilibili/im/type.pbenum.dart';
import 'package:PiliPlus/grpc/bilibili/main/community/reply/v1.pb.dart'
show ReplyInfo;
@@ -288,17 +287,17 @@ class RequestUtils {
if (id != null) {
await Future.delayed(const Duration(milliseconds: 200));
var res = await DynamicsHttp.dynamicDetail(id: id);
if (res['status']) {
if (res.isSuccess) {
final ctr = Get.find<DynamicsTabController>(tag: 'all');
if (ctr.loadingState.value.isSuccess) {
List<DynamicItemModel>? list = ctr.loadingState.value.data;
if (list != null) {
list.insert(0, res['data']);
list.insert(0, res.data);
ctr.loadingState.refresh();
return;
}
}
ctr.loadingState.value = Success([res['data']]);
ctr.loadingState.value = Success([res.data]);
}
}
} catch (e) {
@@ -318,7 +317,7 @@ class RequestUtils {
await Future.delayed(const Duration(seconds: 5));
}
var res = await DynamicsHttp.dynamicDetail(id: id, clearCookie: true);
bool isBan = !res['status'];
bool isBan = !res.isSuccess;
Get.dialog(
AlertDialog(
title: const Text('动态检查结果'),
@@ -400,23 +399,20 @@ class RequestUtils {
title: Text('${isCopy ? '复制' : '移动'}'),
contentPadding: const EdgeInsets.only(top: 5),
content: SingleChildScrollView(
child: Builder(
builder: (context) => Column(
children: List.generate(list.length, (index) {
final item = list[index];
return RadioWidget<int>(
padding: const EdgeInsets.only(left: 14),
title: item.title,
groupValue: checkedId,
child: RadioGroup(
onChanged: (value) {
checkedId = value;
(context as Element).markNeedsBuild();
},
groupValue: checkedId,
child: Column(
children: list.map((item) {
return RadioListTile<int>(
dense: true,
title: Text(item.title),
value: item.id,
onChanged: (value) {
checkedId = value;
if (context.mounted) {
(context as Element).markNeedsBuild();
}
},
);
}),
}).toList(),
),
),
),

View File

@@ -12,7 +12,7 @@ import 'package:PiliPlus/utils/set_int_adapter.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:path_provider/path_provider.dart';
class GStorage {
abstract class GStorage {
static late final Box<UserInfoData> userInfo;
static late final Box<dynamic> historyWord;
static late final Box<dynamic> localCache;

View File

@@ -33,7 +33,7 @@ import 'package:get/get.dart' hide ContextExtensionss;
import 'package:hive/hive.dart';
import 'package:uuid/uuid.dart';
class Pref {
abstract class Pref {
static final Box _setting = GStorage.setting;
static final Box _video = GStorage.video;
static final Box _localCache = GStorage.localCache;