fix: 更新诸多bug
This commit is contained in:
@@ -22,6 +22,7 @@ import '../kr_site_config_service.dart';
|
||||
import '../../common/app_config.dart';
|
||||
import 'package:dio/dio.dart' as dio;
|
||||
import 'package:kaer_with_panels/app/services/singbox_imp/kr_sing_box_imp.dart';
|
||||
import 'package:kaer_with_panels/app/utils/kr_http_adapter_util.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class KRAuthApi {
|
||||
@@ -401,6 +402,13 @@ class KRAuthApi {
|
||||
|
||||
// 使用 Dio 直接发送请求(因为需要特殊的加密处理)
|
||||
final dioInstance = dio.Dio();
|
||||
// ✅ 关键修复:统一使用配置好的 Adapter,包含 SSL 验证绕过和代理处理
|
||||
dioInstance.httpClientAdapter = KRHttpAdapterUtil.createAdapter(
|
||||
useSingBoxProxy: false, // 设备登录建议先直连
|
||||
forceDirect: true,
|
||||
timeout: const Duration(seconds: 10),
|
||||
);
|
||||
|
||||
final baseUrl = AppConfig.getInstance().baseUrl;
|
||||
final url = '$baseUrl${Api.kr_deviceLogin}';
|
||||
|
||||
|
||||
@@ -229,8 +229,11 @@ class KRSubscribeApi {
|
||||
|
||||
/// 获取用户已订阅套餐
|
||||
Future<Either<HttpError, List<KRAlreadySubscribe>>>
|
||||
kr_getAlreadySubscribe() async {
|
||||
kr_getAlreadySubscribe({String? includeExpired}) async {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
if (includeExpired != null) {
|
||||
data['includeExpired'] = includeExpired;
|
||||
}
|
||||
|
||||
BaseResponse<KRAlreadySubscribeList> baseResponse =
|
||||
await HttpUtil.getInstance().request<KRAlreadySubscribeList>(
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'package:get/get.dart';
|
||||
import '../modules/kr_home/views/hi_subscription_corner_button.dart';
|
||||
import 'package:kaer_with_panels/main.dart';
|
||||
import 'package:kaer_with_panels/app/widgets/kr_local_image.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:kaer_with_panels/app/routes/app_pages.dart';
|
||||
|
||||
class GlobalOverlayService extends GetxService {
|
||||
Color? _currentColor;
|
||||
@@ -24,9 +26,14 @@ class GlobalOverlayService extends GetxService {
|
||||
}
|
||||
OverlayEntry? _overlayEntry;
|
||||
final RxBool _isVisible = false.obs;
|
||||
final RxString _currentRoute = ''.obs;
|
||||
|
||||
bool get isVisible => _isVisible.value;
|
||||
|
||||
void updateCurrentRoute(String route) {
|
||||
_currentRoute.value = route;
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -77,20 +84,56 @@ class GlobalOverlayService extends GetxService {
|
||||
|
||||
// 2️⃣ money-icon,独立定位,固定在屏幕右上角
|
||||
Positioned(
|
||||
top: MediaQuery.of(context).padding.top + 8,
|
||||
right: ((radius - (statusBarHeight / 2)) / 2) + 3,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent, // 让区域可响应点击
|
||||
onTap: () {
|
||||
// ✅ 这里“代理”点击事件,转发到底层按钮动画逻辑
|
||||
print('🔥 money-icon tapped → trigger HISubscriptionCornerButton animation');
|
||||
GlobalOverlayService.instance.triggerSubscriptionAnimation();
|
||||
},
|
||||
child: IgnorePointer(
|
||||
ignoring: false, // 不阻断事件
|
||||
child: KrLocalImage(
|
||||
imageName: 'money-icon',
|
||||
imageType: ImageType.svg,
|
||||
top: MediaQuery.of(context).padding.top,
|
||||
right: (radius / 2),
|
||||
child: FractionalTranslation(
|
||||
// Offset 的第一个参数是 x,第二个是 y
|
||||
// 0.5 代表向右偏移自身宽度的 50%,-0.5 代表向左偏移自身宽度的 50%
|
||||
translation: const Offset(0.5, 0),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: () {
|
||||
print('🔥 money-icon tapped');
|
||||
GlobalOverlayService.instance.triggerSubscriptionAnimation();
|
||||
},
|
||||
child: IgnorePointer(
|
||||
ignoring: false,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
KrLocalImage(
|
||||
imageName: 'money-icon',
|
||||
imageType: ImageType.svg,
|
||||
width: 32.w, // 建议固定宽度以保证计算准确
|
||||
),
|
||||
SizedBox(height: 2.w),
|
||||
Obx(() {
|
||||
final current = _currentRoute.value;
|
||||
print('🔥 GlobalOverlayService Obx: currentRoute = $current');
|
||||
|
||||
// ✅ 结合三种方式判断:1. 显式设为透明 2. 路由名称匹配 3. 包含关键特征
|
||||
bool isHidden = _currentColor == Colors.transparent ||
|
||||
current == Routes.KR_PURCHASE_MEMBERSHIP ||
|
||||
current.contains(Routes.KR_PURCHASE_MEMBERSHIP) ||
|
||||
Routes.KR_PURCHASE_MEMBERSHIP.contains(current) ||
|
||||
current == Routes.KR_ORDER_STATUS ||
|
||||
current.contains('purchase-membership');
|
||||
|
||||
if (isHidden) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return Text(
|
||||
'购买套餐',
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 12.sp,
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -225,17 +225,21 @@ class KRDeviceInfoService {
|
||||
}
|
||||
|
||||
/// Windows设备ID - 使用机器GUID
|
||||
/// 🔧 修复:不使用 flutter_udid,因为它会调用 wmic 命令弹出黑窗口
|
||||
Future<String> _getWindowsDeviceId() async {
|
||||
try {
|
||||
final windowsInfo = await _deviceInfo.windowsInfo;
|
||||
|
||||
// 优先使用 flutter_udid
|
||||
String udid = await FlutterUdid.consistentUdid;
|
||||
// 🔧 修复:不使用 FlutterUdid.consistentUdid
|
||||
// 因为它在 Windows 上会调用 "cmd.exe /c wmic csproduct get UUID"
|
||||
// 这个调用没有使用 CREATE_NO_WINDOW 标志,会弹出黑色命令行窗口
|
||||
|
||||
// 直接使用 device_info_plus 提供的信息构建唯一标识
|
||||
// windowsInfo.deviceId 已经是一个稳定的设备标识
|
||||
|
||||
// 构建多因子字符串
|
||||
final factors = [
|
||||
udid,
|
||||
windowsInfo.deviceId, // 设备ID
|
||||
windowsInfo.deviceId, // 设备ID (最稳定,来自注册表 MachineGuid)
|
||||
windowsInfo.computerName, // 计算机名
|
||||
windowsInfo.productName, // 产品名
|
||||
windowsInfo.numberOfCores.toString(), // CPU核心数
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
|
||||
import '../model/response/kr_site_config.dart';
|
||||
import '../common/app_config.dart';
|
||||
import '../utils/kr_log_util.dart';
|
||||
import '../utils/kr_http_adapter_util.dart';
|
||||
import 'singbox_imp/kr_sing_box_imp.dart';
|
||||
|
||||
/// 网站配置服务
|
||||
@@ -25,6 +26,14 @@ class KRSiteConfigService extends ChangeNotifier {
|
||||
'🌐 网站配置服务:使用直连模式(不通过代理)',
|
||||
tag: 'KRSiteConfigService',
|
||||
);
|
||||
|
||||
// 🔧 关键修复:添加 SSL 证书验证跳过,强制直连
|
||||
_dio.httpClientAdapter = KRHttpAdapterUtil.createAdapter(
|
||||
useSingBoxProxy: false,
|
||||
forceDirect: true,
|
||||
timeout: const Duration(seconds: 20),
|
||||
);
|
||||
|
||||
if (kDebugMode) {
|
||||
print('🌐 网站配置服务:使用直连模式,避免 SingBox 未初始化问题');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user