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.
This commit is contained in:
qianlifeng 2024-09-09 22:53:14 +08:00
parent b9f55f8cbc
commit 09efcf5d69
No known key found for this signature in database
4 changed files with 40 additions and 15 deletions

View File

@ -51,13 +51,6 @@ class WoxQueryToolbarView extends GetView<WoxLauncherController> {
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()),

View File

@ -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)

View File

@ -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"
}

View File

@ -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 个文件未显示"
}