From 11f3cd95faae2af9510ab69f3ce3fb625a71b0a8 Mon Sep 17 00:00:00 2001 From: Mucheen <1528136628@qq.com> Date: Wed, 18 Nov 2026 15:18:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(desktop):=20=E6=8E=92=E9=99=A4=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E6=B5=8B=E8=AF=95=E6=A0=B7=E4=BE=8B=E5=B9=B6=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=20Gradle=20=E6=96=87=E4=BB=B6=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .lithe/build/options.json | 8 + desktop/internal/fileicons/fileicons.go | 8 + desktop/internal/fileicons/fileicons_test.go | 12 +- desktop/internal/fileicons/icons.go | 174 ++++++++++++++++++ desktop/internal/fileicons/svg/gradle.svg | 5 + .../internal/fileicons/svg/gradle_dark.svg | 5 + .../internal/workbench/visual_capture_test.go | 41 +++++ docs/ci-builds.md | 3 +- .../features/project-file-type-icons.json | 4 +- 9 files changed, 256 insertions(+), 4 deletions(-) create mode 100644 .lithe/build/options.json create mode 100644 desktop/internal/fileicons/svg/gradle.svg create mode 100644 desktop/internal/fileicons/svg/gradle_dark.svg diff --git a/.lithe/build/options.json b/.lithe/build/options.json new file mode 100644 index 0000000000..a9487c1a00 --- /dev/null +++ b/.lithe/build/options.json @@ -0,0 +1,8 @@ +{ + "version": 1, + "systems": {}, + "ignoredPaths": [ + ".*", + "/desktop/internal/editor/textmate/testdata/" + ] +} diff --git a/desktop/internal/fileicons/fileicons.go b/desktop/internal/fileicons/fileicons.go index c78cdcf715..b032d15768 100644 --- a/desktop/internal/fileicons/fileicons.go +++ b/desktop/internal/fileicons/fileicons.go @@ -41,6 +41,8 @@ const ( kindScala // kindGroovy identifies a Groovy file. kindGroovy + // kindGradle identifies a Gradle script written in Groovy or Kotlin. + kindGradle // kindPHP identifies a PHP file. kindPHP // kindCSource identifies a C or Objective-C source file. @@ -147,6 +149,7 @@ var kindIcons = [kindCount][2]*gfx.Icon{ kindRuby: {&Ruby, nil}, kindScala: {&Scala, nil}, kindGroovy: {&Groovy, &GroovyDark}, + kindGradle: {&Gradle, &GradleDark}, kindPHP: {&Php, nil}, kindCSource: {&C, &CDark}, kindCHeader: {&H, &HDark}, @@ -396,7 +399,12 @@ func fileKind(name string) kind { return kindSwift case "java": return kindJava + case "gradle": + return kindGradle case "kt", "kts": + if strings.HasSuffix(lowerName, ".gradle.kts") { + return kindGradle + } return kindKotlin case "rs": return kindRust diff --git a/desktop/internal/fileicons/fileicons_test.go b/desktop/internal/fileicons/fileicons_test.go index f9fd284810..db8036da0c 100644 --- a/desktop/internal/fileicons/fileicons_test.go +++ b/desktop/internal/fileicons/fileicons_test.go @@ -52,7 +52,13 @@ func TestFileKind(t *testing.T) { {"notes.txt", kindText}, {".gitignore", kindGitignore}, {".editorconfig", kindEditorConfig}, - {"build.gradle.kts", kindKotlin}, + {"build.gradle", kindGradle}, + {"settings.gradle", kindGradle}, + {"build.gradle.kts", kindGradle}, + {"settings.gradle.kts", kindGradle}, + {"INIT.GRADLE.KTS", kindGradle}, + {"script.kts", kindKotlin}, + {"build.gradle.tokens", kindUnknown}, {"notes", kindUnknown}, {".bashrc", kindUnknown}, {"file.", kindUnknown}, @@ -191,6 +197,10 @@ func TestForFileUsesDarkVariant(t *testing.T) { {"a.json", false, &Json}, {"main.go", true, &Go}, {"main.go", false, &Go}, + {"build.gradle", false, &Gradle}, + {"build.gradle", true, &GradleDark}, + {"build.gradle.kts", false, &Gradle}, + {"build.gradle.kts", true, &GradleDark}, } for _, c := range cases { // The returned icon is a copy that shares the generated icon's layers. diff --git a/desktop/internal/fileicons/icons.go b/desktop/internal/fileicons/icons.go index 664526e2f3..a863a7e8a7 100644 --- a/desktop/internal/fileicons/icons.go +++ b/desktop/internal/fileicons/icons.go @@ -2687,6 +2687,180 @@ var Go = gfx.Icon{ }, } +// gradle is a compiled vector icon. +var Gradle = gfx.Icon{ + ViewBox: 16.0, + Stroke: 2.0, + Cap: gfx.CapRound, + Join: gfx.JoinRound, + Layers: []gfx.IconLayer{ + {Fill: gfx.Color{Red: 0.423529, Green: 0.439216, Blue: 0.494118, Alpha: 1.0}, Commands: []gfx.PathCommand{ + gfx.MoveTo(14.445, 3.764), + gfx.QuadTo(14.442, 3.759, 14.44, 3.753), + gfx.QuadTo(14.189, 3.236, 13.654, 3.056), + gfx.QuadTo(13.015, 2.841, 12.33, 3.44), + gfx.QuadTo(12.174, 3.576, 11.967, 3.562), + gfx.QuadTo(11.76, 3.549, 11.624, 3.393), + gfx.QuadTo(11.488, 3.237, 11.502, 3.03), + gfx.QuadTo(11.516, 2.823, 11.672, 2.687), + gfx.QuadTo(12.789, 1.71, 13.973, 2.108), + gfx.QuadTo(14.908, 2.423, 15.341, 3.321), + gfx.QuadTo(15.395, 3.423, 15.434, 3.527), + gfx.QuadTo(16.733, 6.608, 12.864, 9.502), + gfx.QuadTo(11.682, 10.387, 11.615, 12.76), + gfx.QuadTo(11.598, 13.344, 11.014, 13.344), + gfx.LineTo(9.873, 13.344), + gfx.QuadTo(9.328, 13.344, 9.183, 12.805), + gfx.QuadTo(8.988, 12.084, 8.23, 12.084), + gfx.QuadTo(7.476, 12.084, 7.278, 12.81), + gfx.QuadTo(7.132, 13.346, 6.588, 13.346), + gfx.LineTo(5.512, 13.346), + gfx.QuadTo(4.968, 13.346, 4.822, 12.81), + gfx.QuadTo(4.624, 12.084, 3.87, 12.084), + gfx.QuadTo(3.116, 12.084, 2.918, 12.81), + gfx.QuadTo(2.772, 13.347, 2.228, 13.347), + gfx.LineTo(1.036, 13.347), + gfx.QuadTo(0.495, 13.347, 0.439, 12.808), + gfx.QuadTo(-0.016, 8.399, 2.984, 6.265), + gfx.LineTo(2.984, 6.263), + gfx.QuadTo(2.596, 5.059, 3.703, 4.513), + gfx.QuadTo(7.16, 2.809, 11.064, 4.86), + gfx.QuadTo(12.414, 5.57, 12.963, 5.57), + gfx.QuadTo(13.822, 5.57, 14.284, 4.864), + gfx.QuadTo(14.651, 4.302, 14.494, 3.874), + gfx.QuadTo(14.471, 3.819, 14.445, 3.764), + gfx.ClosePath(), + gfx.MoveTo(14.545, 6.054), + gfx.QuadTo(13.897, 6.57, 12.963, 6.57), + gfx.QuadTo(12.167, 6.57, 10.599, 5.746), + gfx.QuadTo(7.146, 3.931, 4.145, 5.41), + gfx.QuadTo(3.812, 5.574, 3.935, 5.956), + gfx.LineTo(4.043, 6.289), + gfx.QuadTo(4.057, 6.325, 4.065, 6.362), + gfx.LineTo(4.632, 8.226), + gfx.QuadTo(4.698, 8.407, 4.954, 8.464), + gfx.QuadTo(5.267, 8.533, 5.525, 8.388), + gfx.QuadTo(6.485, 7.869, 7.257, 7.174), + gfx.QuadTo(7.411, 7.035, 7.618, 7.046), + gfx.QuadTo(7.825, 7.057, 7.963, 7.21), + gfx.QuadTo(8.102, 7.364, 8.091, 7.571), + gfx.QuadTo(8.08, 7.778, 7.926, 7.917), + gfx.QuadTo(7.066, 8.692, 6.015, 9.26), + gfx.QuadTo(5.424, 9.592, 4.738, 9.44), + gfx.QuadTo(3.928, 9.261, 3.683, 8.541), + gfx.LineTo(3.681, 8.534), + gfx.LineTo(3.3, 7.281), + gfx.QuadTo(1.173, 9.002, 1.403, 12.347), + gfx.LineTo(2.016, 12.347), + gfx.QuadTo(2.46, 11.084, 3.87, 11.084), + gfx.QuadTo(5.28, 11.084, 5.724, 12.346), + gfx.LineTo(6.376, 12.346), + gfx.QuadTo(6.82, 11.084, 8.23, 11.084), + gfx.QuadTo(9.646, 11.084, 10.086, 12.344), + gfx.LineTo(10.633, 12.344), + gfx.QuadTo(10.804, 9.795, 12.265, 8.701), + gfx.QuadTo(14.044, 7.371, 14.545, 6.054), + gfx.ClosePath(), + }}, + {Fill: gfx.Color{Red: 0.423529, Green: 0.439216, Blue: 0.494118, Alpha: 1.0}, Commands: []gfx.PathCommand{ + gfx.MoveTo(9.259, 7.32), + gfx.CubicTo(9.164, 7.259, 9.107, 7.148, 9.144, 7.041), + gfx.CubicTo(9.244, 6.755, 9.5, 6.543, 9.812, 6.51), + gfx.CubicTo(10.186, 6.469, 10.537, 6.695, 10.656, 7.052), + gfx.CubicTo(10.754, 7.349, 10.669, 7.67, 10.45, 7.88), + gfx.CubicTo(10.368, 7.958, 10.243, 7.952, 10.148, 7.891), + gfx.ClosePath(), + }}, + }, +} + +// gradle-dark is a compiled vector icon. +var GradleDark = gfx.Icon{ + ViewBox: 16.0, + Stroke: 2.0, + Cap: gfx.CapRound, + Join: gfx.JoinRound, + Layers: []gfx.IconLayer{ + {Fill: gfx.Color{Red: 0.807843, Green: 0.815686, Blue: 0.839216, Alpha: 1.0}, Commands: []gfx.PathCommand{ + gfx.MoveTo(14.445, 3.764), + gfx.QuadTo(14.442, 3.759, 14.44, 3.753), + gfx.QuadTo(14.189, 3.236, 13.654, 3.056), + gfx.QuadTo(13.015, 2.841, 12.33, 3.44), + gfx.QuadTo(12.174, 3.576, 11.967, 3.562), + gfx.QuadTo(11.76, 3.549, 11.624, 3.393), + gfx.QuadTo(11.488, 3.237, 11.502, 3.03), + gfx.QuadTo(11.516, 2.823, 11.672, 2.687), + gfx.QuadTo(12.789, 1.71, 13.973, 2.108), + gfx.QuadTo(14.908, 2.423, 15.341, 3.321), + gfx.QuadTo(15.395, 3.423, 15.434, 3.527), + gfx.QuadTo(16.733, 6.608, 12.864, 9.502), + gfx.QuadTo(11.682, 10.387, 11.615, 12.76), + gfx.QuadTo(11.598, 13.344, 11.014, 13.344), + gfx.LineTo(9.873, 13.344), + gfx.QuadTo(9.328, 13.344, 9.183, 12.805), + gfx.QuadTo(8.988, 12.084, 8.23, 12.084), + gfx.QuadTo(7.476, 12.084, 7.278, 12.81), + gfx.QuadTo(7.132, 13.346, 6.588, 13.346), + gfx.LineTo(5.512, 13.346), + gfx.QuadTo(4.968, 13.346, 4.822, 12.81), + gfx.QuadTo(4.624, 12.084, 3.87, 12.084), + gfx.QuadTo(3.116, 12.084, 2.918, 12.81), + gfx.QuadTo(2.772, 13.347, 2.228, 13.347), + gfx.LineTo(1.036, 13.347), + gfx.QuadTo(0.495, 13.347, 0.439, 12.808), + gfx.QuadTo(-0.016, 8.399, 2.984, 6.265), + gfx.LineTo(2.984, 6.263), + gfx.QuadTo(2.596, 5.059, 3.703, 4.513), + gfx.QuadTo(7.16, 2.809, 11.064, 4.86), + gfx.QuadTo(12.414, 5.57, 12.963, 5.57), + gfx.QuadTo(13.822, 5.57, 14.284, 4.864), + gfx.QuadTo(14.651, 4.302, 14.494, 3.874), + gfx.QuadTo(14.471, 3.819, 14.445, 3.764), + gfx.ClosePath(), + gfx.MoveTo(14.545, 6.054), + gfx.QuadTo(13.897, 6.57, 12.963, 6.57), + gfx.QuadTo(12.167, 6.57, 10.599, 5.746), + gfx.QuadTo(7.146, 3.931, 4.145, 5.41), + gfx.QuadTo(3.812, 5.574, 3.935, 5.956), + gfx.LineTo(4.043, 6.289), + gfx.QuadTo(4.057, 6.325, 4.065, 6.362), + gfx.LineTo(4.632, 8.226), + gfx.QuadTo(4.698, 8.407, 4.954, 8.464), + gfx.QuadTo(5.267, 8.533, 5.525, 8.388), + gfx.QuadTo(6.485, 7.869, 7.257, 7.174), + gfx.QuadTo(7.411, 7.035, 7.618, 7.046), + gfx.QuadTo(7.825, 7.057, 7.963, 7.21), + gfx.QuadTo(8.102, 7.364, 8.091, 7.571), + gfx.QuadTo(8.08, 7.778, 7.926, 7.917), + gfx.QuadTo(7.066, 8.692, 6.015, 9.26), + gfx.QuadTo(5.424, 9.592, 4.738, 9.44), + gfx.QuadTo(3.928, 9.261, 3.683, 8.541), + gfx.LineTo(3.681, 8.534), + gfx.LineTo(3.3, 7.281), + gfx.QuadTo(1.173, 9.002, 1.403, 12.347), + gfx.LineTo(2.016, 12.347), + gfx.QuadTo(2.46, 11.084, 3.87, 11.084), + gfx.QuadTo(5.28, 11.084, 5.724, 12.346), + gfx.LineTo(6.376, 12.346), + gfx.QuadTo(6.82, 11.084, 8.23, 11.084), + gfx.QuadTo(9.646, 11.084, 10.086, 12.344), + gfx.LineTo(10.633, 12.344), + gfx.QuadTo(10.804, 9.795, 12.265, 8.701), + gfx.QuadTo(14.044, 7.371, 14.545, 6.054), + gfx.ClosePath(), + }}, + {Fill: gfx.Color{Red: 0.807843, Green: 0.815686, Blue: 0.839216, Alpha: 1.0}, Commands: []gfx.PathCommand{ + gfx.MoveTo(9.259, 7.32), + gfx.CubicTo(9.164, 7.259, 9.107, 7.148, 9.144, 7.041), + gfx.CubicTo(9.244, 6.755, 9.5, 6.543, 9.812, 6.51), + gfx.CubicTo(10.186, 6.469, 10.537, 6.695, 10.656, 7.052), + gfx.CubicTo(10.754, 7.349, 10.669, 7.67, 10.45, 7.88), + gfx.CubicTo(10.368, 7.958, 10.243, 7.952, 10.148, 7.891), + gfx.ClosePath(), + }}, + }, +} + // graphql is a compiled vector icon. var Graphql = gfx.Icon{ ViewBox: 16.0, diff --git a/desktop/internal/fileicons/svg/gradle.svg b/desktop/internal/fileicons/svg/gradle.svg new file mode 100644 index 0000000000..29f3e59ee6 --- /dev/null +++ b/desktop/internal/fileicons/svg/gradle.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/desktop/internal/fileicons/svg/gradle_dark.svg b/desktop/internal/fileicons/svg/gradle_dark.svg new file mode 100644 index 0000000000..37c055abf2 --- /dev/null +++ b/desktop/internal/fileicons/svg/gradle_dark.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/desktop/internal/workbench/visual_capture_test.go b/desktop/internal/workbench/visual_capture_test.go index 645940a485..4bd7e9af41 100644 --- a/desktop/internal/workbench/visual_capture_test.go +++ b/desktop/internal/workbench/visual_capture_test.go @@ -20,6 +20,47 @@ import ( "github.com/vivaui/viva/headless" ) +// TestVisualGradleFileIcons captures Gradle scripts in the Project tree in both themes. +func TestVisualGradleFileIcons(t *testing.T) { + out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") + if out == "" { + t.Skip("set LITHE_VISUAL_OUTPUT_DIR") + } + if err := os.MkdirAll(out, 0o755); err != nil { + t.Fatal(err) + } + for _, theme := range []string{"light", "dark"} { + for _, language := range []string{"zh-Hans", "en-US"} { + t.Run(theme+"-"+language, func(t *testing.T) { + root := t.TempDir() + files := []string{"build.gradle", "build.gradle.kts", "build.gradle.tokens", "settings.gradle", "settings.gradle.kts"} + writeTreeFiles(t, root, files...) + prefs := store.At(t.TempDir()) + if err := prefs.Save(settingsFile, map[string]string{"theme": theme}); err != nil { + t.Fatal(err) + } + var session *headless.Session + h := newHarnessWithDriver(t, Options{Kernel: &testKernel{Client: core.NewClient()}, Store: prefs, Languages: []string{language}}, func(config app.Config) (*app.Driver, func(), error) { + config.Width, config.Height = 1000, 640 + var err error + session, err = headless.Open(config, nil, headless.Options{}) + if err != nil { + return nil, nil, err + } + return session.Driver(), session.Close, nil + }) + h.openTree(t, root) + for _, name := range files { + h.treeRowHit(name) + } + if err := session.Screenshot(filepath.Join(out, "gradle-file-icons-"+theme+"-"+language+".png")); err != nil { + t.Fatal(err) + } + }) + } + } +} + // TestVisualWorkbench uses the archive's repository in a private temporary checkout. // No installed plugins, user settings, native windows or network services are used. func TestVisualWorkbench(t *testing.T) { diff --git a/docs/ci-builds.md b/docs/ci-builds.md index d35be4c257..5b6b77dee7 100644 --- a/docs/ci-builds.md +++ b/docs/ci-builds.md @@ -82,7 +82,8 @@ Viva 的 IDE API 辅助程序 `lithe-mcp` 由 `scripts/desktop/build-desktop-cor Viva 的 `desktop-go.sh` 把暂存 Core 静态库、头文件、原生链接参数和实际选中的 Windows import archive 的 SHA-256 纳入 cgo 编译参数。只改 Rust 或 Core pin 也会使 Go 构建缓存失效;相同字节仍复用 Go 缓存,不清空用户缓存。这个摘要只是本地构建身份,不是跨工作树资源密封清单。`scripts/desktop/desktop-core-cache.test.mjs` 在系统临时目录创建独占的 `lithe core-cache-*` 夹具,只替换 C 静态库来验证真实 Go 编译结果;子进程有本地时限,结束后删除夹具。该目录只属于一次测试,不跨工作树复制,不进入安装包;三个原生 CI 车道都运行此回归。 -Viva 文件与项目树图标的 SVG 和生成的 Go 数据由 Git 管理,生成脚本限定 Python 3.9 或 3.11、 +Viva 文件与项目树图标的 SVG(含 `desktop/internal/fileicons/svg/gradle*.svg`)和生成的 Go 数据 +(含 `desktop/internal/fileicons/icons.go`)由 Git 管理。生成脚本限定 Python 3.9 或 3.11、 picosvg 与直接依赖以及 Viva 编译器版本,在本工作树重建;没有自动发现受支持的 Python 时可用 `LITHE_ICON_PYTHON` 指定受支持的解释器,该变量不是缓存路径。临时转换目录退出时删除。它们不是跨工作树的可复制缓存, 不跨工作树复制。运行期图标只读编译数据,不写入安装包,因而不改变 diff --git a/shared/platform-feature-matrix/features/project-file-type-icons.json b/shared/platform-feature-matrix/features/project-file-type-icons.json index 321a9cb89c..0a82327700 100644 --- a/shared/platform-feature-matrix/features/project-file-type-icons.json +++ b/shared/platform-feature-matrix/features/project-file-type-icons.json @@ -2,7 +2,7 @@ "id": "project-file-type-icons", "area": "工作台", "group": "项目侧边栏", - "capability": "项目树、标签页和搜索结果为常见项目文件显示专用图标:.gitignore/.gitattributes 用 Git 图标,go.mod/go.sum 用 Go 图标,Makefile 与 *.mk 用 Makefile 图标,package.json 用 Node.js 图标,bun.lock、Cargo.lock、package-lock.json 等锁文件用锁图标,README 用信息图标,*.java 用 Java 图标,LICENSE/COPYING 用许可证图标;Lua、Zig(含 .zon)、Protobuf、GraphQL 和 CMake(*.cmake 与 CMakeLists.txt)文件用各自的语言图标", + "capability": "项目树、标签页和搜索结果为常见项目文件显示专用图标:.gitignore/.gitattributes 用 Git 图标,go.mod/go.sum 用 Go 图标,Makefile 与 *.mk 用 Makefile 图标,package.json 用 Node.js 图标,bun.lock、Cargo.lock、package-lock.json 等锁文件用锁图标,README 用信息图标,*.java 用 Java 图标,LICENSE/COPYING 用许可证图标;Lua、Zig(含 .zon)、Protobuf、GraphQL 和 CMake(*.cmake 与 CMakeLists.txt)文件用各自的语言图标,*.gradle 和 *.gradle.kts 用 Gradle 图标", "macos": { "implementationStatus": "implemented", "verificationStatus": "pending", @@ -28,7 +28,7 @@ ] }, "owner": "Workbench", - "verification": "在深浅主题下打开含 go.mod、go.sum、Makefile、.gitignore、.gitattributes、bun.lock、package.json、README.md、LICENSE、NOTICE、Main.java 的项目,核对项目树、编辑器标签和 Search Everywhere/快速打开中的图标与上述分类一致,不再显示问号或纯文本图标;NOTICE 等未分类文本仍显示文本图标。Windows 使用 IDEA Icons 主题核对同一组文件,PowerShell 文件仍显示原 Windows 四格图标。打开含 order.lua、main.zig、order.proto、schema.graphql、CMakeLists.txt 的项目,深浅主题下分别显示 Lua、Zig、Protobuf、GraphQL 和 CMake 图标,不再显示问号或文本图标。", + "verification": "在深浅主题下打开含 go.mod、go.sum、Makefile、.gitignore、.gitattributes、bun.lock、package.json、README.md、LICENSE、NOTICE、Main.java 的项目,核对项目树、编辑器标签和 Search Everywhere/快速打开中的图标与上述分类一致,不再显示问号或纯文本图标;NOTICE 等未分类文本仍显示文本图标。Windows 使用 IDEA Icons 主题核对同一组文件,PowerShell 文件仍显示原 Windows 四格图标。打开含 order.lua、main.zig、order.proto、schema.graphql、CMakeLists.txt 的项目,深浅主题下分别显示 Lua、Zig、Protobuf、GraphQL 和 CMake 图标,不再显示问号或文本图标。用深浅主题检查 build.gradle、settings.gradle 及对应 .gradle.kts 文件显示 Gradle 大象图标,普通 .kts 文件仍显示 Kotlin 图标。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", "macos": {