mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 12:57:24 +00:00
add retry
This commit is contained in:
@@ -162,7 +162,10 @@
|
|||||||
"Current quantity": "当前数量",
|
"Current quantity": "当前数量",
|
||||||
"Display the original image on the details page": "在详情页显示原图",
|
"Display the original image on the details page": "在详情页显示原图",
|
||||||
"Open link": "打开链接",
|
"Open link": "打开链接",
|
||||||
"Read": "阅读"
|
"Read": "阅读",
|
||||||
|
"Error": "错误",
|
||||||
|
"Failed to register URL scheme.": "注册URL协议失败",
|
||||||
|
"Retry": "重试"
|
||||||
},
|
},
|
||||||
"zh_TW": {
|
"zh_TW": {
|
||||||
"Search": "搜索",
|
"Search": "搜索",
|
||||||
@@ -327,6 +330,9 @@
|
|||||||
"Current quantity": "當前數量",
|
"Current quantity": "當前數量",
|
||||||
"Display the original image on the details page": "在詳情頁顯示原圖",
|
"Display the original image on the details page": "在詳情頁顯示原圖",
|
||||||
"Open link": "打開鏈接",
|
"Open link": "打開鏈接",
|
||||||
"Read": "閱讀"
|
"Read": "閱讀",
|
||||||
|
"Error": "錯誤",
|
||||||
|
"Failed to register URL scheme.": "註冊URL協議失敗",
|
||||||
|
"Retry": "重試"
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:app_links/app_links.dart';
|
import 'package:app_links/app_links.dart';
|
||||||
|
import 'package:fluent_ui/fluent_ui.dart';
|
||||||
import 'package:pixes/foundation/app.dart';
|
import 'package:pixes/foundation/app.dart';
|
||||||
import 'package:pixes/foundation/log.dart';
|
import 'package:pixes/foundation/log.dart';
|
||||||
import 'package:pixes/pages/illust_page.dart';
|
import 'package:pixes/pages/illust_page.dart';
|
||||||
@@ -8,6 +9,7 @@ import 'package:pixes/pages/novel_page.dart';
|
|||||||
import 'package:pixes/pages/search_page.dart';
|
import 'package:pixes/pages/search_page.dart';
|
||||||
import 'package:pixes/pages/user_info_page.dart';
|
import 'package:pixes/pages/user_info_page.dart';
|
||||||
import 'package:pixes/utils/ext.dart';
|
import 'package:pixes/utils/ext.dart';
|
||||||
|
import 'package:pixes/utils/translation.dart';
|
||||||
import 'package:win32_registry/win32_registry.dart';
|
import 'package:win32_registry/win32_registry.dart';
|
||||||
|
|
||||||
Future<void> _register(String scheme) async {
|
Future<void> _register(String scheme) async {
|
||||||
@@ -31,13 +33,40 @@ Future<void> _register(String scheme) async {
|
|||||||
regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue);
|
regKey.createKey(protocolCmdRegKey).createValue(protocolCmdRegValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _registerPixiv() async {
|
||||||
|
try {
|
||||||
|
await _register("pixiv");
|
||||||
|
} catch (e) {
|
||||||
|
// 注册失败会导致登录不可用
|
||||||
|
while (App.mainNavigatorKey == null) {
|
||||||
|
await Future.delayed(const Duration(milliseconds: 100));
|
||||||
|
}
|
||||||
|
Future.delayed(const Duration(seconds: 1), () async {
|
||||||
|
showDialog(
|
||||||
|
context: App.rootNavigatorKey.currentContext!,
|
||||||
|
builder: (context) => ContentDialog(
|
||||||
|
title: Text("Error".tl),
|
||||||
|
content: Text("${"Failed to register URL scheme.".tl}\n$e"),
|
||||||
|
actions: [
|
||||||
|
FilledButton(
|
||||||
|
child: Text("Retry".tl),
|
||||||
|
onPressed: () {
|
||||||
|
context.pop();
|
||||||
|
_registerPixiv();
|
||||||
|
})
|
||||||
|
],
|
||||||
|
));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Function(Uri uri)? onLink;
|
bool Function(Uri uri)? onLink;
|
||||||
|
|
||||||
bool _firstLink = true;
|
bool _firstLink = true;
|
||||||
|
|
||||||
void handleLinks() async {
|
void handleLinks() async {
|
||||||
if (App.isWindows) {
|
if (App.isWindows) {
|
||||||
await _register("pixiv");
|
_registerPixiv();
|
||||||
}
|
}
|
||||||
AppLinks().uriLinkStream.listen((uri) async {
|
AppLinks().uriLinkStream.listen((uri) async {
|
||||||
if (_firstLink) {
|
if (_firstLink) {
|
||||||
|
Reference in New Issue
Block a user