Compare commits

...

3 Commits

Author SHA1 Message Date
b442289b8a feat: 修改bug
Some checks failed
Build Windows / build (push) Has been cancelled
Build Windows / 编译 libcore (Windows) (20.15.1) (push) Has started running
2025-11-20 06:19:05 -08:00
89d13e6237 feat: 修改兼容 2025-11-20 00:51:14 -08:00
8fd742a688 feat: 修改兼容 2025-11-19 04:06:46 -08:00
9 changed files with 171 additions and 81 deletions

BIN
android/app/src/main/res/drawable-hdpi/splash.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -1447,7 +1447,7 @@ class AppConfig {
kr_official_telegram = config.kr_official_telegram;
kr_official_telephone = config.kr_official_telephone;
kr_invitation_link = config.kr_invitation_link;
kr_website_id = config.kr_website_id;
// kr_website_id = config.kr_website_id;
if (config.kr_domains.isNotEmpty) {
KRDomain.kr_handleDomains(config.kr_domains);
}

View File

@ -19,53 +19,48 @@ class HINodePageView extends GetView<HINodeListController> {
return HIBaseScaffold(
child: Stack(
children: [
Positioned(
left: 0,
child: Obx(() => controller.isDebugMode.value
? GestureDetector(
onTap: () {
controller.kr_resetDebugMode();
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 4.w),
decoration: BoxDecoration(
color: Colors.red.withOpacity(0.8),
borderRadius: BorderRadius.circular(12.w),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.bug_report,
size: 12.w,
color: Colors.white,
),
SizedBox(width: 3.w),
Text(
'关闭调试',
style: TextStyle(
fontSize: 10.sp,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
],
),
),
)
: const SizedBox.shrink()),
),
//
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Positioned(
left: 0, //
child: Obx(() => controller.isDebugMode.value
? GestureDetector(
onTap: () {
controller.kr_resetDebugMode();
Get.snackbar(
'调试模式',
'已关闭调试模式',
snackPosition: SnackPosition.BOTTOM,
duration: const Duration(seconds: 2),
);
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 4.w),
decoration: BoxDecoration(
color: Colors.red.withOpacity(0.8),
borderRadius: BorderRadius.circular(12.w),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.bug_report,
size: 12.w,
color: Colors.white,
),
SizedBox(width: 3.w),
Text(
'关闭调试',
style: TextStyle(
fontSize: 10.sp,
color: Colors.white,
fontWeight: FontWeight.w500,
),
),
],
),
),
)
: const SizedBox.shrink()),
),
//
//
Padding(
padding: EdgeInsets.only(left: 100.w, right: 60.w),
child: Row(

View File

@ -429,7 +429,7 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'设备:${_extractDeviceModel(userAgent)}',
'设备:${_extractDeviceModel(userAgent, deviceType)}',
style: TextStyle(
color: Colors.white,
fontSize: 10.sp, //
@ -589,12 +589,12 @@ class HIUserInfoView extends GetView<HIUserInfoController> {
);
}
String _extractDeviceModel(String deviceName) {
String _extractDeviceModel(String deviceName, String deviceType) {
//
final RegExp regExp = RegExp(r'\((.*?)\)');
final Match? match = regExp.firstMatch(deviceName);
if (match != null && match.groupCount >= 1) {
if (match != null && match.groupCount >= 1 ) {
//
final inside = match.group(1)!; // "Android; google Pixel 9; 15"

View File

@ -305,19 +305,24 @@ class KRLoginController extends GetxController
///
void kr_sendCode() async {
final either = await KRAuthApi().kr_sendCode(
accountController.text,
2
); // 3
/*
*
* kr_loginStatus.value == KRLoginProgressStatus.kr_registerSendCode
? 2 // 2
: 3*/
if (accountController.text.isEmpty) {
KRCommonUtil.kr_showToast(AppTranslations.kr_login.enterAccount);
return;
}
int type;
final check = await KRAuthApi().kr_isRegister(accountController.text);
final result = check.fold((l) {
KRCommonUtil.kr_showToast(l.msg);
return null;
}, (isRegistered) => isRegistered ? 2 : 1);
if (result == null) return;
type = result;
final either = await KRAuthApi().kr_sendCode(accountController.text, type);
either.fold((l) {
KRCommonUtil.kr_showToast(l.msg);
}, (r) async {
///
_startCountdown();
});
}

View File

@ -76,10 +76,13 @@ class KRLoginView extends GetView<KRLoginController> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Obx(() {
final _ = KRAppRunData.getInstance().kr_isLogin.value;
final email = KRAppRunData.getInstance().kr_account.value ?? '';
final account = KRAppRunData.getInstance().kr_account.value;
final isDeviceLogin = account != null && account.startsWith('9000');
if (isDeviceLogin) return const SizedBox();
return Text(
email.isNotEmpty ? email : '',
account ?? '',
style: TextStyle(
color: Colors.white,
fontSize: 20.sp,

View File

@ -1,7 +1,7 @@
///
abstract class Api {
///
static const String kr_isRegister = "/v1/app/auth/check";
static const String kr_isRegister = "/v1/auth/check";
///
static const String kr_checkSubscription = "/v1/public/user/subscribe_status";

View File

@ -36,7 +36,7 @@ class KRAuthApi {
BaseResponse<KRIsRegister> baseResponse = await HttpUtil.getInstance()
.request<KRIsRegister>(Api.kr_isRegister, data,
method: HttpMethod.POST, isShowLoading: true);
method: HttpMethod.GET, isShowLoading: true);
if (!baseResponse.isSuccess) {
return left(

View File

@ -12,6 +12,7 @@ import 'package:kaer_with_panels/singbox/service/singbox_service.dart';
import 'package:kaer_with_panels/singbox/service/singbox_service_provider.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart' as p;
import 'package:device_info_plus/device_info_plus.dart';
import '../../../core/model/directories.dart';
import '../../../singbox/model/singbox_config_option.dart';
@ -112,6 +113,62 @@ class KRSingBoxImp {
/// Futuresingle-flight
Future<void>? _kr_initFuture;
/// Android模拟器
bool _kr_isAndroidEmulator = false;
///
///
/// - Android
/// - brand/model/product/manufacturer
/// `_kr_isAndroidEmulator`
Future<void> _kr_detectEmulator() async {
try {
if (!Platform.isAndroid) {
_kr_isAndroidEmulator = false;
return;
}
final info = await DeviceInfoPlugin().androidInfo;
final brand = (info.brand ?? '').toLowerCase();
final model = (info.model ?? '').toLowerCase();
final product = (info.product ?? '').toLowerCase();
final manufacturer = (info.manufacturer ?? '').toLowerCase();
final device = (info.device ?? '').toLowerCase();
bool containsAny(String s, List<String> keys) => keys.any((k) => s.contains(k));
final indicators = <bool>[
containsAny(brand, [
'generic', 'unknown', 'google', 'vbox', 'virtualbox',
'bluestacks', 'nox', 'ldplayer', 'genymotion', 'mumu', 'netease', 'leidian'
]),
containsAny(model, [
'emulator', 'sdk', 'sdk_gphone', 'google_sdk', 'android sdk built for x86',
'bluestacks', 'genymotion', 'nox', 'ldplayer', 'mumu'
]),
containsAny(product, [
'sdk', 'google_sdk', 'sdk_gphone', 'emulator', 'vbox', 'virtualbox'
]),
containsAny(manufacturer, [
'genymotion', 'unknown', 'bluestacks', 'nox', 'ld', 'netease', 'mumu'
]),
containsAny(device, [
'emulator', 'generic', 'vbox', 'virtualbox', 'sdk'
]),
];
_kr_isAndroidEmulator = indicators.any((v) => v);
KRLogUtil.kr_i(
'🔍 Android 模拟器检测: ${_kr_isAndroidEmulator ? '是模拟器' : '非模拟器'}'
' (brand=$brand, model=$model, product=$product, manufacturer=$manufacturer, device=$device)',
tag: 'SingBox',
);
} catch (e) {
_kr_isAndroidEmulator = false;
KRLogUtil.kr_w('⚠️ 模拟器检测失败,按真机处理: $e', tag: 'SingBox');
}
}
///
bool get kr_isProxyReady => kr_status.value is SingboxStarted;
@ -167,6 +224,9 @@ class KRSingBoxImp {
await KRCountryUtil.kr_init();
KRLogUtil.kr_i('国家工具初始化完成');
// Android模拟器
await _kr_detectEmulator();
final oOption = SingboxConfigOption.fromJson(_getConfigOption());
KRLogUtil.kr_i('配置选项初始化完成');
@ -555,9 +615,11 @@ class KRSingBoxImp {
"log-level": "info", // 使 info warn
"resolve-destination": false,
"ipv6-mode": "ipv4_only", // hiddify-app: 使 IPv4 (: ipv4_only, prefer_ipv4, prefer_ipv6, ipv6_only)
"remote-dns-address": "https://dns.google/dns-query", // 使 Google DoH DNS
"remote-dns-address": _kr_isAndroidEmulator
? "local"
: "https://dns.google/dns-query",
"remote-dns-domain-strategy": "prefer_ipv4",
"direct-dns-address": "local", // 使 DNS
"direct-dns-address": "local",
"direct-dns-domain-strategy": "prefer_ipv4",
"mixed-port": kr_port,
"tproxy-port": kr_port,
@ -645,6 +707,47 @@ class KRSingBoxImp {
return op;
}
/// DNS
///
/// - 使 DoH + DNSfinal
/// - 使 DNSfinal DNS
/// Sing-box `dns` Map
Map<String, dynamic> _kr_buildDnsConfig() {
if (_kr_isAndroidEmulator) {
KRLogUtil.kr_i('🛡️ 模拟器兼容模式:强制使用系统 DNS', tag: 'SingBox');
return {
"servers": [
{
"tag": "dns-direct",
"address": "local",
"detour": "direct"
}
],
"rules": [],
"final": "dns-direct",
"strategy": "prefer_ipv4"
};
}
return {
"servers": [
{
"tag": "dns-remote",
"address": "https://1.1.1.1/dns-query",
"address_resolver": "dns-direct"
},
{
"tag": "dns-direct",
"address": "local",
"detour": "direct"
}
],
"rules": _kr_buildDnsRules(),
"final": "dns-remote",
"strategy": "prefer_ipv4"
};
}
///
/// hiddify-app: libcore UI
void _kr_subscribeToStatus() {
@ -1150,23 +1253,7 @@ class KRSingBoxImp {
"level": "debug",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "dns-remote",
"address": "https://1.1.1.1/dns-query",
"address_resolver": "dns-direct"
},
{
"tag": "dns-direct",
"address": "local",
"detour": "direct"
}
],
"rules": _kr_buildDnsRules(), // 使 DNS
"final": "dns-remote",
"strategy": "prefer_ipv4"
},
"dns": _kr_buildDnsConfig(),
"inbounds": [
{
"type": "tun",