fix: 验收包写入公司内网地址,避免 Windows 空 VITE 与 Android 假域名
Windows 补 .env.production 与 endpoints 兜底;Android 默认 host/端口改为内网,启动后重写 HttpUtil/ApiService,Urls 改为 getter。 Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Cursor
multica-agent
parent
18d890ae7f
commit
bbc4dce0b6
@@ -10,6 +10,7 @@ class CompanyBootstrap {
|
||||
static Future<void> install() async {
|
||||
applyOfficialStylesFromTokens();
|
||||
await DataSp.putServerConfig(AppEndpoints.toServerConfig());
|
||||
ApiService().setBaseUrl(AppEndpoints.host);
|
||||
HttpUtil.setBaseUrl(AppEndpoints.apiAddr);
|
||||
ApiService().setBaseUrl(AppEndpoints.apiAddr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class Config {
|
||||
await Hive.initFlutter(path);
|
||||
MediaKit.ensureInitialized();
|
||||
HttpUtil.init();
|
||||
ApiService().setBaseUrl(serverIp);
|
||||
ApiService().setBaseUrl(imApiUrl);
|
||||
} catch (_) {}
|
||||
|
||||
runApp();
|
||||
@@ -65,9 +65,10 @@ class Config {
|
||||
static const friendScheme = "io.openim.app/addFriend/";
|
||||
static const groupScheme = "io.openim.app/joinGroup/";
|
||||
|
||||
static const _host = "your-server-ip or your-domain";
|
||||
static const _host = "192.168.200.11";
|
||||
|
||||
static const _ipRegex = '((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)';
|
||||
static const _ipRegex =
|
||||
'((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)';
|
||||
|
||||
static bool get _isIP => RegExp(_ipRegex).hasMatch(_host);
|
||||
|
||||
@@ -86,7 +87,7 @@ class Config {
|
||||
if (null != server) {
|
||||
url = server['chatTokenUrl'];
|
||||
}
|
||||
return url ?? (_isIP ? "http://$_host:10009" : "https://$_host/chat");
|
||||
return url ?? (_isIP ? "http://$_host:10010" : "https://$_host/chat");
|
||||
}
|
||||
|
||||
static String get appAuthUrl {
|
||||
@@ -95,7 +96,7 @@ class Config {
|
||||
if (null != server) {
|
||||
url = server['authUrl'];
|
||||
}
|
||||
return url ?? (_isIP ? "http://$_host:10008" : "https://$_host/chat");
|
||||
return url ?? (_isIP ? "http://$_host:10010" : "https://$_host/chat");
|
||||
}
|
||||
|
||||
static String get imApiUrl {
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
import 'config.dart';
|
||||
|
||||
class Urls {
|
||||
static final onlineStatus = "${Config.imApiUrl}/manager/get_users_online_status";
|
||||
static final queryAllUsers = "${Config.imApiUrl}/manager/get_all_users_uid";
|
||||
static final updateUserInfo = "${Config.appAuthUrl}/user/update";
|
||||
static final searchFriendInfo = "${Config.appAuthUrl}/friend/search";
|
||||
static final getUsersFullInfo = "${Config.appAuthUrl}/user/find/full";
|
||||
static final searchUserFullInfo = "${Config.appAuthUrl}/user/search/full";
|
||||
static String get onlineStatus =>
|
||||
"${Config.imApiUrl}/manager/get_users_online_status";
|
||||
static String get queryAllUsers =>
|
||||
"${Config.imApiUrl}/manager/get_all_users_uid";
|
||||
static String get updateUserInfo => "${Config.appAuthUrl}/user/update";
|
||||
static String get searchFriendInfo => "${Config.appAuthUrl}/friend/search";
|
||||
static String get getUsersFullInfo => "${Config.appAuthUrl}/user/find/full";
|
||||
static String get searchUserFullInfo =>
|
||||
"${Config.appAuthUrl}/user/search/full";
|
||||
|
||||
static final getVerificationCode = "${Config.appAuthUrl}/account/code/send";
|
||||
static final checkVerificationCode = "${Config.appAuthUrl}/account/code/verify";
|
||||
static final register = "${Config.appAuthUrl}/account/register";
|
||||
static String get getVerificationCode =>
|
||||
"${Config.appAuthUrl}/account/code/send";
|
||||
static String get checkVerificationCode =>
|
||||
"${Config.appAuthUrl}/account/code/verify";
|
||||
static String get register => "${Config.appAuthUrl}/account/register";
|
||||
|
||||
static final resetPwd = "${Config.appAuthUrl}/account/password/reset";
|
||||
static final changePwd = "${Config.appAuthUrl}/account/password/change";
|
||||
static final login = "${Config.appAuthUrl}/account/login";
|
||||
static String get resetPwd => "${Config.appAuthUrl}/account/password/reset";
|
||||
static String get changePwd => "${Config.appAuthUrl}/account/password/change";
|
||||
static String get login => "${Config.appAuthUrl}/account/login";
|
||||
|
||||
static final upgrade = "${Config.appAuthUrl}/app/check";
|
||||
static final getClientConfig = '${Config.appAuthUrl}/client_config/get';
|
||||
static final getTokenForRTC = "${Config.appAuthUrl}/user/rtc/get_token";
|
||||
static String get upgrade => "${Config.appAuthUrl}/app/check";
|
||||
static String get getClientConfig => '${Config.appAuthUrl}/client_config/get';
|
||||
static String get getTokenForRTC => "${Config.appAuthUrl}/user/rtc/get_token";
|
||||
}
|
||||
|
||||
@@ -39,7 +39,12 @@ class HttpUtil {
|
||||
dio.options.receiveTimeout = const Duration(seconds: 30);
|
||||
}
|
||||
|
||||
static String get operationID => DateTime.now().millisecondsSinceEpoch.toString();
|
||||
static void setBaseUrl(String url) {
|
||||
dio.options.baseUrl = url;
|
||||
}
|
||||
|
||||
static String get operationID =>
|
||||
DateTime.now().millisecondsSinceEpoch.toString();
|
||||
|
||||
static Future post(
|
||||
String path, {
|
||||
@@ -103,8 +108,11 @@ class HttpUtil {
|
||||
final bytes = await File(compressPath ?? path).readAsBytes();
|
||||
final mf = MultipartFile.fromBytes(bytes, filename: fileName);
|
||||
|
||||
var formData =
|
||||
FormData.fromMap({'operationID': '${DateTime.now().millisecondsSinceEpoch}', 'fileType': 1, 'file': mf});
|
||||
var formData = FormData.fromMap({
|
||||
'operationID': '${DateTime.now().millisecondsSinceEpoch}',
|
||||
'fileType': 1,
|
||||
'file': mf
|
||||
});
|
||||
|
||||
var resp = await dio.post<Map<String, dynamic>>(
|
||||
"${Config.imApiUrl}/third/minio_upload",
|
||||
@@ -151,12 +159,14 @@ class HttpUtil {
|
||||
onCompletion?.call();
|
||||
intervalDo.drop(
|
||||
fun: () async {
|
||||
saveFileToGallerySaver(File(cachePath), showTaost: EasyLoading.isShow);
|
||||
saveFileToGallerySaver(File(cachePath),
|
||||
showTaost: EasyLoading.isShow);
|
||||
},
|
||||
milliseconds: 1500);
|
||||
}
|
||||
if (count == total) {
|
||||
saveFileToGallerySaver(File(cachePath), showTaost: EasyLoading.isShow);
|
||||
saveFileToGallerySaver(File(cachePath),
|
||||
showTaost: EasyLoading.isShow);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -166,7 +176,8 @@ class HttpUtil {
|
||||
var byteData = await image.toByteData(format: ImageByteFormat.png);
|
||||
if (byteData != null) {
|
||||
Uint8List uint8list = byteData.buffer.asUint8List();
|
||||
var result = await ImageGallerySaverPlus.saveImage(Uint8List.fromList(uint8list));
|
||||
var result =
|
||||
await ImageGallerySaverPlus.saveImage(Uint8List.fromList(uint8list));
|
||||
if (result != null) {
|
||||
var tips = StrRes.saveSuccessfully;
|
||||
if (Platform.isAndroid) {
|
||||
@@ -214,13 +225,15 @@ class HttpUtil {
|
||||
);
|
||||
}
|
||||
|
||||
static Future saveFileToGallerySaver(File file, {String? name, bool showTaost = true}) async {
|
||||
static Future saveFileToGallerySaver(File file,
|
||||
{String? name, bool showTaost = true}) async {
|
||||
Permissions.storage(() async {
|
||||
var tips = StrRes.saveSuccessfully;
|
||||
Logger.print('saveFileToGallerySaver: ${file.path}');
|
||||
final imageBytes = await file.readAsBytes();
|
||||
|
||||
final result = await ImageGallerySaverPlus.saveImage(imageBytes, name: name);
|
||||
final result =
|
||||
await ImageGallerySaverPlus.saveImage(imageBytes, name: name);
|
||||
if (result != null && showTaost) {
|
||||
if (Platform.isAndroid) {
|
||||
final filePath = result['filePath'].split('//').last;
|
||||
|
||||
Reference in New Issue
Block a user