Add sub link share
This commit is contained in:
@@ -69,6 +69,8 @@
|
||||
},
|
||||
"share": {
|
||||
"buttonText": "Share",
|
||||
"exportToClipboardSuccess": "Exported to clipboard",
|
||||
"exportSubLinkToClipboard": "Export subscription link to clipboard",
|
||||
"exportConfigToClipboard": "Export configuration to clipboard",
|
||||
"exportConfigToClipboardSuccess": "Configuration copied to clipboard"
|
||||
},
|
||||
|
||||
@@ -69,6 +69,8 @@
|
||||
},
|
||||
"share": {
|
||||
"buttonText": "اشتراک گذاری",
|
||||
"exportToClipboardSuccess": "به کلیپ بورد اضافه شد",
|
||||
"exportSubLinkToClipboard": "افزودن لینک اشتراک به کلیپ بورد",
|
||||
"exportConfigToClipboard": "افزودن پیکربندی به کلیپ بورد",
|
||||
"exportConfigToClipboardSuccess": "پیکربندی در کلیپ بورد کپی شد"
|
||||
},
|
||||
|
||||
@@ -69,6 +69,8 @@
|
||||
},
|
||||
"share": {
|
||||
"buttonText": "Делиться",
|
||||
"exportToClipboardSuccess": "Экспортировано в буфер обмена",
|
||||
"exportSubLinkToClipboard": "Экспортировать ссылку на подписку в буфер обмена",
|
||||
"exportConfigToClipboard": "Экспортировать конфигурацию в буфер обмена",
|
||||
"exportConfigToClipboardSuccess": "Конфигурация скопирована в буфер обмена."
|
||||
},
|
||||
|
||||
@@ -69,6 +69,8 @@
|
||||
},
|
||||
"share": {
|
||||
"buttonText": "分享",
|
||||
"exportToClipboardSuccess": "导出到剪贴板",
|
||||
"exportSubLinkToClipboard": "将订阅链接导出到剪贴板",
|
||||
"exportConfigToClipboard": "将配置导出到剪贴板",
|
||||
"exportConfigToClipboardSuccess": "配置已复制到剪贴板"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hiddify/core/core_providers.dart';
|
||||
@@ -288,6 +289,20 @@ class ProfileActionsMenu extends HookConsumerWidget {
|
||||
),
|
||||
SubmenuButton(
|
||||
menuChildren: [
|
||||
if (profile case RemoteProfile(:final url, :final name))
|
||||
MenuItemButton(
|
||||
child: Text(t.profile.share.exportSubLinkToClipboard),
|
||||
onPressed: () async {
|
||||
final link = LinkParser.generateSubShareLink(url, name);
|
||||
if (link.isNotEmpty) {
|
||||
await Clipboard.setData(ClipboardData(text: link));
|
||||
if (context.mounted) {
|
||||
CustomToast(t.profile.share.exportToClipboardSuccess)
|
||||
.show(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
MenuItemButton(
|
||||
child: Text(t.profile.share.exportConfigToClipboard),
|
||||
onPressed: () async {
|
||||
|
||||
@@ -7,6 +7,19 @@ typedef ProfileLink = ({String url, String name});
|
||||
|
||||
// TODO: test and improve
|
||||
abstract class LinkParser {
|
||||
static String generateSubShareLink(String url, [String? name]) {
|
||||
final uri = Uri.tryParse(url);
|
||||
if (uri == null) return '';
|
||||
return Uri(
|
||||
scheme: 'hiddify',
|
||||
host: 'install-sub',
|
||||
queryParameters: {
|
||||
"url": uri.toString(),
|
||||
if (name != null) "name": name,
|
||||
},
|
||||
).toString();
|
||||
}
|
||||
|
||||
// protocols schemas
|
||||
static const protocols = {'clash', 'clashmeta', 'sing-box', 'hiddify'};
|
||||
static const rawProtocols = {
|
||||
|
||||
Reference in New Issue
Block a user