优化天气胶囊拖动性能与插件示例迁移

完成天气胶囊在高 DPI 和窄窗口下的逐级降级布局,减少窗口拖动期间的主题与材质重建。新增三个停用的 manifest v3 插件示例、Tauri 伴随程序和构建哈希校验;旧版插件自动回收到可恢复目录。安装器升级成功后递归清理旧静态资源空目录,并补充相关文档和测试。
This commit is contained in:
2026-08-20 09:09:10 +08:00
parent e88fc8532d
commit c92f358774
28 changed files with 939 additions and 196 deletions
+77
View File
@@ -1130,6 +1130,82 @@ begin
#endif
end;
function IsPreservedDirectoryTree(const RelativePath: string): Boolean;
var
Normalized: string;
begin
Normalized := LowerCase(Trim(RelativePath));
Result :=
(Normalized = 'data') or (Pos('data\', Normalized) = 1) or
(Normalized = 'feedbackpackages') or (Pos('feedbackpackages\', Normalized) = 1) or
(Normalized = 'config') or (Pos('config\', Normalized) = 1) or
(Normalized = 'runtime\uninstall-engine') or
(Pos('runtime\uninstall-engine\', Normalized) = 1);
end;
function ManifestRequiresDirectory(const RelativePath: string): Boolean;
var
I: Integer;
DirectoryPrefix: string;
Item: string;
begin
Result := False;
DirectoryPrefix := LowerCase(RemoveBackslashUnlessRoot(RelativePath)) + '\';
for I := 0 to NewPayloadFiles.Count - 1 do
begin
Item := LowerCase(NewPayloadFiles[I]);
if Pos(DirectoryPrefix, Item) = 1 then
begin
Result := True;
Exit;
end;
end;
end;
function IsInstallDirectoryPath(const AppDir, Candidate: string): Boolean;
var
RootPath: string;
CandidatePath: string;
begin
RootPath := LowerCase(AddBackslash(RemoveBackslashUnlessRoot(AppDir)));
CandidatePath := LowerCase(AddBackslash(RemoveBackslashUnlessRoot(Candidate)));
Result := Pos(RootPath, CandidatePath) = 1;
end;
procedure RemoveEmptyInstallDirectories(const AppDir, CurrentDir: string);
var
FindRec: TFindRec;
FullPath: string;
RelativePath: string;
begin
if (not DirExists(CurrentDir)) or (not IsInstallDirectoryPath(AppDir, CurrentDir)) then
Exit;
if FindFirst(AddBackslash(CurrentDir) + '*', FindRec) then
begin
try
repeat
if (FindRec.Name <> '.') and (FindRec.Name <> '..') and
((FindRec.Attributes and DirectoryAttribute) <> 0) then
begin
FullPath := AddBackslash(CurrentDir) + FindRec.Name;
RelativePath := RelativeInstallPath(AppDir, FullPath);
if (RelativePath <> '') and
((FindRec.Attributes and $400) = 0) and
(not IsPreservedDirectoryTree(RelativePath)) then
begin
RemoveEmptyInstallDirectories(AppDir, FullPath);
if (not ManifestRequiresDirectory(RelativePath)) and RemoveDir(FullPath) then
Log('Removed empty obsolete install directory: ' + RelativePath);
end;
end;
until not FindNext(FindRec);
finally
FindClose(FindRec);
end;
end;
end;
procedure FinalizeLegacyInstallLayout();
var
AppDir: string;
@@ -1140,6 +1216,7 @@ begin
DeleteKnownObsoletePayload(AppDir)
else
QuarantineUnknownLegacyFiles(AppDir, AppDir);
RemoveEmptyInstallDirectories(AppDir, AppDir);
CleanLegacyRuntimeAndCache();
end;