ZaiZai 11 сар өмнө
parent
commit
3d8892c348

+ 1 - 2
src/config/index.js

@@ -19,7 +19,6 @@ export default {
     cryptoKey: '', //token加密key 使用@org.springblade.test.CryptoKeyGenerator获取,需和后端配置保持一致
     aesKey: '', //报文加密key 使用@org.springblade.test.CryptoKeyGenerator获取,需和后端配置保持一致
     desKey: '', //报文加密key 使用@org.springblade.test.CryptoKeyGenerator获取,需和后端配置保持一致
-    localModel: false, //本地模式,开启后,将关闭https强转、截图等相关功能
-    localLogin: false, //本地模式,自动登录
+    localModel: true, //本地模式,开启后,将关闭https强转、截图等相关功能
     ...config,
 }

+ 24 - 17
src/views/login/index.vue

@@ -1,5 +1,5 @@
 <template>
-    <div v-loading="loginLoading" class="hc-login-body hc-full">
+    <div class="hc-login-body hc-full">
         <img class="hc-login-bg" :src="bg1Png" :data-src="bgPng" loading="lazy" alt="bg">
         <img class="hc-login-img" :src="imgPng" :data-src="imgPng" loading="lazy" alt="bg">
         <div class="hc-login-main hc-h-full hc-flex-center w-[50%]">
@@ -31,13 +31,12 @@
 </template>
 
 <script setup>
-import { onMounted, ref } from 'vue'
+import { nextTick, onMounted, ref } from 'vue'
 import router from '~src/router/index'
 import { useAppStore } from '~src/store'
-import { formValidate } from 'js-fast-way'
+import { deepClone, formValidate } from 'js-fast-way'
 import { useAppLogin } from '~store/user'
-import config from '~src/config/index'
-
+import { getStore, setStore } from '~src/utils/storage'
 //图片文件
 import bg1Png from '~src/assets/login/bg1.png'
 import bgPng from '~src/assets/login/bg.png'
@@ -46,26 +45,25 @@ import imgPng from '~src/assets/login/img.png'
 //初始化
 const store = useAppStore()
 
-const loginLoading = ref(false)
-onMounted(() => {
+onMounted(async () => {
+    const username = deepClone(getStore('login-username') || '')
+    const password = deepClone(getStore('login-password') || '')
+    const checkboxs = deepClone(getStore('login-checkbox') || '')
+    formValue.value.username = username
+    formValue.value.password = password
+    checkbox.value = checkboxs
+    await nextTick()
     store.clearStoreData() //先清理下缓存
+    setLoginData()
     // 兼容性脚本,如果loading属性不被支持
     document.querySelectorAll('img[loading="lazy"]').forEach((img) => {
         img.src = img.dataset.src
     })
-    //本地模式,自动登录
-    if (config.localLogin) {
-        loading.value = true
-        loginLoading.value = true
-        formValue.value.username = 'admin'
-        formValue.value.password = 'admin'
-        formValidateClick()
-    }
 })
 
 //表单
 const formRef = ref(null)
-const checkbox = ref(false)
+const checkbox = ref(true)
 const formValue = ref({ tenantId: '000000', username: '', password: '', type: 'account' })
 const formRules = {
     username: {
@@ -102,12 +100,21 @@ const formValidateClick = async () => {
     //登录成功
     loading.value = false
     window?.$message?.success('登录成功')
+    setLoginData()
     setTimeout(() => {
         loading.value = false
-        loginLoading.value = false
         router.push({ name: store.home })
     }, 1500)
 }
+
+//缓存账号密码
+const setLoginData = () => {
+    if (checkbox.value) {
+        setStore('login-username', formValue.value.username)
+        setStore('login-password', formValue.value.password)
+    }
+    setStore('login-checkbox', checkbox.value)
+}
 </script>
 
 <style lang="scss">

+ 1 - 1
vite.config.js

@@ -6,7 +6,7 @@ import config from './src/config'
 
 // https://vitejs.dev/config/
 export default defineConfig({
-    //base: './',
+    base: './',
     css: {
         extract: true,
     },