| | |
| | | } |
| | | |
| | | var targetDirectory = Path.Combine(_paths.PluginDirectory, manifest.Id); |
| | | CopyDirectoryReplacingFiles(sourceDirectory, targetDirectory); |
| | | CopyDirectoryPreservingPluginConfig(sourceDirectory, targetDirectory); |
| | | manifests.Add((manifest, manifest.Id)); |
| | | } |
| | | |
| | |
| | | changed = true; |
| | | } |
| | | |
| | | if (RepairManifestClickThrough(manifest, layout.Instances)) |
| | | { |
| | | changed = true; |
| | | } |
| | | |
| | | continue; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private static void CopyDirectoryReplacingFiles(string sourceDirectory, string targetDirectory) |
| | | private static void CopyDirectoryPreservingPluginConfig(string sourceDirectory, string targetDirectory) |
| | | { |
| | | Directory.CreateDirectory(targetDirectory); |
| | | |
| | |
| | | var relativePath = Path.GetRelativePath(sourceDirectory, sourceFile); |
| | | var targetFile = Path.Combine(targetDirectory, relativePath); |
| | | Directory.CreateDirectory(Path.GetDirectoryName(targetFile)!); |
| | | |
| | | if (string.Equals(relativePath, "plugin.json", StringComparison.OrdinalIgnoreCase) && |
| | | File.Exists(targetFile)) |
| | | { |
| | | File.Copy(sourceFile, Path.Combine(targetDirectory, "plugin.template.json"), overwrite: true); |
| | | continue; |
| | | } |
| | | |
| | | File.Copy(sourceFile, targetFile, overwrite: true); |
| | | } |
| | | } |
| | |
| | | return changed; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Heal instances whose persisted clickThrough drifted from the plugin default. |
| | | /// Interactive plugins (e.g. LLM palette) ship with clickThrough=false; "恢复默认" |
| | | /// used to force true for every widget and left them permanently unclickable. |
| | | /// </summary> |
| | | private static bool RepairManifestClickThrough(PluginManifest manifest, IList<WidgetLayout> layouts) |
| | | { |
| | | if (manifest.DefaultLayout.ClickThrough) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | var changed = false; |
| | | var pluginId = new PluginId(manifest.Id); |
| | | for (var index = 0; index < layouts.Count; index++) |
| | | { |
| | | var layout = layouts[index]; |
| | | if (layout.PluginId == pluginId && layout.ClickThrough) |
| | | { |
| | | layouts[index] = layout with { ClickThrough = false }; |
| | | changed = true; |
| | | } |
| | | } |
| | | |
| | | return changed; |
| | | } |
| | | |
| | | private static bool IsAudioVisualizer(PluginManifest manifest) |
| | | => string.Equals(manifest.Id, "sample.audio-visualizer", StringComparison.OrdinalIgnoreCase); |
| | | |