From 6c86aa42fd364491198eadb651e1fba86fd8c350 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期五, 14 七月 2023 15:28:15 +0800
Subject: [PATCH] update 优化 无用加密前端加密没意义

---
 src/views/login.vue |   47 +++++++++++++++++++++++------------------------
 1 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/src/views/login.vue b/src/views/login.vue
index 0ac655c..13cbd75 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -27,6 +27,20 @@
         </div>
       </el-form-item>
       <el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">璁颁綇瀵嗙爜</el-checkbox>
+      <el-form-item style="float: right;">
+        <el-button circle title="寰俊鐧诲綍" @click="doSocialLogin('wechat')" >
+          <svg-icon icon-class="wechat" />
+        </el-button>
+        <el-button circle title="MaxKey鐧诲綍" @click="doSocialLogin('maxkey')" >
+          <svg-icon icon-class="maxkey" />
+        </el-button>
+        <el-button circle title="Gitee鐧诲綍" @click="doSocialLogin('gitee')" >
+          <svg-icon icon-class="gitee" />
+        </el-button>
+        <el-button circle title="Github鐧诲綍" @click="doSocialLogin('github')" >
+          <svg-icon icon-class="github" />
+        </el-button>
+      </el-form-item>
       <el-form-item style="width:100%;">
         <el-button :loading="loading" size="large" type="primary" style="width:100%;" @click.prevent="handleLogin">
           <span v-if="!loading">鐧� 褰�</span>
@@ -36,20 +50,6 @@
           <router-link class="link-type" :to="'/register'">绔嬪嵆娉ㄥ唽</router-link>
         </div>
       </el-form-item>
-      <div style="display: flex;justify-content: flex-end;flex-direction: row;">
-        <el-button circle>
-          <svg-icon icon-class="qq" @click="doSocialLogin('qq')" />
-        </el-button>
-        <el-button circle>
-          <svg-icon icon-class="wechat" @click="doSocialLogin('wechat')" />
-        </el-button>
-        <el-button circle>
-          <svg-icon icon-class="gitee" @click="doSocialLogin('gitee')" />
-        </el-button>
-        <el-button circle>
-          <svg-icon icon-class="github" @click="doSocialLogin('github')" />
-        </el-button>
-      </div>
     </el-form>
     <!--  搴曢儴  -->
     <div class="el-login-footer">
@@ -65,14 +65,14 @@
 import { encrypt, decrypt } from '@/utils/jsencrypt';
 import { useUserStore } from '@/store/modules/user';
 import { LoginData, TenantVO } from '@/api/types';
-import { ElForm, FormRules } from 'element-plus';
 import { to } from 'await-to-js';
+import { HttpStatus } from "@/enums/RespEnum";
 
 const userStore = useUserStore();
 const router = useRouter();
 
 const loginForm = ref<LoginData>({
-  tenantId: "000000",
+  tenantId: '000000',
   username: 'admin',
   password: 'admin123',
   rememberMe: false,
@@ -80,7 +80,7 @@
   uuid: ''
 });
 
-const loginRules: FormRules = {
+const loginRules: ElFormRules = {
   tenantId: [{ required: true, trigger: "blur", message: "璇疯緭鍏ユ偍鐨勭鎴风紪鍙�" }],
   username: [{ required: true, trigger: 'blur', message: '璇疯緭鍏ユ偍鐨勮处鍙�' }],
   password: [{ required: true, trigger: 'blur', message: '璇疯緭鍏ユ偍鐨勫瘑鐮�' }],
@@ -98,19 +98,19 @@
 // 娉ㄥ唽寮�鍏�
 const register = ref(false);
 const redirect = ref(undefined);
-const loginRef = ref(ElForm);
+const loginRef = ref<ElFormInstance>();
 // 绉熸埛鍒楄〃
 const tenantList = ref<TenantVO[]>([]);
 
 const handleLogin = () => {
-  loginRef.value.validate(async (valid: boolean, fields: any) => {
+  loginRef.value?.validate(async (valid: boolean, fields: any) => {
     if (valid) {
       loading.value = true;
       // 鍕鹃�変簡闇�瑕佽浣忓瘑鐮佽缃湪 cookie 涓缃浣忕敤鎴峰悕鍜屽瘑鐮�
       if (loginForm.value.rememberMe) {
         Cookies.set("tenantId", loginForm.value.tenantId, { expires: 30 });
         Cookies.set('username', loginForm.value.username, { expires: 30 });
-        Cookies.set('password', String(encrypt(loginForm.value.password)), { expires: 30 });
+        Cookies.set('password', String(loginForm.value.password), { expires: 30 });
         Cookies.set('rememberMe', String(loginForm.value.rememberMe), { expires: 30 });
       } else {
         // 鍚﹀垯绉婚櫎
@@ -120,7 +120,6 @@
         Cookies.remove('rememberMe');
       }
       // 璋冪敤action鐨勭櫥褰曟柟娉�
-      // prittier-ignore
       const [err] = await to(userStore.login(loginForm.value));
       if (!err) {
         await router.push({ path: redirect.value || '/' });
@@ -158,7 +157,7 @@
   loginForm.value = {
     tenantId: tenantId === undefined ? loginForm.value.tenantId : tenantId,
     username: username === undefined ? loginForm.value.username : username,
-    password: password === undefined ? loginForm.value.password : (decrypt(password) as string),
+    password: password === undefined ? loginForm.value.password : String(password),
     rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
   };
 }
@@ -179,7 +178,7 @@
 }
 
 //妫�娴嬬鎴烽�夋嫨妗嗙殑鍙樺寲
-watch(() => loginForm.value.tenantId, (val: string) => {
+watch(() => loginForm.value.tenantId, () => {
   Cookies.set("tenantId", loginForm.value.tenantId, { expires: 30 })
 });
 
@@ -189,7 +188,7 @@
  */
 const doSocialLogin = (type: string) => {
   authBinding(type).then((res: any) => {
-    if (res.code === 200) {
+    if (res.code === HttpStatus.SUCCESS) {
       // 鑾峰彇鎺堟潈鍦板潃璺宠浆
       window.location.href = res.data;
     } else {

--
Gitblit v1.9.3