mirror of
https://github.com/qinglong-app/qinglong_app.git
synced 2025-10-09 16:48:19 +08:00
适配新版本api
This commit is contained in:
2
lib/module/env/env_page.dart
vendored
2
lib/module/env/env_page.dart
vendored
@@ -152,7 +152,7 @@ class EnvItemCell extends StatelessWidget {
|
||||
Navigator.of(context).pushNamed(Routes.routeAddEnv, arguments: bean);
|
||||
},
|
||||
foregroundColor: Colors.white,
|
||||
icon: CupertinoIcons.pencil,
|
||||
icon: CupertinoIcons.pencil_outline,
|
||||
),
|
||||
SlidableAction(
|
||||
backgroundColor: Colors.orange,
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:qinglong_app/base/http/api.dart';
|
||||
import 'package:qinglong_app/base/ql_app_bar.dart';
|
||||
import 'package:qinglong_app/base/routes.dart';
|
||||
import 'package:qinglong_app/module/config/config_page.dart';
|
||||
import 'package:qinglong_app/module/env/env_page.dart';
|
||||
import 'package:qinglong_app/module/home/system_bean.dart';
|
||||
import 'package:qinglong_app/module/others/other_page.dart';
|
||||
import 'package:qinglong_app/module/task/task_page.dart';
|
||||
import 'package:move_to_background/move_to_background.dart';
|
||||
import 'package:qinglong_app/utils/update_utils.dart';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import '../../utils/utils.dart';
|
||||
|
||||
class HomePage extends ConsumerStatefulWidget {
|
||||
const HomePage({Key? key}) : super(key: key);
|
||||
|
||||
@@ -18,7 +24,8 @@ class HomePage extends ConsumerStatefulWidget {
|
||||
_HomePageState createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends ConsumerState<HomePage> with TickerProviderStateMixin {
|
||||
class _HomePageState extends ConsumerState<HomePage>
|
||||
with TickerProviderStateMixin {
|
||||
int _index = 0;
|
||||
String _title = "";
|
||||
bool isNewYear = false;
|
||||
@@ -41,6 +48,7 @@ class _HomePageState extends ConsumerState<HomePage> with TickerProviderStateMix
|
||||
super.initState();
|
||||
WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
|
||||
update();
|
||||
getSystemBean();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -238,7 +246,8 @@ class _HomePageState extends ConsumerState<HomePage> with TickerProviderStateMix
|
||||
void update() async {
|
||||
String? result = await UpdateUtils().checkUpdate();
|
||||
if (result != null && result.isNotEmpty) {
|
||||
UpdateDialog updateDialog = UpdateDialog(context, title: "发现新版本", updateContent: "版本号:v$result", onUpdate: () {
|
||||
UpdateDialog updateDialog = UpdateDialog(context,
|
||||
title: "发现新版本", updateContent: "版本号:v$result", onUpdate: () {
|
||||
UpdateUtils.launchURL(result);
|
||||
});
|
||||
updateDialog.show();
|
||||
@@ -256,6 +265,13 @@ class _HomePageState extends ConsumerState<HomePage> with TickerProviderStateMix
|
||||
isNewYear = false;
|
||||
}
|
||||
}
|
||||
|
||||
void getSystemBean() async {
|
||||
var bean = await Api.system();
|
||||
if (bean.success) {
|
||||
Utils.systemBean.version = bean.bean?.version ?? "2.10.13";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class IndexBean {
|
||||
|
||||
23
lib/module/home/system_bean.dart
Normal file
23
lib/module/home/system_bean.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
import 'package:json_conversion_annotation/json_conversion_annotation.dart';
|
||||
|
||||
@JsonConversion()
|
||||
class SystemBean {
|
||||
String? version;
|
||||
|
||||
SystemBean({this.version});
|
||||
|
||||
SystemBean.fromJson(Map<String, dynamic> json) {
|
||||
version = json['version'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['version'] = this.version;
|
||||
return data;
|
||||
}
|
||||
|
||||
static SystemBean jsonConversion(Map<String, dynamic> json) {
|
||||
return SystemBean.fromJson(json);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user