Files
崔宝新 3a2b589e37 feat: add new assets, optimize list layout and重构个人中心页面
1. 新增fork/star/close等多个业务图标并配置到静态资源路径
2. 新增静态资源CDN配置常量
3. 优化帖子列表加载更多UI,无更多数据时显示提示文本
4. 重构我的页面布局,对齐Vue端实现,替换图标为CDN资源
5. 统一退出登录弹窗为公共组件,调整代码格式与缩进
2026-09-07 17:53:32 +08:00

69 lines
2.8 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/// ============================================================
/// 【AppEnv】环境配置 —— 编译期注入(对标 uni-app 的 envList)
///
/// 一、核心概念:
/// 环境是"打包时定死"的维度:测试包连测试地址,正式包连正式地址。
/// 所以用 `--dart-define` 在编译期注入,代码里是 const,零运行时开销。
///
/// 二、怎么用:
/// flutter run --dart-define=ENV=dev
/// flutter build apk --release --dart-define=ENV=prod
/// 不传时默认 prod(日常 flutter run 不用带参数,行为不变)。
///
/// 三、对标 uni-app(app.config.js envList):
/// dev = 开发/本地调试 test = 测试服 prod = 正式服
/// 每个环境一套 {baseUrl / gameUrl / reportUrl}。
/// ============================================================
class AppEnv {
AppEnv._();
/// 环境:dev / test / prod(默认 prod,日常运行零参数)
static const String env = String.fromEnvironment('ENV', defaultValue: 'prod');
/// 品牌标识:aixue / chucai / yule / ...(默认 aixue=爱学蝶变)
/// 品牌表见 app_brand.dart;主题/接口/App 名都随它走(AppConfig 聚合)
static const String brand = String.fromEnvironment(
'BRAND',
defaultValue: 'aixue',
);
/// 三套环境地址表(与 uni-app envList 完全对齐)
static const Map<String, Map<String, String>> _envTable = {
'dev': {
'baseUrl': 'https://k12-student-api-test.23544.com:16400',
'gameUrl': 'https://cocos-test.cnzhyx.cn',
'reportUrl': 'https://report-test.cnzhyx.cn/',
},
'test': {
'baseUrl': 'https://axdb-test.cnzhyx.cn',
'gameUrl': 'https://cocos-test.cnzhyx.cn',
'reportUrl': 'https://report-test.cnzhyx.cn/',
},
'prod': {
// 正式环境的 baseUrl 在 AppConfig 里会被品牌专属地址覆盖(同 uni-app)
'baseUrl': 'https://ylax-api.cqbzyx.com',
'gameUrl': 'https://axdb-cocos.cnzhyx.cn/',
'reportUrl': 'https://axdb-report.cnzhyx.cn/',
},
};
/// 取当前环境某个 key 的地址(key 不存在返回空串,避免线上崩)
static String value(String key) =>
_envTable[env]?[key] ?? _envTable['prod']?[key] ?? '';
/// 当前环境接口地址
static String get baseUrl => value('baseUrl');
/// 当前环境小游戏地址(预留,对标 envList.gameUrl)
static String get gameUrl => value('gameUrl');
/// 当前环境学习报告地址(预留,对标 envList.reportUrl)
static String get reportUrl => value('reportUrl');
/// 静态资源 CDN 域名(对标 uni-app utils/image.js 的 IMG_URL)
static const String imgBaseUrl = 'https://hx.cnzhyx.cn';
/// 是否正式环境(组合规则里判断用:prod 才走品牌专属地址)
static bool get isProd => env == 'prod';
}