![]() |
VOOZH | about |
dotnet add package Rong.Volo.Abp.CodeGenerator.Vue --version 9.1.1
NuGet\Install-Package Rong.Volo.Abp.CodeGenerator.Vue -Version 9.1.1
<PackageReference Include="Rong.Volo.Abp.CodeGenerator.Vue" Version="9.1.1" />
<PackageVersion Include="Rong.Volo.Abp.CodeGenerator.Vue" Version="9.1.1" />Directory.Packages.props
<PackageReference Include="Rong.Volo.Abp.CodeGenerator.Vue" />Project file
paket add Rong.Volo.Abp.CodeGenerator.Vue --version 9.1.1
#r "nuget: Rong.Volo.Abp.CodeGenerator.Vue, 9.1.1"
#:package Rong.Volo.Abp.CodeGenerator.Vue@9.1.1
#addin nuget:?package=Rong.Volo.Abp.CodeGenerator.Vue&version=9.1.1Install as a Cake Addin
#tool nuget:?package=Rong.Volo.Abp.CodeGenerator.Vue&version=9.1.1Install as a Cake Tool
[DependsOn(
……
//代码生成模块
typeof(RongVoloAbpCodeGeneratorVueModule)
……
)]
public class YourModule : AbpModule
VueBoolAttribute:bool 组件
VueDictionaryAttribute: 字典组件
VueEditorAttribute:编辑器组件
VueEnumAttribute:枚举组件
VueFileAttribute:文件组件
VueTableSorterAttribute:table是否排序组件
VueTextareaAttribute:内容输入组件
VueValueNameAttribute:对象点拼接显示的属性名称, 如 student.name
VueComponentAttribute: 使用组件
针对 枚举下拉组件,字典下拉组件,bool 下拉组件,文件上传组件,文件预览组件,编辑器 组件,可通过 CodeGeneratorVueOptions 配置来指定,不指定则使用默认组件:
//vue代码生成器
Configure<RongVoloAbpCodeGeneratorVueOptions>(options =>
{
//指定版本
options.VbenVersion = VbenVersionEnum.Vben2;
//Ant 的 Tabled 的 DataIndex 嵌套模式:。默认 Array
//2.x 版本 为 a.b.c
//3.x,4.x 版本 为 ['a','b','c']
options.AntTabledDataIndexMode = AntTabledDataIndexModeEnum.Array;
//Vben 组件替换
options.ComponentMapForVben = new();
//枚举Select
options.EnumSelectComponent = "MyEnumSelect";
options.EnumSelectComponentProp = "code";
//枚举Radio
options.EnumRadioComponent = "MyEnumRadio";
options.EnumRadioComponentProp = "code";
//枚举Checkbox
options.EnumCheckboxComponent = "MyEnumCheckbox";
options.EnumCheckboxComponentProp = "code";
//字典Select
options.DictionarySelectComponent = "MyDictSelect";
options.DictionarySelectComponentProp = "code";
//字典Radio
options.DictionaryRadioComponent = "MyDictRadio";
options.DictionaryRadioComponentProp = "code";
//字典Checkbox
options.DictionaryCheckboxComponent = "MyDictCheckbox";
options.DictionaryCheckboxComponentProp = "code";
//bool
options.BoolSelectComponent = "MyBoolSelect";
options.BoolRadioComponent = "MyBoolRadio";
//文件上传
options.FileUploadComponent = "MyUploadFile";
//图片上传
options.ImageUploadComponent = "MyUploadFile";
//文件预览
options.FilePreviewComponent = "MyFileViewList";
options.FilePreviewComponentProp = "fileList";
//图片预览
options.ImagePreviewComponent = "MyImagePreview";
options.ImagePreviewComponentProp = "fileId";
//编辑器
options.EditorComponent = "MyEditor";
//使用组件进行展示 prop,默认 value
options.VueComponentViewProp = "value";
});
依赖注入 RongVoloAbpCodeGeneratorVueStore 来生成
例子:创建如下控制器,运行 http://localhost:端口/codevue/go ,返回 ok 则生成成功
public class CodeVueController : AbpController
{
private readonly RongVoloAbpCodeGeneratorVueStore _codeGeneratorStore;
public CodeVueController(RongVoloAbpCodeGeneratorVueStore codeGeneratorStore)
{
_codeGeneratorStore = codeGeneratorStore;
}
/// <summary>
/// 代码生成 - 方式1
/// </summary>
/// <returns></returns>+
public async Task<ActionResult> GoAsync()
{
List<TemplateVueModel> list = new List<TemplateVueModel>();
var entitys = typeof(CodeGeneratorDomainModule).Assembly.GetTypes()
.Where(x => typeof(IEntity).IsAssignableFrom(x));
var dtos = typeof(CodeGeneratorApplicationContractsModule).Assembly.GetTypes();
foreach (var entity in entitys)
{
var name = entity.Name;
var displayName = entity.GetCustomAttribute<DisplayAttribute>()?.Name ?? name;
var page = dtos.FirstOrDefault(a => a.Name == $"{name}PageOutput");
var search = dtos.FirstOrDefault(a => a.Name == $"{name}PageSearchInput");
var create = dtos.FirstOrDefault(a => a.Name == $"{name}CreateInput");
var update = dtos.FirstOrDefault(a => a.Name == $"{name}UpdateInput");
var detail = dtos.FirstOrDefault(a => a.Name == $"{name}DetailOutput");
var permission = dtos.FirstOrDefault(a => a.Name == $"{name}Permissions");
string? permissionGroup = permission?.GetField("GroupName")?.GetValue(null)?.ToString();
list.Add(new TemplateVueModel(name, displayName, new TemplateVueModelType()
{
SearchType = search,
PageType = page,
DetailType = detail,
CreateType = create,
UpdateType = update,
}, permissionGroup));
}
//开始生成
await _codeGeneratorStore.StartAsync(list, CodeGeneratorRemoteServiceConsts.RootPath, "E:\\MY\\Rong.CodeGenerator\\vue\\vben_demo", new []{"app"});
return Content("ok");
}}
/// <summary>
/// 代码生成 - 方式二
/// </summary>
/// <returns></returns>+
public async Task<ActionResult> GoAsync()
{
//开始生成
await _codeGeneratorStore.StartAsync(typeof(IEntity),
typeof(CodeGeneratorDomainModule),
typeof(CodeGeneratorApplicationContractsModule),
CodeGeneratorRemoteServiceConsts.RootPath,
"E:\\MY\\Rong.CodeGenerator\\vue\\vben_demo",
//要忽略生成的实体
new []{typeof(App)});
return Content("ok");
}
}
1.生成的页面文件在 src/views/ 下,以“小驼峰实体名”为文件夹名:
新增页:add.vue
修改页:modify.vue
主页:index.vue
详情页:detail.vue
详情弹框页: detailDrawer.vue
api接口:api.ts
2.路由: 在src/router/routes/modules/ 下,以“小驼峰实体名”命名:
xxx.ts
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.