Skip to content

Commit d42d28d

Browse files
committed
优化
1 parent 794be44 commit d42d28d

32 files changed

+271
-32
lines changed

build-dmg.sh

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
#!/bin/sh
2-
create-dmg \
3-
--volname "Application Installer" \
4-
--volicon "build/macos/Build/Products/Release/TubeSavely.app/Contents/Resources/AppIcon.icns" \
5-
--background "assets/images/ic_feedback.png" \
6-
--window-pos 200 120 \
7-
--window-size 800 400 \
8-
--icon-size 100 \
9-
--icon "assets/ic_logo.png" 200 190 \
10-
--hide-extension "TubeSavely.app" \
11-
--app-drop-link 600 185 \
12-
"build/macos/TubeSavely.dmg" \
13-
"build/macos/Build/Products/Release/TubeSavely.app"
14-
#"Application-Installer.dmg"是.dmg文件名称。
15-
#"source_folder/"是"flutter build macos --release"结果路径,如:/工程目录/build/macos/Build/Products/Release/xxx.app
2+
# 检查是否存在 Application-Installer.dmg 文件,如果存在则删除
3+
#if [ -f Application-Installer.dmg ]; then
4+
# rm Application-Installer.dmg
5+
#fi
6+
#
7+
#test -f Application-Installer.dmg && rm Application-Installer.dmg
8+
#create-dmg \
9+
# --volname "Application Installer" \
10+
# --volicon "build/macos/Build/Products/Release/TubeSavely.app/Contents/Resources/AppIcon.icns" \
11+
# --background "assets/images/ic_feedback.png" \
12+
# --window-pos 200 120 \
13+
# --window-size 800 400 \
14+
# --icon-size 100 \
15+
# --icon "assets/ic_logo_small.png" 200 190 \
16+
# --hide-extension "TubeSavely.app" \
17+
# --app-drop-link 600 185 \
18+
# "build/macos/TubeSavely.dmg" \
19+
# "build/macos/Build/Products/Release/TubeSavely.app"
1620

17-
18-
#hdiutil create -srcfolder build/macos/Build/Products/Release/TubeSavely.app TubeSavely.dmg
19-
#hdiutil convert TubeSavely.dmg -format UDBZ -o Compressed_TubeSavely.dmg
21+
hdiutil create -srcfolder build/macos/Build/Products/Release/TubeSavely.app TubeSavely.dmg
22+
hdiutil convert TubeSavely.dmg -format UDBZ -o Compressed_TubeSavely.dmg

lib/core/downloader/downloader.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ import 'package:tubesavely/utils/toast_util.dart';
1616

