浏览代码

chore: 🤓简化代码

喵你个旺呀 1 年之前
父节点
当前提交
19ed3cee8c
共有 2 个文件被更改,包括 34 次插入46 次删除
  1. 27 36
      Admin.NET/Admin.NET.Core/Service/CodeGen/SysCodeGenService.cs
  2. 7 10
      Web/src/views/login/component/account.vue

+ 27 - 36
Admin.NET/Admin.NET.Core/Service/CodeGen/SysCodeGenService.cs

@@ -680,14 +680,8 @@ public class SysCodeGenService : IDynamicApiController, ITransient
     /// <returns></returns>
     private static List<string> GetTemplatePathList(SysCodeGen input)
     {
-        if (input.GenerateType!.Substring(1, 1).Contains('1'))
-        {
-            return new() { "index.vue.vm", "editDialog.vue.vm", "api.ts.vm" };
-        }
-        if (input.GenerateType.Substring(1, 1).Contains('2'))
-        {
-            return new() { "Service.cs.vm", "Input.cs.vm", "Output.cs.vm", "Dto.cs.vm" };
-        }
+        if (input.GenerateType!.Substring(1, 1).Contains('1')) return new() { "index.vue.vm", "editDialog.vue.vm", "api.ts.vm" };
+        if (input.GenerateType.Substring(1, 1).Contains('2')) return new() { "Service.cs.vm", "Input.cs.vm", "Output.cs.vm", "Dto.cs.vm" };
         return new() { "Service.cs.vm", "Input.cs.vm", "Output.cs.vm", "Dto.cs.vm", "index.vue.vm", "editDialog.vue.vm", "api.ts.vm" };
     }
 
@@ -725,7 +719,8 @@ public class SysCodeGenService : IDynamicApiController, ITransient
                 apiJsPath
             };
         }
-        else if (input.GenerateType.Substring(1, 1).Contains('2'))
+
+        if (input.GenerateType.Substring(1, 1).Contains('2'))
         {
             // 生成到本项目(后端)
             return new List<string>()
@@ -736,20 +731,17 @@ public class SysCodeGenService : IDynamicApiController, ITransient
                 viewPath,
             };
         }
-        else
-        {
-            // 前后端同时生成到本项目
-            return new List<string>()
-            {
-                servicePath,
-                inputPath,
-                outputPath,
-                viewPath,
-                indexPath,
-                formModalPath,
-                apiJsPath
-            };
-        }
+        // 前后端同时生成到本项目
+        return new List<string>()
+        {
+            servicePath,
+            inputPath,
+            outputPath,
+            viewPath,
+            indexPath,
+            formModalPath,
+            apiJsPath
+        };
     }
 
     /// <summary>
@@ -780,7 +772,8 @@ public class SysCodeGenService : IDynamicApiController, ITransient
                 apiJsPath
             };
         }
-        else if (input.GenerateType.StartsWith("12"))
+
+        if (input.GenerateType.StartsWith("12"))
         {
             return new List<string>()
             {
@@ -790,18 +783,16 @@ public class SysCodeGenService : IDynamicApiController, ITransient
                 viewPath
             };
         }
-        else
+
+        return new List<string>()
         {
-            return new List<string>()
-            {
-                servicePath,
-                inputPath,
-                outputPath,
-                viewPath,
-                indexPath,
-                formModalPath,
-                apiJsPath
-            };
-        }
+            servicePath,
+            inputPath,
+            outputPath,
+            viewPath,
+            indexPath,
+            formModalPath,
+            apiJsPath
+        };
     }
 }

+ 7 - 10
Web/src/views/login/component/account.vue

@@ -140,10 +140,8 @@ let timer: any = null;
 // 页面初始化
 onMounted(async () => {
 	// 若URL带有Token参数(第三方登录)
-	var accessToken = route.query.token;
-	if (accessToken != null && accessToken != undefined) {
-		await saveTokenAndInitRoutes(accessToken);
-	}
+	const accessToken = route.query.token;
+	if (accessToken) await saveTokenAndInitRoutes(accessToken);
 
 	// 获取登录配置
 	state.secondVerEnabled = themeConfig.value.secondVer ?? true;
@@ -174,8 +172,7 @@ onUnmounted(() => {
 
 // 检测大小写按键
 const handleKeyPress = (e: KeyboardEvent) => {
-	const isCapsLockOn = e.getModifierState('CapsLock');
-	state.capsLockVisible = isCapsLockOn;
+	state.capsLockVisible = e.getModifierState('CapsLock');
 };
 
 // 获取验证码
@@ -183,10 +180,10 @@ const getCaptcha = async () => {
 	if (!state.captchaEnabled) return;
 
 	state.ruleForm.code = '';
-	var res = await getAPI(SysAuthApi).apiSysAuthCaptchaGet();
-	state.captchaImage = 'data:text/html;base64,' + res.data.result?.img;
-	state.ruleForm.codeId = res.data.result?.id;
-	state.expirySeconds = res.data.result?.expirySeconds;
+	const res = await getAPI(SysAuthApi).apiSysAuthCaptchaGet().then(res => res.data.result);
+	state.captchaImage = 'data:text/html;base64,' + res?.img;
+	state.expirySeconds = res?.expirySeconds;
+  state.ruleForm.codeId = res?.id;
 };
 
 // 获取时间