mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-24 11:10:15 +08:00
tweaks (#1780)
* opt: sized * fix: self send * feat: ctrl enter to send * opt: checked * opt: download notifier * opt: Future.syncValue * mod: account * mod: loading state * opt: DebounceStreamMixin * opt: report * opt: enum map * opt: file handler * opt: dyn color * opt: Uint8List subview * opt: FileExt * opt: computeLuminance * opt: isNullOrEmpty * opt: Get context * update [skip ci] Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * opt dynamicColor [skip ci] Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * fixes [skip ci] * update Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> * update Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me> --------- Signed-off-by: My-Responsitories <107370289+My-Responsitories@users.noreply.github.com> Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
committed by
GitHub
parent
02e0d34127
commit
ce5e85e64b
@@ -8,7 +8,7 @@ import 'package:hive/hive.dart';
|
||||
sealed class Account {
|
||||
Map<String, dynamic>? toJson() => null;
|
||||
|
||||
Future<void> onChange() => Future.value();
|
||||
Future<void> onChange() => Future.syncValue(null);
|
||||
|
||||
Set<AccountType> get type => const {};
|
||||
|
||||
@@ -74,7 +74,7 @@ class LoginAccount extends Account {
|
||||
@override
|
||||
Future<void> delete() {
|
||||
assert(_hasDelete = true);
|
||||
return _box.delete(_midStr);
|
||||
return Future.wait([cookieJar.deleteAll(), _box.delete(_midStr)]);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -144,10 +144,8 @@ class AnonymousAccount extends Account {
|
||||
bool activated = false;
|
||||
|
||||
@override
|
||||
Future<void> delete() async {
|
||||
await cookieJar.deleteAll();
|
||||
cookieJar.setBuvid3();
|
||||
}
|
||||
Future<void> delete() =>
|
||||
cookieJar.deleteAll().whenComplete(cookieJar.setBuvid3);
|
||||
|
||||
static final _instance = AnonymousAccount._();
|
||||
|
||||
@@ -166,16 +164,15 @@ class AnonymousAccount extends Account {
|
||||
|
||||
extension BiliCookie on Cookie {
|
||||
void setBiliDomain([String domain = '.bilibili.com']) {
|
||||
this
|
||||
..domain = domain
|
||||
..httpOnly = false
|
||||
..path = '/';
|
||||
this.domain = domain;
|
||||
httpOnly = false;
|
||||
path = '/';
|
||||
}
|
||||
}
|
||||
|
||||
extension BiliCookieJar on DefaultCookieJar {
|
||||
Map<String, String> toJson() {
|
||||
final cookies = domainCookies['bilibili.com']?['/'] ?? {};
|
||||
final cookies = domainCookies['bilibili.com']?['/'] ?? const {};
|
||||
return {for (var i in cookies.values) i.cookie.name: i.cookie.value};
|
||||
}
|
||||
|
||||
|
||||
@@ -87,8 +87,7 @@ abstract final class PiliScheme {
|
||||
case 'bilibili':
|
||||
switch (host) {
|
||||
case 'root':
|
||||
Navigator.popUntil(
|
||||
Get.context!,
|
||||
Get.key.currentState!.popUntil(
|
||||
(Route<dynamic> route) => route.isFirst,
|
||||
);
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
extension FileExt on File {
|
||||
extension FileSystemEntityExt on FileSystemEntity {
|
||||
Future<void> tryDel({bool recursive = false}) async {
|
||||
try {
|
||||
await delete(recursive: recursive);
|
||||
@@ -9,12 +9,6 @@ extension FileExt on File {
|
||||
}
|
||||
|
||||
extension DirectoryExt on Directory {
|
||||
Future<void> tryDel({bool recursive = false}) async {
|
||||
try {
|
||||
await delete(recursive: recursive);
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Future<bool> lengthGte(int length) async {
|
||||
int count = 0;
|
||||
await for (var _ in list()) {
|
||||
|
||||
@@ -15,7 +15,10 @@ class JsonFileHandler extends ReportHandler {
|
||||
final bool printLogs;
|
||||
final bool handleWhenRejected;
|
||||
|
||||
static late Future<RandomAccessFile> _future;
|
||||
static Future<RandomAccessFile> _future = LoggerUtils.getLogsPath()
|
||||
.then((file) => file.open(mode: FileMode.writeOnlyAppend))
|
||||
.then((raf) => raf.writeFrom(const []))
|
||||
.then(_flush);
|
||||
|
||||
JsonFileHandler._({
|
||||
this.enableDeviceParameters = true,
|
||||
@@ -35,12 +38,7 @@ class JsonFileHandler extends ReportHandler {
|
||||
bool handleWhenRejected = false,
|
||||
}) async {
|
||||
try {
|
||||
final raf = await (await LoggerUtils.getLogsPath()).open(
|
||||
mode: FileMode.writeOnlyAppend,
|
||||
);
|
||||
await raf.writeFrom(const []);
|
||||
await raf.flush();
|
||||
_future = Future.syncValue(raf);
|
||||
await _future;
|
||||
return JsonFileHandler._(
|
||||
enableDeviceParameters: enableDeviceParameters,
|
||||
enableApplicationParameters: enableApplicationParameters,
|
||||
@@ -55,10 +53,12 @@ class JsonFileHandler extends ReportHandler {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<RandomAccessFile> _flush(RandomAccessFile raf) => raf.flush();
|
||||
|
||||
static Future<RandomAccessFile> add(
|
||||
Future<RandomAccessFile> Function(RandomAccessFile) onValue,
|
||||
) {
|
||||
return _future = _future.then(onValue);
|
||||
return _future = _future.then(onValue).then(_flush);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -47,11 +47,11 @@ abstract final class LoginUtils {
|
||||
|
||||
static Future<void> onLoginMain() async {
|
||||
final account = Accounts.main;
|
||||
GrpcReq.updateHeaders(account.accessKey);
|
||||
setWebCookie(account);
|
||||
RequestUtils.syncHistoryStatus();
|
||||
final result = await UserHttp.userInfo();
|
||||
if (result.isSuccess) {
|
||||
GrpcReq.updateHeaders(account.accessKey);
|
||||
setWebCookie(account);
|
||||
RequestUtils.syncHistoryStatus();
|
||||
final UserInfoData data = result.data;
|
||||
if (data.isLogin == true) {
|
||||
final accountService = Get.find<AccountService>()
|
||||
|
||||
@@ -653,8 +653,8 @@ abstract class PageUtils {
|
||||
Get.generalDialog(
|
||||
barrierLabel: '',
|
||||
barrierDismissible: true,
|
||||
pageBuilder: (buildContext, animation, secondaryAnimation) {
|
||||
if (Get.context!.isPortrait) {
|
||||
pageBuilder: (context, animation, secondaryAnimation) {
|
||||
if (context.isPortrait) {
|
||||
return SafeArea(
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: 0.7,
|
||||
@@ -680,7 +680,7 @@ abstract class PageUtils {
|
||||
},
|
||||
transitionDuration: const Duration(milliseconds: 350),
|
||||
transitionBuilder: (context, animation, secondaryAnimation, child) {
|
||||
Offset begin = Get.context!.isPortrait
|
||||
Offset begin = context.isPortrait
|
||||
? const Offset(0.0, 1.0)
|
||||
: const Offset(1.0, 0.0);
|
||||
var tween = Tween(
|
||||
|
||||
@@ -656,6 +656,7 @@ abstract class Pref {
|
||||
_setting.get(SettingBoxKey.customColor, defaultValue: 0);
|
||||
|
||||
static bool get dynamicColor =>
|
||||
!Platform.isIOS &&
|
||||
_setting.get(SettingBoxKey.dynamicColor, defaultValue: !Platform.isIOS);
|
||||
|
||||
static bool get autoClearCache =>
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/http/ua_type.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/extension/string_ext.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
@@ -131,7 +130,7 @@ abstract class Update {
|
||||
for (Map<String, dynamic> i in data['assets']) {
|
||||
final String name = i['name'];
|
||||
if (name.contains(plat) &&
|
||||
(ext.isNullOrEmpty ? true : name.endsWith(ext!))) {
|
||||
(ext == null || ext.isEmpty ? true : name.endsWith(ext))) {
|
||||
PageUtils.launchURL(i['browser_download_url']);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user