更新接口

pull/1/head
戴余标 3 years ago
parent 66d67f0996
commit 5889e88d4c

@ -44,6 +44,7 @@ class SAASAPI {
static _Vote vote = _Vote();
static _Facilities facilities = _Facilities();
static _Bracelet bracelet = _Bracelet();
static _Updater updater = _Updater();
///
static _ProfileApi profile = _ProfileApi();
@ -439,3 +440,10 @@ class _Facilities {
///
String get cancel => '/app/user/facilities/cancel';
}
class _Updater{
///app
String get findNewVersion => '/app/version/findNewVersion';
///app
String get insert => '/app/version/insert';
}

@ -1,5 +1,4 @@
import 'package:aku_new_community/provider/old_age_provider.dart';
import 'package:aku_new_community/utils/updater_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

@ -18,6 +18,7 @@ import 'package:aku_new_community/utils/websocket/web_socket_util.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
import 'account_manager_page.dart';
import 'feedback_page/feedback_page.dart';
class SettingsPage extends StatefulWidget {

@ -15,7 +15,6 @@ import 'package:aku_new_community/ui/market/market_page.dart';
import 'package:aku_new_community/utils/websocket/web_socket_util.dart';
import 'package:aku_new_community/widget/bee_scaffold.dart';
import 'package:aku_new_community/widget/others/user_tool.dart';
import '../utils/updater_page.dart';
import 'home/home_page.dart';
import 'opening_code_page/opening_code_page.dart';
import 'personal/personal_page.dart';
@ -191,7 +190,7 @@ class _TabNavigatorState extends State<TabNavigator>
4,
),
];
return UpdaterPage(
return
BeeScaffold(
body: WillPopScope(
onWillPop: () async {
@ -227,7 +226,6 @@ class _TabNavigatorState extends State<TabNavigator>
),
),
),
)
);
}

@ -0,0 +1,28 @@
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
part 'updater_model.g.dart';
@JsonSerializable()
class UpdaterModel extends Equatable{
final int id;
final String versionNumber;
final String buildNo;
final int forceUpdate;
final String createDate;
factory UpdaterModel.fromJson(Map<String, dynamic> json) =>_$UpdaterModelFromJson(json);
const UpdaterModel({
required this.id,
required this.versionNumber,
required this.buildNo,
required this.forceUpdate,
required this.createDate,
});
@override
List<Object?> get props => [
id,versionNumber,buildNo,forceUpdate,createDate,
];
}

@ -0,0 +1,15 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'updater_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
UpdaterModel _$UpdaterModelFromJson(Map<String, dynamic> json) => UpdaterModel(
id: json['id'] as int,
versionNumber: json['versionNumber'] as String,
buildNo: json['buildNo'] as String,
forceUpdate: json['forceUpdate'] as int,
createDate: json['createDate'] as String,
);

@ -1,15 +1,17 @@
import 'package:aku_new_community/utils/updater/updater_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:package_info/package_info.dart';
import 'package:dio/dio.dart';
import 'package:sp_util/sp_util.dart';
import 'package:url_launcher/url_launcher.dart';
import 'constants.dart';
import 'data_util.dart';
import '../../constants/saas_api.dart';
import '../constants.dart';
import '../data_util.dart';
import '../network/net_util.dart';
class UpdaterPage extends StatefulWidget {
final Widget child;
const UpdaterPage(this.child);
@override
@ -17,6 +19,7 @@ class UpdaterPage extends StatefulWidget {
}
class UpdatePagerState extends State<UpdaterPage> {
UpdaterModel? _model;
var _serviceVersionCode,
_serviceVersionName,
_serviceVersionPlatform,
@ -42,19 +45,13 @@ class UpdatePagerState extends State<UpdaterPage> {
//
_getNewVersionAPP() async {
String url = "/appversions/latest"; //URLURL
try {
Response response = await Dio().get(url);
setState(() {
var data = response.data;
_serviceVersionCode = data["versionCode"].toString(); //
_serviceVersionName = data["versionName"].toString(); //
_serviceVersionPlatform = data["versionPlatform"].toString(); //
_serviceVersionApp = data["versionApp"].toString(); //URL
_checkVersionCode();
var base =
await NetUtil().get(SAASAPI.updater.findNewVersion, params: {
'version': '1.8.12',
});
} catch (e) {
print(e);
if (base.success) {
_model = UpdaterModel.fromJson(base.data);
setState(() {});
}
_checkVersionCode();
}
Loading…
Cancel
Save