feat(mobile-next): 建立 v2 Token 唯一入口、内网地址与功能开关

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
编码工程师
2026-08-20 02:30:09 +08:00
co-authored by Cursor multica-agent
parent 45d91684bc
commit d787c0a477
11 changed files with 384 additions and 81 deletions
@@ -0,0 +1,36 @@
/// 内网地址唯一入口。页面与 SDK 初始化不得再硬编码 IP/端口。
///
/// 仅本地联调:`--dart-define=AUTH_HOST=127.0.0.1` 可覆盖账号服务地址。
class AppEndpoints {
AppEndpoints._();
static const String host = String.fromEnvironment(
'SERVER_HOST',
defaultValue: '192.168.200.11',
);
static const String authHost = String.fromEnvironment(
'AUTH_HOST',
defaultValue: host,
);
static const int apiPort = 10002;
static const int wsPort = 10001;
static const int authPort = 10010;
static const int livekitPort = 17880;
static const String apiAddr = 'http://$host:$apiPort';
static const String wsAddr = 'ws://$host:$wsPort';
static const String authApiBase = 'http://$authHost:$authPort';
static const String livekitUrl = 'ws://$host:$livekitPort';
/// 写入官方 DataSp 的服务器配置键,供 Config.imApiUrl / imWsUrl 读取。
static Map<String, String> toServerConfig() => {
'serverIP': host,
'apiUrl': apiAddr,
'wsUrl': wsAddr,
'authUrl': authApiBase,
'chatTokenUrl': authApiBase,
'logLevel': '5',
};
}
@@ -0,0 +1,15 @@
import 'package:openim_common/openim_common.dart';
import '../brand/apply_official_styles.dart';
import 'app_endpoints.dart';
/// 启动时注入内网地址与官方 Styles→Token 映射。不改 SDK 核心。
class CompanyBootstrap {
CompanyBootstrap._();
static Future<void> install() async {
applyOfficialStylesFromTokens();
await DataSp.putServerConfig(AppEndpoints.toServerConfig());
ApiService().setBaseUrl(AppEndpoints.host);
}
}