Skip to content

Commit

Permalink
增加vue3单表/多表代码生成器
Browse files Browse the repository at this point in the history
  • Loading branch information
yubaolee committed Oct 5, 2022
1 parent 9412ee4 commit a3a8bd5
Show file tree
Hide file tree
Showing 6 changed files with 1,512 additions and 7 deletions.
45 changes: 38 additions & 7 deletions OpenAuth.App/BuilderTable/BuilderTableApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,29 @@ public void CreateVue(CreateVueReq req)

if (subTable == null) //如果子表不存在,则用单模版生成
{
if (sysTableInfo.IsDynamicHeader)
if (req.Version == "vue3")
{
domainContent = FileHelper.ReadFile(@"Template\\SingleTable\\BuildVueWithDynamicHeader.html");
if (sysTableInfo.IsDynamicHeader)
{
domainContent = FileHelper.ReadFile(@"Template\\SingleTable\\BuildVue3WithDynamicHeader.html");
}
else
{
domainContent = FileHelper.ReadFile(@"Template\\SingleTable\\BuildVue3.html");
}
}
else
{
domainContent = FileHelper.ReadFile(@"Template\\SingleTable\\BuildVue.html");
if (sysTableInfo.IsDynamicHeader)
{
domainContent = FileHelper.ReadFile(@"Template\\SingleTable\\BuildVueWithDynamicHeader.html");
}
else
{
domainContent = FileHelper.ReadFile(@"Template\\SingleTable\\BuildVue.html");
}
}


domainContent = domainContent.Replace("{ClassName}", sysTableInfo.ClassName)
.Replace("{TableName}", sysTableInfo.ClassName.ToCamelCase())
Expand All @@ -660,16 +675,32 @@ public void CreateVue(CreateVueReq req)
var subTableColumns = _builderTableColumnApp.Find(subTable.Id);
if (subTableColumns.Count == 0)
throw new Exception($"未找到子表{subTable.ClassName}的字段定义");

if (sysTableInfo.IsDynamicHeader)
if (req.Version == "vue3")
{
domainContent = FileHelper.ReadFile(@"Template\\MultiTable\\BuildVueWithDynamicHeader.html");
if (sysTableInfo.IsDynamicHeader)
{
domainContent = FileHelper.ReadFile(@"Template\\MultiTable\\BuildVue3WithDynamicHeader.html");
}
else
{
domainContent = FileHelper.ReadFile(@"Template\\MultiTable\\BuildVue3.html");
}
}
else
{
domainContent = FileHelper.ReadFile(@"Template\\MultiTable\\BuildVue.html");
if (sysTableInfo.IsDynamicHeader)
{
domainContent = FileHelper.ReadFile(@"Template\\MultiTable\\BuildVueWithDynamicHeader.html");
}
else
{
domainContent = FileHelper.ReadFile(@"Template\\MultiTable\\BuildVue.html");
}
}



domainContent = domainContent.Replace("{ParentTableId}", subTable.ForeignKey.ToCamelCase())
.Replace("{FirstTableName}", sysTableInfo.ClassName.ToCamelCase())
.Replace("{SecondTableName}", subTable.ClassName.ToCamelCase())
Expand Down
6 changes: 6 additions & 0 deletions OpenAuth.App/BuilderTable/Request/CreateVueReq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ public class CreateVueReq
/// vue项目所在的根目录,如:D:\OpenAuth.Pro\Client
/// </summary>
public string VueProjRootPath { get; set; }

/// <summary>
/// 版本信息
/// 值为vue2/vue3,默认为vue2
/// </summary>
public string Version { get; set; }
}
}
Loading

0 comments on commit a3a8bd5

Please sign in to comment.