Commit b3e0e504 by tanghuan

启动备用端口时,跟端口相关的值需要重新设置

1 parent 3de75121
......@@ -12,13 +12,13 @@ class Constant {
static int localServerPort = 35982;
static const localServerPortOption = [35982, 35983, 35984];
static final String localServerUrl = 'http://$localServerHost:$localServerPort';
static String localServerUrl = 'http://$localServerHost:$localServerPort';
static final String localFileUrl = 'http://127.0.0.1:$localServerPort';
static String localFileUrl = 'http://127.0.0.1:$localServerPort';
static const String localServerTemp = '/temp';
static final String localServerTempFileUrl = '$localFileUrl$localServerTemp';
static String localServerTempFileUrl = '$localFileUrl$localServerTemp';
static const String localServerTest = '/test';
static final String localServerTestFileUrl = '$localFileUrl$localServerTest';
static String localServerTestFileUrl = '$localFileUrl$localServerTest';
/// obs 相关
/// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -24,6 +24,12 @@ class LocalServerService {
try {
server = await HttpServer.bind(InternetAddress.loopbackIPv4, Constant.localServerPortOption[i]);
Constant.localServerPort = server.port;
// 端口改变之后,相应改变其它关联用到端口的值
Constant.localServerUrl = 'http://${Constant.localServerHost}:${Constant.localServerPort}';
Constant.localFileUrl = 'http://127.0.0.1:${Constant.localServerPort}';
Constant.localServerTempFileUrl = '${Constant.localFileUrl}${Constant.localServerTemp}';
Constant.localServerTestFileUrl = '${Constant.localFileUrl}${Constant.localServerTest}';
print('本地服务器启动在端口: ${server.port}');
break;
} on SocketException catch (e) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!