Просмотр исходного кода

Merge branch 'next' of https://gitee.com/zuohuaijun/Admin.NET into next

zuohuaijun 2 лет назад
Родитель
Сommit
99cbd93476

+ 3 - 3
Admin.NET/Admin.NET.Core/Extension/RepositoryExtension.cs

@@ -131,13 +131,13 @@ public static class RepositoryExtension
     /// <param name="queryable"></param>
     /// <param name="pageInput"> </param>
     /// <param name="prefix"> </param>
-    /// <param name="defualtSortField"> 默认排序字段 </param>
+    /// <param name="defaultSortField"> 默认排序字段 </param>
     /// <param name="descSort"> 是否降序 </param>
     /// <returns> </returns>
-    public static ISugarQueryable<T> OrderBuilder<T>(this ISugarQueryable<T> queryable, BasePageInput pageInput, string prefix = "", string defualtSortField = "Id", bool descSort = true)
+    public static ISugarQueryable<T> OrderBuilder<T>(this ISugarQueryable<T> queryable, BasePageInput pageInput, string prefix = "", string defaultSortField = "Id", bool descSort = true)
     {
         // 约定默认每张表都有Id排序
-        var orderStr = string.IsNullOrWhiteSpace(defualtSortField) ? "" : descSort ? defualtSortField + " Desc" : defualtSortField + " Asc";
+        var orderStr = string.IsNullOrWhiteSpace(defaultSortField) ? "" : descSort ? defaultSortField + " Desc" : defaultSortField + " Asc";
 
         TypeAdapterConfig typeAdapterConfig = new();
         typeAdapterConfig.ForType<T, BasePageInput>().IgnoreNullValues(true);

+ 34 - 9
Admin.NET/Admin.NET.Core/Service/CodeGen/SysCodeGenService.cs

@@ -640,16 +640,41 @@ public class SysCodeGenService : IDynamicApiController, ITransient
         var formModalPath = Path.Combine(frontendPath, input.TableName[..1].ToLower() + input.TableName[1..], "component", "editDialog.vue");
         var apiJsPath = Path.Combine(new DirectoryInfo(App.WebHostEnvironment.ContentRootPath).Parent.Parent.FullName, _codeGenOptions.FrontRootPath, "src", "api", "main", input.TableName[..1].ToLower() + input.TableName[1..] + ".ts");
 
-        return new List<string>()
+        if (input.GenerateType.Substring(1, 1).Contains('1'))
         {
-            servicePath,
-            inputPath,
-            outputPath,
-            viewPath,
-            indexPath,
-            formModalPath,
-            apiJsPath
-        };
+            //生成到本项目(前端)
+            return new List<string>()
+            {
+                indexPath,
+                formModalPath,
+                apiJsPath
+            };
+        }
+        else if (input.GenerateType.Substring(1, 1).Contains("2"))
+        {
+            //生成到本项目(后端)
+            return new List<string>()
+            {
+                servicePath,
+                inputPath,
+                outputPath,
+                viewPath,
+            };
+        }
+        else
+        {
+            //前后端同时生成到本项目
+            return new List<string>()
+            {
+                servicePath,
+                inputPath,
+                outputPath,
+                viewPath,
+                indexPath,
+                formModalPath,
+                apiJsPath
+            };
+        }
     }
 
     /// <summary>

+ 6 - 0
Web/src/views/system/file/index.vue

@@ -110,6 +110,7 @@
 		<el-drawer :title="state.fileName" v-model="state.dialogPdfVisible" size="50%" destroy-on-close>
 			<vue-office-pdf :src="state.pdfUrl" style="height: 100vh" @rendered="renderedHandler" @error="errorHandler"
 		/></el-drawer>
+		<el-image-viewer v-if="state.showViewer" :url-list="state.previewList" @close="state.showViewer = false"></el-image-viewer>
 	</div>
 </template>
 
@@ -147,10 +148,12 @@ const state = reactive({
 	dialogDocxVisible: false,
 	dialogXlsxVisible: false,
 	dialogPdfVisible: false,
+	showViewer: false,
 	docxUrl: '',
 	excelUrl: '',
 	pdfUrl: '',
 	fileName: '',
+	previewList: [] as string[],
 });
 
 onMounted(async () => {
@@ -234,6 +237,9 @@ const openFilePreviewDialog = async (row: any) => {
 		state.fileName = `【${row.fileName}${row.suffix}】`;
 		state.excelUrl = getFileUrl(row);
 		state.dialogXlsxVisible = true;
+	} else if (['.jpg', '.png', '.jpeg', '.bmp'].findIndex((e) => e == row.suffix) > -1) {
+		state.previewList = [getFileUrl(row)];
+		state.showViewer = true;
 	} else {
 		ElMessage.error('此文件格式不支持预览');
 	}