mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-16 15:16:15 +08:00
feat: 调整设置,支持导入导出,代码优化
This commit is contained in:
@@ -2,7 +2,6 @@ import 'package:appscheme/appscheme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../http/dynamics.dart';
|
||||
import '../http/search.dart';
|
||||
import '../models/common/search_type.dart';
|
||||
import 'id_utils.dart';
|
||||
|
||||
@@ -1,8 +1,35 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:PiliPalaX/http/constants.dart';
|
||||
import 'package:PiliPalaX/http/init.dart';
|
||||
import 'package:webview_cookie_manager/webview_cookie_manager.dart';
|
||||
|
||||
class SetCookie {
|
||||
class CookieTool {
|
||||
static exportCookie() async {
|
||||
Map<String, String> allCookies = {};
|
||||
List<String> Urls = [HttpString.baseUrl, HttpString.apiBaseUrl, HttpString.tUrl];
|
||||
for (var url in Urls) {
|
||||
allCookies[url] = await WebviewCookieManager().getCookies(url)
|
||||
.then((cookies) => cookies.map((cookie) => '${cookie.name}=${cookie.value}').join('; '));
|
||||
}
|
||||
return jsonEncode(allCookies);
|
||||
}
|
||||
static importCookie(String cookie) async {
|
||||
var allCookies = jsonDecode(cookie);
|
||||
for (var url in allCookies.keys) {
|
||||
List<String> cookiesStringList = allCookies[url]!.split('; ');
|
||||
List<Cookie> cookies = [];
|
||||
for (var c in cookiesStringList) {
|
||||
List<String> kv = c.split('=');
|
||||
cookies.add(Cookie(kv[0], kv[1]));
|
||||
}
|
||||
await Request.cookieManager.cookieJar.saveFromResponse(Uri.parse(url), cookies);
|
||||
if (url == HttpString.baseUrl) {
|
||||
Request.dio.options.headers['cookie'] = allCookies[url];
|
||||
}
|
||||
}
|
||||
}
|
||||
static onSet() async {
|
||||
var cookies = await WebviewCookieManager().getCookies(HttpString.baseUrl);
|
||||
await Request.cookieManager.cookieJar
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
@@ -47,6 +48,21 @@ class GStrorage {
|
||||
setting.get(SettingBoxKey.defaultPicQa, defaultValue: 10); // 设置全局变量
|
||||
}
|
||||
|
||||
static Future<String> exportAllSettings() async {
|
||||
return jsonEncode({
|
||||
setting.name: setting.toMap(),
|
||||
video.name: video.toMap(),
|
||||
});
|
||||
}
|
||||
|
||||
static Future<void> importAllSettings(String data) async {
|
||||
final Map<String, dynamic> map = jsonDecode(data);
|
||||
await setting.clear();
|
||||
await video.clear();
|
||||
await setting.putAll(map[setting.name]);
|
||||
await video.putAll(map[video.name]);
|
||||
}
|
||||
|
||||
static void regAdapter() {
|
||||
Hive.registerAdapter(OwnerAdapter());
|
||||
Hive.registerAdapter(UserInfoDataAdapter());
|
||||
@@ -89,6 +105,8 @@ class SettingBoxKey {
|
||||
enableHA = 'enableHA',
|
||||
useOpenSLES = 'useOpenSLES',
|
||||
expandBuffer = 'expandBuffer',
|
||||
hardwareDecoding = 'hardwareDecoding',
|
||||
videoSync = 'videoSync',
|
||||
enableVerticalExpand = 'enableVerticalExpand',
|
||||
enableOnlineTotal = 'enableOnlineTotal',
|
||||
enableAutoBrightness = 'enableAutoBrightness',
|
||||
@@ -136,7 +154,20 @@ class SettingBoxKey {
|
||||
enableSystemProxy = 'enableSystemProxy',
|
||||
enableAi = 'enableAi',
|
||||
disableLikeMsg = 'disableLikeMsg',
|
||||
defaultHomePage = 'defaultHomePage';
|
||||
defaultHomePage = 'defaultHomePage',
|
||||
|
||||
// 弹幕相关设置 权重(云屏蔽) 屏蔽类型 显示区域 透明度 字体大小 弹幕时间 描边粗细
|
||||
danmakuWeight = 'danmakuWeight',
|
||||
danmakuBlockType = 'danmakuBlockType',
|
||||
danmakuShowArea = 'danmakuShowArea',
|
||||
danmakuOpacity = 'danmakuOpacity',
|
||||
danmakuFontScale = 'danmakuFontScale',
|
||||
danmakuDuration = 'danmakuDuration',
|
||||
strokeWidth = 'strokeWidth',
|
||||
|
||||
// 代理host port
|
||||
systemProxyHost = 'systemProxyHost',
|
||||
systemProxyPort = 'systemProxyPort';
|
||||
|
||||
/// 外观
|
||||
static const String themeMode = 'themeMode',
|
||||
@@ -146,6 +177,7 @@ class SettingBoxKey {
|
||||
enableSingleRow = 'enableSingleRow', // 首页单列
|
||||
displayMode = 'displayMode',
|
||||
maxRowWidth = 'maxRowWidth', // 首页列最大宽度(dp)
|
||||
adaptiveNavBar = 'adaptiveNavBar',
|
||||
enableMYBar = 'enableMYBar',
|
||||
hideSearchBar = 'hideSearchBar', // 收起顶栏
|
||||
hideTabBar = 'hideTabBar', // 收起底栏
|
||||
@@ -164,20 +196,7 @@ class LocalCacheKey {
|
||||
|
||||
//
|
||||
wbiKeys = 'wbiKeys',
|
||||
timeStamp = 'timeStamp',
|
||||
|
||||
// 弹幕相关设置 权重(云屏蔽) 屏蔽类型 显示区域 透明度 字体大小 弹幕时间 描边粗细
|
||||
danmakuWeight = 'danmakuWeight',
|
||||
danmakuBlockType = 'danmakuBlockType',
|
||||
danmakuShowArea = 'danmakuShowArea',
|
||||
danmakuOpacity = 'danmakuOpacity',
|
||||
danmakuFontScale = 'danmakuFontScale',
|
||||
danmakuDuration = 'danmakuDuration',
|
||||
strokeWidth = 'strokeWidth',
|
||||
|
||||
// 代理host port
|
||||
systemProxyHost = 'systemProxyHost',
|
||||
systemProxyPort = 'systemProxyPort';
|
||||
timeStamp = 'timeStamp';
|
||||
}
|
||||
|
||||
class VideoBoxKey {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
import 'dart:math';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
@@ -193,7 +192,6 @@ class Utils {
|
||||
toInt: true,
|
||||
);
|
||||
}
|
||||
print('distance: $distance');
|
||||
if (distance <= 60) {
|
||||
return '刚刚';
|
||||
} else if (distance <= 3600) {
|
||||
|
||||
Reference in New Issue
Block a user