feat: add msix check

This commit is contained in:
22
2025-09-26 20:46:46 +08:00
parent 44e9eb4d65
commit b7876bf10b
3 changed files with 27 additions and 4 deletions

View File

@@ -3,4 +3,5 @@ class INFO {
static const String author = '22';
static const String authorUrl = 'https://github.com/nini22P';
static const String githubUrl = 'https://github.com/nini22P/iris';
static const String msStoreId = '9NML7WNHNRTJ';
}

View File

@@ -10,6 +10,13 @@ import 'package:iris/utils/get_latest_release.dart';
import 'package:iris/utils/get_localizations.dart';
import 'package:iris/utils/url.dart';
bool isPortable() {
String resolvedExecutablePath = Platform.resolvedExecutable;
String path = p.dirname(resolvedExecutablePath);
String batFilePath = p.join(path, 'iris-updater.bat');
return File(batFilePath).existsSync();
}
Future<void> showReleaseDialog(BuildContext context,
{required Release release}) async =>
await showDialog<void>(
@@ -32,10 +39,7 @@ class ReleaseDialog extends HookWidget {
useEffect(() {
if (isWindows) {
String resolvedExecutablePath = Platform.resolvedExecutable;
String path = p.dirname(resolvedExecutablePath);
String batFilePath = p.join(path, 'iris-updater.bat');
updateScriptIsExists.value = File(batFilePath).existsSync();
updateScriptIsExists.value = isPortable();
}
return null;
}, []);

View File

@@ -1,3 +1,6 @@
import 'dart:io';
import 'package:iris/utils/platform.dart';
import 'package:path/path.dart' as p;
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:iris/info.dart';
@@ -7,6 +10,16 @@ import 'package:iris/utils/get_localizations.dart';
import 'package:iris/utils/url.dart';
import 'package:package_info_plus/package_info_plus.dart';
bool isMsix() {
if (!isWindows) {
return false;
}
String resolvedExecutablePath = Platform.resolvedExecutable;
String path = p.dirname(resolvedExecutablePath);
String batFilePath = p.join(path, 'AppxManifest.xml');
return File(batFilePath).existsSync();
}
class About extends HookWidget {
const About({super.key});
@@ -48,6 +61,11 @@ class About extends HookWidget {
title: Text(t.check_update),
subtitle: noNewVersion.value ? Text(t.no_new_version) : null,
onTap: () async {
if (isMsix()) {
launchURL(
'ms-windows-store://pdp/?ProductId=${INFO.msStoreId}');
return;
}
noNewVersion.value = false;
final release = await getLatestRelease();
if (release != null && context.mounted) {