From dbc9c4c1216467121d40814c7f58f299bc2d5e60 Mon Sep 17 00:00:00 2001 From: Neginegi Date: Sun, 19 Feb 2023 23:47:28 +0800 Subject: [PATCH] fix docs and locales (#86) * refactor project in get-cli standard * use local trackers when github is not connectable upgrade stylish_bottom_bar to 1.0.0 responsive view for home_view treeview for file_list_vie fluent ui integrating * improve responsive view. treeView add light theme.fix overflow bugs * responsive view,treeView,file select downloaded and downloading pages file extension icons fix some minor bugs * use local trackers when github is not connectable upgrade stylish_bottom_bar to 1.0.0 responsive view for home_view treeview for file_list_vie fluent ui integrating * improve responsive view. treeView add light theme.fix overflow bugs * bottom bar index fix * refactor project in get-cli standard * fix:locale fix * docs: add detailed bash for build and dev --------- Co-authored-by: wuke2022 --- CONTRIBUTING.md | 2 +- CONTRIBUTING_zh-CN.md | 8 +- README.md | 3 +- README_zh-CN.md | 1 + ui/flutter/.fvm/flutter_sdk | 1 - ui/flutter/.fvm/fvm_config.json | 4 - .../app/controllers/app_controller.dart | 2 +- .../lib/app/modules/app/views/app_view.dart | 2 +- .../modules/setting/views/setting_view.dart | 2 +- .../app/views/views/buid_task_list_view.dart | 6 +- .../{messages.dart => localeManager.dart} | 2 +- ui/flutter/lib/main.dart | 6 +- ui/flutter/lib/util/file_icon.dart | 105 +++++++++++++++++- 13 files changed, 115 insertions(+), 29 deletions(-) delete mode 120000 ui/flutter/.fvm/flutter_sdk delete mode 100644 ui/flutter/.fvm/fvm_config.json rename ui/flutter/lib/i18n/{messages.dart => localeManager.dart} (87%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 60360d85..92313b62 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,7 +32,7 @@ Please refer to `en_us.dart` for translation. ## flutter development -Don't forget to run`dart format .`before you commit to keep your code in standard dart format +Don't forget to run`dart format ./ui/flutter`before you commit to keep your code in standard dart format Turn on build_runner watcher if you want to edit api/models: diff --git a/CONTRIBUTING_zh-CN.md b/CONTRIBUTING_zh-CN.md index 79b2cea2..cb6c2f6d 100644 --- a/CONTRIBUTING_zh-CN.md +++ b/CONTRIBUTING_zh-CN.md @@ -13,24 +13,20 @@ PR,合并到 `main` 分支。 flutter 项目即可运行。 ## 翻译 - + Gopeed 的国际化文件位于 `ui/flutter/assets/locales` 目录下,只需要在该目录下添加对应的语言文件即可。 - 编辑locales后请运行以下命令: - ``` get generate locales ``` 请注意以 `en_US.json` 为参照进行翻译。 - ## flutter开发 - -每次提交前请务必运行`dart format .` +每次提交前请务必`dart format ./ui/flutter` 如果要编辑api/models,请打开build_runner watcher: diff --git a/README.md b/README.md index 519fbdd6..a4d705c2 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,8 @@ cd ../../ rm -rf cmd/web/dist cp -r ui/flutter/build/web cmd/web/dist go build -tags nosqlite,web -ldflags="-s -w" -o bin/ github.com/GopeedLab/gopeed/cmd/web -```` +go run cmd/web/main.go +``` ## License diff --git a/README_zh-CN.md b/README_zh-CN.md index bf3bed36..e5f2caee 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -146,6 +146,7 @@ cd ../../ rm -rf cmd/web/dist cp -r ui/flutter/build/web cmd/web/dist go build -tags nosqlite,web -ldflags="-s -w" -o bin/ github.com/GopeedLab/gopeed/cmd/web +go run cmd/web/main.go ``` ## 开源许可 diff --git a/ui/flutter/.fvm/flutter_sdk b/ui/flutter/.fvm/flutter_sdk deleted file mode 120000 index ad024458..00000000 --- a/ui/flutter/.fvm/flutter_sdk +++ /dev/null @@ -1 +0,0 @@ -C:/Users/huget/fvm/versions/3.7.0 \ No newline at end of file diff --git a/ui/flutter/.fvm/fvm_config.json b/ui/flutter/.fvm/fvm_config.json deleted file mode 100644 index c2dd9f53..00000000 --- a/ui/flutter/.fvm/fvm_config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flutterSdkVersion": "3.7.0", - "flavors": {} -} \ No newline at end of file diff --git a/ui/flutter/lib/app/modules/app/controllers/app_controller.dart b/ui/flutter/lib/app/modules/app/controllers/app_controller.dart index ca813ead..7f13732f 100644 --- a/ui/flutter/lib/app/modules/app/controllers/app_controller.dart +++ b/ui/flutter/lib/app/modules/app/controllers/app_controller.dart @@ -10,7 +10,7 @@ import '../../../../api/api.dart'; import '../../../../api/model/downloader_config.dart'; import '../../../../core/common/start_config.dart'; import '../../../../generated/locales.g.dart'; -import '../../../../i18n/messages.dart'; +import '../../../../i18n/localeManager.dart'; import '../../../../util/log_util.dart'; import '../../../../util/util.dart'; diff --git a/ui/flutter/lib/app/modules/app/views/app_view.dart b/ui/flutter/lib/app/modules/app/views/app_view.dart index ff445213..6e62cb0a 100644 --- a/ui/flutter/lib/app/modules/app/views/app_view.dart +++ b/ui/flutter/lib/app/modules/app/views/app_view.dart @@ -3,7 +3,7 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:get/get.dart'; import '../../../../generated/locales.g.dart'; -import '../../../../i18n/messages.dart'; +import '../../../../i18n/localeManager.dart'; import '../../../../theme/theme.dart'; import '../../../routes/app_pages.dart'; import '../controllers/app_controller.dart'; diff --git a/ui/flutter/lib/app/modules/setting/views/setting_view.dart b/ui/flutter/lib/app/modules/setting/views/setting_view.dart index 2a8c3564..cd75829a 100644 --- a/ui/flutter/lib/app/modules/setting/views/setting_view.dart +++ b/ui/flutter/lib/app/modules/setting/views/setting_view.dart @@ -8,7 +8,7 @@ import 'package:intl/intl.dart'; import 'package:url_launcher/url_launcher.dart'; import '../../../../generated/locales.g.dart'; -import '../../../../i18n/messages.dart'; +import '../../../../i18n/localeManager.dart'; import '../../../../util/package_info.dart'; import '../../../../util/util.dart'; import '../../../views/views/check_list_view.dart'; diff --git a/ui/flutter/lib/app/views/views/buid_task_list_view.dart b/ui/flutter/lib/app/views/views/buid_task_list_view.dart index 920662fd..fa213d68 100644 --- a/ui/flutter/lib/app/views/views/buid_task_list_view.dart +++ b/ui/flutter/lib/app/views/views/buid_task_list_view.dart @@ -78,10 +78,10 @@ class BuildTaskListView extends GetView { context: context, barrierDismissible: false, builder: (_) => AlertDialog( - title: Text('task.deleteTask'.tr), + title: Text('deleteTask'.tr), content: Obx(() => CheckboxListTile( value: keep.value, - title: Text('task.deleteTaskTip'.tr, + title: Text('deleteTaskTip'.tr, style: context.textTheme.bodyLarge), onChanged: (v) { keep.value = v!; @@ -93,7 +93,7 @@ class BuildTaskListView extends GetView { ), TextButton( child: Text( - 'task.delete'.tr, + 'delete'.tr, style: const TextStyle(color: Colors.redAccent), ), onPressed: () async { diff --git a/ui/flutter/lib/i18n/messages.dart b/ui/flutter/lib/i18n/localeManager.dart similarity index 87% rename from ui/flutter/lib/i18n/messages.dart rename to ui/flutter/lib/i18n/localeManager.dart index 6f755f95..53ce2160 100644 --- a/ui/flutter/lib/i18n/messages.dart +++ b/ui/flutter/lib/i18n/localeManager.dart @@ -9,5 +9,5 @@ String getLocaleKey(Locale locale) { return '${locale.languageCode}_${locale.countryCode}'; } -const mainLocale = Locale('zh', 'CN'); +const debugLocale = Locale('zh', 'CN'); const fallbackLocale = Locale('en', 'US'); diff --git a/ui/flutter/lib/main.dart b/ui/flutter/lib/main.dart index 4c198331..cc9095b2 100644 --- a/ui/flutter/lib/main.dart +++ b/ui/flutter/lib/main.dart @@ -2,12 +2,12 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:gopeed/api/api.dart' as api; -import 'package:gopeed/i18n/messages.dart'; import 'app/modules/app/controllers/app_controller.dart'; import 'app/modules/app/views/app_view.dart'; import 'core/libgopeed_boot.dart'; import 'generated/locales.g.dart'; +import 'i18n/localeManager.dart'; import 'util/log_util.dart'; import 'util/mac_secure_util.dart'; import 'util/package_info.dart'; @@ -50,9 +50,9 @@ Future onStart() async { final appController = Get.find(); await appController.trackerUpdateOnStart(); - // if is debug mode, check language message is complete + // if is debug mode, check language message is complete,change debug locale to your comfortable language if you want if (kDebugMode) { - final mainLang = getLocaleKey(mainLocale); + final mainLang = getLocaleKey(debugLocale); final fullMessages = AppTranslation.translations[mainLang]; AppTranslation.translations.keys .where((e) => e != mainLang) diff --git a/ui/flutter/lib/util/file_icon.dart b/ui/flutter/lib/util/file_icon.dart index 40c64caa..e00a11f9 100644 --- a/ui/flutter/lib/util/file_icon.dart +++ b/ui/flutter/lib/util/file_icon.dart @@ -12,23 +12,90 @@ findIcon(String ext) { const List iconMaps = [ //media { - 'extensions': ['jpg', 'png', 'gif', 'bmp', 'jpeg', 'jpe', 'jif', 'jfif', 'jfi', 'webp', 'tiff', 'tif', 'ico', 'svg', 'webp'], + 'extensions': [ + 'jpg', + 'png', + 'gif', + 'bmp', + 'jpeg', + 'jpe', + 'jif', + 'jfif', + 'jfi', + 'webp', + 'tiff', + 'tif', + 'ico', + 'svg', + 'webp' + ], 'type': 'Image', 'thumbnail': 'file_image' }, { - 'extensions': ['mp4', 'webm', 'mpg', 'mp2', 'mpeg', 'mpe', 'mpv', 'ocg', 'm4p', 'm4v', 'avi', 'wmv', 'mov', 'qt', 'flv', 'swf', 'mkv', 'rmvb', 'rm', 'vob', '3gp'], + 'extensions': [ + 'mp4', + 'webm', + 'mpg', + 'mp2', + 'mpeg', + 'mpe', + 'mpv', + 'ocg', + 'm4p', + 'm4v', + 'avi', + 'wmv', + 'mov', + 'qt', + 'flv', + 'swf', + 'mkv', + 'rmvb', + 'rm', + 'vob', + '3gp' + ], 'type': 'Video', 'thumbnail': 'my_movies_t_v' }, { - 'extensions': ['mp3', 'ogg', 'ogm', 'wav', '.aac', '.ape', '.flac', '.flav', '.m4a', '.wma'], + 'extensions': [ + 'mp3', + 'ogg', + 'ogm', + 'wav', + '.aac', + '.ape', + '.flac', + '.flav', + '.m4a', + '.wma' + ], 'type': 'Audio', 'thumbnail': 'music_in_collection_fill' }, //compressed { - 'extensions': ['7z', 'brotli', 'bzip2', 'gz', 'gzip', 'rar', 'tgz', 'xz', 'zip', 'zstd', 'deb', 'msi', 'snap', 'iso', 'dmg', 'dockerfile', 'dockerignore'], + 'extensions': [ + '7z', + 'brotli', + 'bzip2', + 'gz', + 'gzip', + 'rar', + 'tgz', + 'xz', + 'zip', + 'zstd', + 'deb', + 'msi', + 'snap', + 'iso', + 'dmg', + 'dockerfile', + 'dockerignore' + ], 'type': 'Archive', 'thumbnail': 'package' }, @@ -49,7 +116,18 @@ const List iconMaps = [ 'thumbnail': 'excel_document' }, { - 'extensions': ['pot', 'potm', 'potx', 'ppam', 'pps', 'ppsm', 'ppsx', 'ppt', 'pptn', 'pptx'], + 'extensions': [ + 'pot', + 'potm', + 'potx', + 'ppam', + 'pps', + 'ppsm', + 'ppsx', + 'ppt', + 'pptn', + 'pptx' + ], 'type': 'Powerpoint Document', 'thumbnail': 'power_point_document' }, @@ -60,7 +138,22 @@ const List iconMaps = [ 'thumbnail': 'file_symlink' }, { - 'extensions': ['ini', 'dlc', 'config', 'conf', 'properties', 'prop', 'settings', 'option', 'props', 'toml', 'prefs', 'sln.dotsettings', 'sln.dotsettings.user', 'cfg'], + 'extensions': [ + 'ini', + 'dlc', + 'config', + 'conf', + 'properties', + 'prop', + 'settings', + 'option', + 'props', + 'toml', + 'prefs', + 'sln.dotsettings', + 'sln.dotsettings.user', + 'cfg' + ], 'type': 'Settings', 'thumbnail': 'text_document_settings' },