mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
new: win/linux update
This commit is contained in:
@@ -3,7 +3,6 @@ import 'dart:io';
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:r_upgrade/r_upgrade.dart';
|
import 'package:r_upgrade/r_upgrade.dart';
|
||||||
import 'package:toolbox/core/extension/context/common.dart';
|
|
||||||
import 'package:toolbox/core/extension/context/dialog.dart';
|
import 'package:toolbox/core/extension/context/dialog.dart';
|
||||||
import 'package:toolbox/core/extension/context/locale.dart';
|
import 'package:toolbox/core/extension/context/locale.dart';
|
||||||
import 'package:toolbox/core/extension/context/snackbar.dart';
|
import 'package:toolbox/core/extension/context/snackbar.dart';
|
||||||
@@ -78,25 +77,18 @@ Future<void> doUpdate(BuildContext context, {bool force = false}) async {
|
|||||||
|
|
||||||
Future<void> _doUpdate(AppUpdate update, BuildContext context) async {
|
Future<void> _doUpdate(AppUpdate update, BuildContext context) async {
|
||||||
final url = update.url.current;
|
final url = update.url.current;
|
||||||
if (url == null) return;
|
if (url == null) {
|
||||||
|
Loggers.app.warning('Update url not is null');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isAndroid) {
|
if (isAndroid) {
|
||||||
final fileName = url.split('/').last;
|
final fileName = url.split('/').last;
|
||||||
await RUpgrade.upgrade(url, fileName: fileName);
|
await RUpgrade.upgrade(url, fileName: fileName);
|
||||||
} else if (isIOS) {
|
} else if (isIOS) {
|
||||||
await RUpgrade.upgradeFromAppStore('1586449703');
|
await RUpgrade.upgradeFromAppStore('1586449703');
|
||||||
} else if (isMacOS) {
|
|
||||||
await openUrl(url);
|
|
||||||
} else {
|
} else {
|
||||||
context.showRoundDialog(
|
await openUrl(url);
|
||||||
child: Text(l10n.platformNotSupportUpdate),
|
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => context.pop(),
|
|
||||||
child: Text(l10n.ok),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,11 +87,15 @@ class AppUpdatePlatformSpecific<T> {
|
|||||||
required this.mac,
|
required this.mac,
|
||||||
required this.ios,
|
required this.ios,
|
||||||
required this.android,
|
required this.android,
|
||||||
|
required this.windows,
|
||||||
|
required this.linux,
|
||||||
});
|
});
|
||||||
|
|
||||||
final T mac;
|
final T mac;
|
||||||
final T ios;
|
final T ios;
|
||||||
final T android;
|
final T android;
|
||||||
|
final T windows;
|
||||||
|
final T linux;
|
||||||
|
|
||||||
factory AppUpdatePlatformSpecific.fromRawJson(String str) =>
|
factory AppUpdatePlatformSpecific.fromRawJson(String str) =>
|
||||||
AppUpdatePlatformSpecific.fromJson(json.decode(str));
|
AppUpdatePlatformSpecific.fromJson(json.decode(str));
|
||||||
@@ -103,12 +107,16 @@ class AppUpdatePlatformSpecific<T> {
|
|||||||
mac: json["mac"],
|
mac: json["mac"],
|
||||||
ios: json["ios"],
|
ios: json["ios"],
|
||||||
android: json["android"],
|
android: json["android"],
|
||||||
|
windows: json["windows"],
|
||||||
|
linux: json["linux"],
|
||||||
);
|
);
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() => {
|
||||||
"mac": mac,
|
"mac": mac,
|
||||||
"ios": ios,
|
"ios": ios,
|
||||||
"android": android,
|
"android": android,
|
||||||
|
"windows": windows,
|
||||||
|
"linux": linux,
|
||||||
};
|
};
|
||||||
|
|
||||||
T? get current {
|
T? get current {
|
||||||
@@ -119,7 +127,15 @@ class AppUpdatePlatformSpecific<T> {
|
|||||||
return ios;
|
return ios;
|
||||||
case OS.android:
|
case OS.android:
|
||||||
return android;
|
return android;
|
||||||
default:
|
case OS.windows:
|
||||||
|
return windows;
|
||||||
|
case OS.linux:
|
||||||
|
return linux;
|
||||||
|
|
||||||
|
/// Not implemented yet.
|
||||||
|
case OS.web:
|
||||||
|
case OS.fuchsia:
|
||||||
|
case OS.unknown:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user