Browse Source

Merge pull request #15016 from abpframework/liangshiwei/cli

Change theme for MauiBlazor
pull/15019/head
maliming 4 years ago
committed by GitHub
parent
commit
e979d40c5e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 82
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs

82
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ChangeThemeStep.cs

@ -225,6 +225,12 @@ public class ChangeThemeStep : ProjectBuildPipelineStep
ChangeThemeToLeptonForNoLayersBlazorServerProjects(context);
#endregion
#region MyCompanyName.MyProjectName.MauiBlazor
ChangeThemeToLeptonForMauiBlazorProjects(context);
#endregion
}
private void ConfigureLeptonManagementPackagesForNoLayersMvc(ProjectBuildContext context, string targetProjectPath, string[] projectNames)
@ -488,6 +494,33 @@ public class ChangeThemeStep : ProjectBuildPipelineStep
file.SetLines(lines);
}
protected void ChangeKeyword(
ProjectBuildContext context,
string targetModuleFilePath,
string oldKeyword,
string newKeyword)
{
var file = context.Files.FirstOrDefault(x => x.Name.Contains(targetModuleFilePath));
if (file == null)
{
return;
}
file.NormalizeLineEndings();
var lines = file.GetLines();
for (var i = 0; i < lines.Length; i++)
{
if (lines[i].Contains(oldKeyword))
{
lines[i] = lines[i].Replace(oldKeyword, newKeyword);
}
}
file.SetLines(lines);
}
protected void ReplaceImportPackage(
ProjectBuildContext context,
string filePath,
@ -973,4 +1006,53 @@ public class ChangeThemeStep : ProjectBuildPipelineStep
);
}
}
private void ChangeThemeToLeptonForMauiBlazorProjects(ProjectBuildContext context)
{
ReplacePackageReferenceWithProjectReference(
context,
"/MyCompanyName.MyProjectName.MauiBlazor/MyCompanyName.MyProjectName.MauiBlazor.csproj",
"Volo.Abp.AspNetCore.Components.MauiBlazor.LeptonXTheme",
@"..\..\..\..\..\lepton-theme\src\Volo.Abp.AspNetCore.Components.MauiBlazor.LeptonTheme\Volo.Abp.AspNetCore.Components.MauiBlazor.LeptonTheme.csproj"
);
ChangeNamespaceAndKeyword(
context,
"/MyCompanyName.MyProjectName.MauiBlazor/MyProjectNameMauiBlazorModule.cs",
"Volo.Abp.AspNetCore.Components.MauiBlazor.LeptonXTheme",
"Volo.Abp.AspNetCore.Components.MauiBlazor.LeptonTheme",
"AbpAspNetCoreComponentsMauiBlazorLeptonXThemeModule",
"AbpAspNetCoreComponentsMauiBlazorLeptonThemeModule"
);
ChangeKeyword(
context,
"/MyCompanyName.MyProjectName.MauiBlazor/MainPage.xaml",
"clr-namespace:Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components;assembly=Volo.Abp.AspNetCore.Components.Web.LeptonXTheme",
"clr-namespace:Volo.Abp.AspNetCore.Components.Web.LeptonTheme.Components;assembly=Volo.Abp.AspNetCore.Components.Web.LeptonTheme");
ChangeKeyword(
context,
"/MyCompanyName.MyProjectName.MauiBlazor/MainPage.xaml",
"leptonXTheme",
"leptonTheme");
ChangeKeyword(
context,
"/MyCompanyName.MyProjectName.MauiBlazor/Pages/Account/Login.razor",
"Volo.Abp.AspNetCore.Components.MauiBlazor.LeptonXTheme.Components.AccountLayout",
"Volo.Abp.AspNetCore.Components.MauiBlazor.LeptonTheme.Components.AccountLayout");
ChangeKeyword(
context,
"/MyCompanyName.MyProjectName.MauiBlazor/Pages/Account/RedirectToLogout.razor",
"LeptonXResource",
"LeptonThemeManagementResource");
ChangeKeyword(
context,
"/MyCompanyName.MyProjectName.MauiBlazor/Pages/Account/RedirectToLogout.razor",
"Volo.Abp.LeptonX.Shared.Localization",
"Volo.Abp.LeptonTheme.Management.Localization");
}
}

Loading…
Cancel
Save