app-starlock/lib/flavors.dart

145 lines
3.6 KiB
Dart
Raw Normal View History

import 'package:get/get.dart';
enum Flavor {
2024-04-08 13:30:35 +08:00
local,
dev,
pre,
sky,
xhj,
}
2024-02-01 14:53:55 +08:00
class StarLockAMapKey {
//iOS平台的key
final String iosKey;
2024-02-01 14:53:55 +08:00
//Android平台的key
final String androidKey;
2024-02-01 14:53:55 +08:00
const StarLockAMapKey({required this.iosKey, required this.androidKey});
}
2024-04-15 14:09:23 +08:00
typedef dynamic fCallFunction();
class F {
static Flavor? appFlavor;
2024-03-28 09:51:30 +08:00
// 是否为精简模式(在一些应用商店场景下,需要精简掉一些功能)
static bool isLite = false;
static String get name => appFlavor?.name ?? '';
static bool get isXHJ => appFlavor == Flavor.xhj;
2024-06-01 13:35:03 +08:00
static bool get isSKY => appFlavor == Flavor.sky;
2024-04-15 14:09:23 +08:00
//便捷判断并返回值
static dynamic sw(
2024-05-28 10:40:17 +08:00
{required fCallFunction skyCall, required fCallFunction? xhjCall}) {
2024-04-15 14:09:23 +08:00
if (xhjCall == null) {
2024-05-28 10:40:17 +08:00
return skyCall();
2024-04-15 14:09:23 +08:00
}
switch (appFlavor) {
2024-05-28 10:40:17 +08:00
case Flavor.sky:
return skyCall();
2024-04-15 14:09:23 +08:00
case Flavor.local:
case Flavor.dev:
case Flavor.pre:
2024-05-28 10:40:17 +08:00
case Flavor.xhj:
2024-04-15 14:09:23 +08:00
default:
2024-05-28 10:40:17 +08:00
return xhjCall();
2024-04-15 14:09:23 +08:00
}
}
static String get title {
switch (appFlavor) {
2024-04-08 13:30:35 +08:00
case Flavor.local:
return '星锁-local';
case Flavor.dev:
return '星锁-dev';
case Flavor.pre:
return '星锁-pre';
case Flavor.sky:
return '锁通通';
case Flavor.xhj:
2024-05-30 10:10:22 +08:00
return '星星锁';
default:
throw Exception('flavor[$name] title not found');
}
}
2024-03-06 19:12:58 +08:00
static String get navTitle {
switch (appFlavor) {
2024-04-08 13:30:35 +08:00
case Flavor.local:
return '${"starLock".tr}-local';
2024-03-06 19:12:58 +08:00
case Flavor.dev:
return '${"starLock".tr}-dev';
2024-03-06 19:12:58 +08:00
case Flavor.pre:
2024-05-28 09:56:40 +08:00
return 'starLock'.tr;
2024-03-06 19:12:58 +08:00
case Flavor.sky:
return '锁通通';
case Flavor.xhj:
2024-05-30 10:10:22 +08:00
return '星星锁';
2024-03-06 19:12:58 +08:00
default:
throw Exception('flavor[$name] title not found');
}
}
static String get apiPrefix {
switch (appFlavor) {
2024-04-08 13:30:35 +08:00
case Flavor.local:
return 'https://ge.lock.star-lock.cn'; // 葛工
2024-05-18 18:25:39 +08:00
// return 'http://192.168.1.15:8022'; // 谢工
case Flavor.dev:
return 'https://dev.lock.star-lock.cn';
case Flavor.pre:
return 'https://pre.lock.star-lock.cn';
case Flavor.sky:
return 'https://lock.skychip.top';
case Flavor.xhj:
2024-05-28 09:56:40 +08:00
return 'https://lock.xhjcn.ltd';
2024-05-18 18:25:39 +08:00
// return 'https://pre.lock.star-lock.cn';
default:
throw Exception('flavor[$name] apiPrefix not found');
}
}
2024-02-01 14:53:55 +08:00
// StarLockAMapKey
static StarLockAMapKey get aMapKey {
switch (appFlavor) {
2024-04-08 13:30:35 +08:00
case Flavor.local:
2024-02-01 14:53:55 +08:00
case Flavor.dev:
return const StarLockAMapKey(
2024-04-11 18:26:28 +08:00
androidKey: 'b56b681ee89f4db43a5aa1879ae8cbfe',
iosKey: 'bd4496e6598ef49796e3a80715035b4d');
2024-02-01 14:53:55 +08:00
case Flavor.pre:
return const StarLockAMapKey(
2024-04-11 18:26:28 +08:00
androidKey: '11d49b3f4fc09c04a02bbb7500925ba2',
iosKey: '883a3355d2d77c2fdc2667030dc97ffe');
2024-03-05 11:17:58 +08:00
case Flavor.sky:
return const StarLockAMapKey(
2024-04-11 18:26:28 +08:00
androidKey: 'fb0d2a3e4208b36452cf636aa025a24f',
iosKey: '86ca725a12a629c280e116a317aaba19');
2024-04-16 11:21:41 +08:00
case Flavor.xhj:
return const StarLockAMapKey(
androidKey: '9dd8073a2e96870b206269bb562a887a',
iosKey: 'c70047e60ce704d945ea89d6c2763b82');
2024-02-01 14:53:55 +08:00
default:
throw Exception('flavor[$name] aMapKey not found');
}
}
2024-05-18 18:25:39 +08:00
// 是否是生产环境
static bool get isProductionEnv {
switch (appFlavor) {
case Flavor.local:
case Flavor.dev:
case Flavor.pre:
return false;
case Flavor.sky:
case Flavor.xhj:
return true;
default:
return false;
}
}
}