1717
class Downloader {
1818
static Future<String> get baseOutputPath async =>
19-
Storage().getString(StorageKeys.CACHE_DIR_KEY) ?? (await getTemporaryDirectory()).path;
19+
Storage().getString(StorageKeys.CACHE_DIR_KEY) ??
20+
(await getDownloadsDirectory())?.path ??
21+
(await getApplicationCacheDirectory()).path;
2022

2123
static start(String videoUrl, String fileName,
2224
{String? audioUrl,

lib/screen/desktop/pages/convert_page.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import 'package:tubesavely/core/ffmpeg/ffmpeg_executor.dart';
88
import 'package:tubesavely/generated/l10n.dart';
99
import 'package:tubesavely/model/emuns.dart';
1010
import 'package:tubesavely/storage/storage.dart';
11-
import 'package:tubesavely/utils/platform_util.dart';
12-
import 'package:url_launcher/url_launcher_string.dart';
11+
import 'package:tubesavely/utils/common_util.dart';
1312

1413
class ConvertPage extends StatefulWidget {
1514
const ConvertPage({super.key});
@@ -225,7 +224,7 @@ class _ConvertPageState extends State<ConvertPage> with AutomaticKeepAliveClient
225224
)),
226225
IconButton(
227226
onPressed: () async {
228-
launchUrlString(Uri.file((await Converter.baseOutputPath ?? ''), windows: PlatformUtil.isWindows).toString());
227+
CommonUtil.openDesktopDirectory((await Converter.baseOutputPath ?? ''));
229228
},
230229
icon: const Icon(
231230
Icons.folder_open,

lib/screen/desktop/pages/download_page.dart

+3-6
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import 'package:tubesavely/model/emuns.dart';
99
import 'package:tubesavely/model/pair.dart';
1010
import 'package:tubesavely/model/video_model.dart';
1111
import 'package:tubesavely/storage/storage.dart';
12+
import 'package:tubesavely/utils/common_util.dart';
1213
import 'package:tubesavely/utils/constants.dart';
13-
import 'package:tubesavely/utils/platform_util.dart';
1414
import 'package:tubesavely/utils/resolution_util.dart';
1515
import 'package:tubesavely/utils/toast_util.dart';
16-
import 'package:url_launcher/url_launcher_string.dart';
1716

1817
class DownloadPage extends StatefulWidget {
1918
const DownloadPage({super.key});
@@ -290,10 +289,8 @@ class _DownloadPageState extends State<DownloadPage> with AutomaticKeepAliveClie
290289
color: Theme.of(context).primaryColor.withOpacity(0.8),
291290
)),
292291
IconButton(
293-
onPressed: () {
294-
launchUrlString(
295-
Uri.file(Storage().getString(StorageKeys.CACHE_DIR_KEY) ?? '', windows: PlatformUtil.isWindows)
296-
.toString());
292+
onPressed: () async {
293+
CommonUtil.openDesktopDirectory(Storage().getString(StorageKeys.CACHE_DIR_KEY) ?? '');
297294
},
298295
icon: const Icon(
299296
Icons.folder_open,

lib/utils/common_util.dart

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import 'dart:io';
2+
3+
import 'package:flutter/widgets.dart';
4+
import 'package:url_launcher/url_launcher_string.dart';
5+
16
class CommonUtil {
27
static String formatSize(num bytes, {int fractionDigits = 2}) {
38
if (bytes <= 0.0) return '';
@@ -20,4 +25,28 @@ class CommonUtil {
2025
}
2126
return '${result.toStringAsFixed(fractionDigits)} $suffix';
2227
}
28+
29+
static void openDesktopDirectory(String path) async {
30+
if (Platform.isMacOS) {
31+
_open('open', ['-R', path.padRight(path.length + 1, path)]);
32+
} else if (Platform.isWindows) {
33+
_open('explorer', [path]);
34+
} else if (Platform.isLinux) {
35+
_open('xdg-open', [path]);
36+
} else {
37+
print('Platform not supported');
38+
launchUrlString(Uri.file((path), windows: Platform.isWindows).toString());
39+
}
40+
}
41+
42+
static void _open(String cmd, List<String> args) {
43+
Process.run(cmd, args).then((ProcessResult result) {
44+
if (result.exitCode == 0) {
45+
debugPrint('Directory opened successfully');
46+
} else {
47+
debugPrint(result.stderr);
48+
launchUrlString(Uri.file((args.last), windows: Platform.isWindows).toString());
49+
}
50+
});
51+
}
2352
}

macos/Runner.xcodeproj/project.pbxproj

+9-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@
8484
72F6BF96B6EDAAA808920461 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8585
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
8686
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
87+
A48D12652C495E0D00EFC2BA /* RunnerProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RunnerProfile.entitlements; sourceTree = "<group>"; };
88+
A48D12662C495E9F00EFC2BA /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/MainMenu.strings"; sourceTree = "<group>"; };
8789
A4CF3B002C294F7800DC7DE6 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/MainMenu.strings; sourceTree = "<group>"; };
8890
A4CF3B012C294F8200DC7DE6 /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/MainMenu.strings; sourceTree = "<group>"; };
8991
BE576A6D7B7AF05A21206F49 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
@@ -177,6 +179,7 @@
177179
33FAB671232836740065AC1E /* Runner */ = {
178180
isa = PBXGroup;
179181
children = (
182+
A48D12652C495E0D00EFC2BA /* RunnerProfile.entitlements */,
180183
33CC10F02044A3C60003C045 /* AppDelegate.swift */,
181184
33CC11122044BFA00003C045 /* MainFlutterWindow.swift */,
182185
33E51913231747F40026EE4D /* DebugProfile.entitlements */,
@@ -292,6 +295,7 @@
292295
Base,
293296
ja,
294297
ko,
298+
"zh-Hans",
295299
);
296300
mainGroup = 33CC10E42044A3C60003C045;
297301
productRefGroup = 33CC10EE2044A3C60003C045 /* Products */;
@@ -467,6 +471,7 @@
467471
33CC10F52044A3C60003C045 /* Base */,
468472
A4CF3B002C294F7800DC7DE6 /* ja */,
469473
A4CF3B012C294F8200DC7DE6 /* ko */,
474+
A48D12662C495E9F00EFC2BA /* zh-Hans */,
470475
);
471476
name = MainMenu.xib;
472477
path = Runner;
@@ -573,13 +578,14 @@
573578
buildSettings = {
574579
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
575580
CLANG_ENABLE_MODULES = YES;
576-
CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
581+
CODE_SIGN_ENTITLEMENTS = Runner/RunnerProfile.entitlements;
577582
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
578583
CODE_SIGN_STYLE = Automatic;
579584
COMBINE_HIDPI_IMAGES = YES;
580585
CURRENT_PROJECT_VERSION = 1.0.1;
581586
DEVELOPMENT_TEAM = 3A5JW5BD39;
582587
INFOPLIST_FILE = Runner/Info.plist;
588+
INFOPLIST_KEY_CFBundleDisplayName = TubeSavely;
583589
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.video";
584590
LD_RUNPATH_SEARCH_PATHS = (
585591
"$(inherited)",
@@ -714,6 +720,7 @@
714720
CURRENT_PROJECT_VERSION = 1.0.1;
715721
DEVELOPMENT_TEAM = 3A5JW5BD39;
716722
INFOPLIST_FILE = Runner/Info.plist;
723+
INFOPLIST_KEY_CFBundleDisplayName = TubeSavely;
717724
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.video";
718725
LD_RUNPATH_SEARCH_PATHS = (
719726
"$(inherited)",
@@ -740,6 +747,7 @@
740747
CURRENT_PROJECT_VERSION = 1.0.1;
741748
DEVELOPMENT_TEAM = 3A5JW5BD39;
742749
INFOPLIST_FILE = Runner/Info.plist;
750+
INFOPLIST_KEY_CFBundleDisplayName = TubeSavely;
743751
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.video";
744752
LD_RUNPATH_SEARCH_PATHS = (
745753
"$(inherited)",

macos/Runner/DebugProfile.entitlements

+2
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@
1414
<true/>
1515
<key>com.apple.security.network.client</key>
1616
<true/>
17+
<key>com.apple.security.network.server</key>
18+
<true/>
1719
</dict>
1820
</plist>

macos/Runner/Info.plist

+8-4
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@
2626
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
2727
<key>NSDocumentsFolderUsageDescription</key>
2828
<string>We need your permission to save the video to the folder</string>
29+
<key>NSDesktopFolderUsageDescription</key>
30+
<string>We need your permission to save the video to the folder</string>
31+
<key>NSPhotoLibraryAddUsageDescription</key>
32+
<string>We need your permission to save the video to the album</string>
33+
<key>NSPhotoLibraryUsageDescription</key>
34+
<string>Used to demonstrate image picker plugin</string>
2935
<key>NSHumanReadableCopyright</key>
3036
<string>$(PRODUCT_COPYRIGHT)</string>
3137
<key>NSMainNibFile</key>
3238
<string>MainMenu</string>
33-
<key>NSPhotoLibraryAddUsageDescription</key>
34-
<string>We need your permission to save the video to the album</string>
35-
<key>NSPhotoLibraryUsageDescription</key>
36-
<string>Used to demonstrate image picker plugin</string>
3739
<key>NSPrincipalClass</key>
3840
<string>NSApplication</string>
41+
<key>NSAppleScriptEnabled</key>
42+
<true/>
3943
</dict>
4044
</plist>

0 commit comments

Comments
 (0)