app-starlock/lib/flavors.dart

198 lines
5.1 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,
2024-09-27 23:33:45 +08:00
sky_dev,
sky_pre,
xhj,
2024-09-27 23:33:45 +08:00
xhj_dev,
xhj_pre,
}
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 ?? '';
2024-09-27 23:33:45 +08:00
static bool get isXHJ =>
appFlavor == Flavor.xhj ||
appFlavor == Flavor.xhj_dev ||
appFlavor == Flavor.xhj_pre;
static bool get isSKY =>
appFlavor == Flavor.sky ||
appFlavor == Flavor.sky_dev ||
appFlavor == Flavor.sky_pre;
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:
2024-09-27 23:33:45 +08:00
case Flavor.sky_dev:
case Flavor.sky_pre:
2024-05-28 10:40:17 +08:00
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:
2024-08-27 11:08:44 +08:00
return '${'星锁'.tr}-local';
case Flavor.dev:
2024-08-27 11:08:44 +08:00
return '${'星锁'.tr}-dev';
case Flavor.pre:
2024-08-27 11:08:44 +08:00
return '${'星锁'.tr}-pre';
case Flavor.sky:
2024-09-27 23:33:45 +08:00
case Flavor.sky_dev:
case Flavor.sky_pre:
return '锁通通'.tr;
case Flavor.xhj:
2024-09-27 23:33:45 +08:00
case Flavor.xhj_dev:
case Flavor.xhj_pre:
return '星星锁'.tr;
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 '${"星锁".tr}-local';
2024-03-06 19:12:58 +08:00
case Flavor.dev:
return '${"星锁".tr}-dev';
2024-03-06 19:12:58 +08:00
case Flavor.pre:
return '星锁'.tr;
2024-03-06 19:12:58 +08:00
case Flavor.sky:
2024-09-27 23:33:45 +08:00
case Flavor.sky_dev:
case Flavor.sky_pre:
return '锁通通'.tr;
2024-03-06 19:12:58 +08:00
case Flavor.xhj:
2024-09-27 23:33:45 +08:00
case Flavor.xhj_dev:
case Flavor.xhj_pre:
return '星星锁'.tr;
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 'http://lock.ge.star-lock.cn'; // 葛工
// return 'http://192.168.1.15:8022'; // 谢工
// return 'http://zhou.lock.star-lock.cn'; // 周工
2024-09-27 23:33:45 +08:00
case Flavor.dev:
2024-09-27 23:33:45 +08:00
case Flavor.xhj_dev:
case Flavor.sky_dev:
return 'https://dev.lock.star-lock.cn';
case Flavor.pre:
2024-09-27 23:33:45 +08:00
case Flavor.xhj_pre:
case Flavor.sky_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:
return const StarLockAMapKey(
androidKey: '9388ca47f9674b447a17eff82bc0e2ea',
iosKey: 'cdec0512564baa58be26b2e2ac5ef3b7');
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');
case Flavor.sky_dev:
return const StarLockAMapKey(
androidKey: '',
iosKey: '',
);
case Flavor.sky_pre:
return const StarLockAMapKey(
androidKey: '7d59c7416c455af3cf80bfb02478e733',
iosKey: 'a5c6c62386aa2b8285b5f8c2cd0597df',
);
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');
case Flavor.xhj_dev:
return const StarLockAMapKey(
androidKey: '',
iosKey: '',
);
case Flavor.xhj_pre:
return const StarLockAMapKey(
androidKey: '9d96095a53f46f5e323a5e9e7f3eaae2',
iosKey: '57f81124738270472558c685199c9a6a',
);
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:
return const StarLockAMapKey(
androidKey: 'no valied key',
iosKey: 'no valied key',
);
2024-02-01 14:53:55 +08:00
}
}
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;
}
}
}