From 09efcf5d695d6c3262643b078f76628a182f9ad8 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Mon, 9 Sep 2024 22:53:14 +0800 Subject: [PATCH] Remove toolbar box shadow and enhance file list preview. Deleted the box shadow from the toolbar to simplify the UI. Refactored the plugin manager to format file list previews, added new translation strings for file selection messages in English and Chinese. --- .../views/wox_query_toolbar_view.dart | 7 ---- Wox/plugin/manager.go | 38 ++++++++++++++++--- Wox/resource/lang/en_US.json | 5 ++- Wox/resource/lang/zh_CN.json | 5 ++- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/Wox.UI.Flutter/wox/lib/modules/launcher/views/wox_query_toolbar_view.dart b/Wox.UI.Flutter/wox/lib/modules/launcher/views/wox_query_toolbar_view.dart index 6b5240ee2..03f8d4332 100644 --- a/Wox.UI.Flutter/wox/lib/modules/launcher/views/wox_query_toolbar_view.dart +++ b/Wox.UI.Flutter/wox/lib/modules/launcher/views/wox_query_toolbar_view.dart @@ -51,13 +51,6 @@ class WoxQueryToolbarView extends GetView { child: Container( decoration: BoxDecoration( color: fromCssColor(controller.woxTheme.value.toolbarBackgroundColor), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.1), - blurRadius: 4, - offset: Offset(0, 2), - ), - ], ), child: Padding( padding: EdgeInsets.only(left: controller.woxTheme.value.toolbarPaddingLeft.toDouble(), right: controller.woxTheme.value.toolbarPaddingRight.toDouble()), diff --git a/Wox/plugin/manager.go b/Wox/plugin/manager.go index 985d8ccbd..eb02392d8 100644 --- a/Wox/plugin/manager.go +++ b/Wox/plugin/manager.go @@ -5,11 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/Masterminds/semver/v3" - "github.com/google/uuid" - "github.com/jinzhu/copier" - "github.com/samber/lo" - "github.com/wissance/stringFormatter" "math" "os" "path" @@ -23,6 +18,12 @@ import ( "wox/setting" "wox/share" "wox/util" + + "github.com/Masterminds/semver/v3" + "github.com/google/uuid" + "github.com/jinzhu/copier" + "github.com/samber/lo" + "github.com/wissance/stringFormatter" ) var managerInstance *Manager @@ -476,7 +477,7 @@ func (m *Manager) PolishResult(ctx context.Context, pluginInstance *Instance, qu if query.Selection.Type == util.SelectionTypeFile { result.Preview = WoxPreview{ PreviewType: WoxPreviewTypeMarkdown, - PreviewData: strings.Join(query.Selection.FilePaths, "\n"), + PreviewData: m.formatFileListPreview(ctx, query.Selection.FilePaths), } } } @@ -582,6 +583,31 @@ func (m *Manager) PolishResult(ctx context.Context, pluginInstance *Instance, qu return result } +func (m *Manager) formatFileListPreview(ctx context.Context, filePaths []string) string { + totalFiles := len(filePaths) + if totalFiles == 0 { + return i18n.GetI18nManager().TranslateWox(ctx, "i18n:selection_no_files_selected") + } + + var sb strings.Builder + sb.WriteString(fmt.Sprintf(i18n.GetI18nManager().TranslateWox(ctx, "i18n:selection_selected_files_count"), totalFiles)) + sb.WriteString("\n\n") + + maxDisplayFiles := 10 + for i, filePath := range filePaths { + if i < maxDisplayFiles { + sb.WriteString(fmt.Sprintf("- `%s`\n", filePath)) + } else { + remainingFiles := totalFiles - maxDisplayFiles + sb.WriteString("\n") + sb.WriteString(fmt.Sprintf(i18n.GetI18nManager().TranslateWox(ctx, "i18n:selection_remaining_files_not_shown"), remainingFiles)) + break + } + } + + return sb.String() +} + func (m *Manager) calculateResultScore(ctx context.Context, pluginId, title, subTitle string) int64 { resultHash := setting.NewResultHash(pluginId, title, subTitle) woxAppData := setting.GetSettingManager().GetWoxAppData(ctx) diff --git a/Wox/resource/lang/en_US.json b/Wox/resource/lang/en_US.json index 3d555299f..68e974b34 100644 --- a/Wox/resource/lang/en_US.json +++ b/Wox/resource/lang/en_US.json @@ -53,5 +53,8 @@ "ui_query_hotkeys": "Query Hotkeys", "ui_query_shortcuts": "Query Shortcuts", "ui_general": "General", - "ui_ai": "AI" + "ui_ai": "AI", + "selection_no_files_selected": "No files selected", + "selection_selected_files_count": "Selected %d files:", + "selection_remaining_files_not_shown": "... %d more files not shown" } \ No newline at end of file diff --git a/Wox/resource/lang/zh_CN.json b/Wox/resource/lang/zh_CN.json index aad7e2a59..cd96686a6 100644 --- a/Wox/resource/lang/zh_CN.json +++ b/Wox/resource/lang/zh_CN.json @@ -53,5 +53,8 @@ "ui_query_hotkeys": "查询快捷键", "ui_query_shortcuts": "查询缩写", "ui_general": "通用", - "ui_ai": "AI" + "ui_ai": "AI", + "selection_no_files_selected": "未选择文件", + "selection_selected_files_count": "已选择 %d 个文件:", + "selection_remaining_files_not_shown": "... 还有 %d 个文件未显示" } \ No newline at end of file