fix:增加使用登陆接口的scdUrl动态设置星图的url
This commit is contained in:
parent
05f9cad8c9
commit
7f0c1fca1d
@ -8,6 +8,7 @@ import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
|
|||||||
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
||||||
import 'package:star_lock/mine/mine/starLockMine_state.dart';
|
import 'package:star_lock/mine/mine/starLockMine_state.dart';
|
||||||
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart';
|
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_entity.dart';
|
||||||
|
import 'package:star_lock/network/start_chart_api.dart';
|
||||||
import 'package:star_lock/talk/starChart/entity/star_chart_register_node_entity.dart';
|
import 'package:star_lock/talk/starChart/entity/star_chart_register_node_entity.dart';
|
||||||
import 'package:star_lock/tools/baseGetXController.dart';
|
import 'package:star_lock/tools/baseGetXController.dart';
|
||||||
|
|
||||||
@ -61,6 +62,13 @@ class StarLockLoginLogic extends BaseGetXController {
|
|||||||
//如已有星图配置则保存 无需重复注册节点及重复绑定
|
//如已有星图配置则保存 无需重复注册节点及重复绑定
|
||||||
if (entity.data!.starchart != null) {
|
if (entity.data!.starchart != null) {
|
||||||
final Starchart starChart = entity.data!.starchart!;
|
final Starchart starChart = entity.data!.starchart!;
|
||||||
|
// 获取星图url
|
||||||
|
if (starChart != null &&
|
||||||
|
starChart.scdUrl != null &&
|
||||||
|
starChart.scdUrl != '') {
|
||||||
|
StartChartApi.to.startChartHost =
|
||||||
|
starChart!.scdUrl ?? StartChartApi.to.startChartHost;
|
||||||
|
}
|
||||||
final StarChartRegisterNodeEntity starChartRegisterNodeEntity =
|
final StarChartRegisterNodeEntity starChartRegisterNodeEntity =
|
||||||
StarChartRegisterNodeEntity(
|
StarChartRegisterNodeEntity(
|
||||||
peer: PeerData(
|
peer: PeerData(
|
||||||
|
|||||||
@ -148,16 +148,18 @@ class GoogleHome {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Starchart {
|
class Starchart {
|
||||||
|
String? scdUrl;
|
||||||
String? starchartId;
|
String? starchartId;
|
||||||
String? starchartPeerPublicKey;
|
String? starchartPeerPublicKey;
|
||||||
String? starchartPeerPrivateKey;
|
String? starchartPeerPrivateKey;
|
||||||
|
|
||||||
Starchart(
|
Starchart(
|
||||||
{this.starchartId,
|
{this.scdUrl,this.starchartId,
|
||||||
this.starchartPeerPublicKey,
|
this.starchartPeerPublicKey,
|
||||||
this.starchartPeerPrivateKey});
|
this.starchartPeerPrivateKey});
|
||||||
|
|
||||||
Starchart.fromJson(Map<String, dynamic> json) {
|
Starchart.fromJson(Map<String, dynamic> json) {
|
||||||
|
scdUrl = json['scdUrl'];
|
||||||
starchartId = json['starchartId'];
|
starchartId = json['starchartId'];
|
||||||
starchartPeerPublicKey = json['starchartPeerPublicKey'];
|
starchartPeerPublicKey = json['starchartPeerPublicKey'];
|
||||||
starchartPeerPrivateKey = json['starchartPeerPrivateKey'];
|
starchartPeerPrivateKey = json['starchartPeerPrivateKey'];
|
||||||
@ -165,6 +167,7 @@ class Starchart {
|
|||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final Map<String, dynamic> data = Map<String, dynamic>();
|
final Map<String, dynamic> data = Map<String, dynamic>();
|
||||||
|
data['scdUrl'] = this.scdUrl;
|
||||||
data['starchartId'] = this.starchartId;
|
data['starchartId'] = this.starchartId;
|
||||||
data['starchartPeerPublicKey'] = this.starchartPeerPublicKey;
|
data['starchartPeerPublicKey'] = this.starchartPeerPublicKey;
|
||||||
data['starchartPeerPrivateKey'] = this.starchartPeerPrivateKey;
|
data['starchartPeerPrivateKey'] = this.starchartPeerPrivateKey;
|
||||||
|
|||||||
@ -9,10 +9,18 @@ import 'package:star_lock/talk/starChart/entity/star_chart_register_node_entity.
|
|||||||
|
|
||||||
class StartChartApi extends BaseProvider {
|
class StartChartApi extends BaseProvider {
|
||||||
// 星图url
|
// 星图url
|
||||||
final String _startChartHost = 'http://sls1-scd.star-lock.cn:8080';
|
String _startChartHost = 'http://sls1-scd.star-lock.cn:8080';
|
||||||
|
|
||||||
static StartChartApi get to => Get.put(StartChartApi());
|
static StartChartApi get to => Get.put(StartChartApi());
|
||||||
|
|
||||||
|
// 设置星图host
|
||||||
|
set startChartHost(String value) {
|
||||||
|
_startChartHost = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取星图host
|
||||||
|
String get startChartHost => _startChartHost;
|
||||||
|
|
||||||
// 星图--注册节点
|
// 星图--注册节点
|
||||||
Future<StarChartRegisterNodeEntity> starChartRegisterNode({
|
Future<StarChartRegisterNodeEntity> starChartRegisterNode({
|
||||||
required String product,
|
required String product,
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:star_lock/network/start_chart_api.dart';
|
||||||
import 'package:star_lock/talk/starChart/star_chart_manage.dart';
|
import 'package:star_lock/talk/starChart/star_chart_manage.dart';
|
||||||
|
import 'package:star_lock/tools/storage.dart';
|
||||||
|
|
||||||
class AppLifecycleObserver extends WidgetsBindingObserver {
|
class AppLifecycleObserver extends WidgetsBindingObserver {
|
||||||
@override
|
@override
|
||||||
@ -28,9 +30,19 @@ class AppLifecycleObserver extends WidgetsBindingObserver {
|
|||||||
StartChartManage().destruction();
|
StartChartManage().destruction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAppResumed() {
|
void onAppResumed() async {
|
||||||
// 处理应用程序恢复到前台的逻辑
|
// 处理应用程序恢复到前台的逻辑
|
||||||
StartChartManage().init();
|
StartChartManage().init();
|
||||||
|
final loginData = await Storage.getLoginData();
|
||||||
|
|
||||||
|
// 获取星图url
|
||||||
|
if (loginData != null &&
|
||||||
|
loginData?.starchart != null &&
|
||||||
|
loginData?.starchart?.scdUrl != null &&
|
||||||
|
loginData?.starchart?.scdUrl != '') {
|
||||||
|
StartChartApi.to.startChartHost =
|
||||||
|
loginData!.starchart!.scdUrl ?? StartChartApi.to.startChartHost;
|
||||||
|
}
|
||||||
print('App has resumed to the foreground.');
|
print('App has resumed to the foreground.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user