feat:跟新密码加密 共享白板功能
This commit is contained in:
@@ -27,14 +27,17 @@
|
||||
|
||||
<script setup>
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
import { watch, ref, getCurrentInstance } from 'vue'
|
||||
import { watch, ref, getCurrentInstance,onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useMeterStore } from '@/stores/modules/meter'
|
||||
import CryptoJS from 'crypto-js';
|
||||
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
const { proxy } = getCurrentInstance()
|
||||
const redirect = ref(undefined);
|
||||
const emit = defineEmits(['loginSuccess'])
|
||||
const meterStore = useMeterStore()
|
||||
|
||||
const loginForm = ref({
|
||||
username: '',
|
||||
@@ -52,14 +55,31 @@ function handleLogin() {
|
||||
proxy.$refs.loginRef.validate((valid) => {
|
||||
if (valid) {
|
||||
loading.value = true
|
||||
if(!localStorage?.getItem('UDID')){
|
||||
ElMessage({
|
||||
message: '服务错误,请刷新页面',
|
||||
type: 'warning',
|
||||
})
|
||||
return
|
||||
}
|
||||
const secretKey = ((loginForm.value.username + localStorage?.getItem('UDID')).toLowerCase()).replaceAll('-', ''); // 用户名+UDID(32位16进制,全小写)
|
||||
|
||||
const randomChars = generateRandomChars(6);
|
||||
|
||||
const message = `Gx${randomChars}${loginForm.value.password}`;
|
||||
|
||||
const ciphertext = CryptoJS.Blowfish.encrypt(message, secretKey).toString();
|
||||
|
||||
|
||||
// 调用action的登录方法
|
||||
userStore
|
||||
.login({
|
||||
password: loginForm.value.password,
|
||||
password: ciphertext,
|
||||
// password: loginForm.value.password,
|
||||
username: loginForm.value.username,
|
||||
})
|
||||
.then(async (res) => {
|
||||
const userInfo = JSON.parse(localStorage.getItem('userData'))
|
||||
const userInfo = JSON.parse(sessionStorage.getItem('userData'))
|
||||
emit('loginSuccess', userInfo)
|
||||
})
|
||||
.catch((e) => {
|
||||
@@ -71,6 +91,16 @@ function handleLogin() {
|
||||
requestNotificationPermission()
|
||||
}
|
||||
|
||||
// 生成随机字符串
|
||||
function generateRandomChars(length) {
|
||||
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
let result = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 请求浏览器的通知权限
|
||||
* @returns {*}
|
||||
@@ -83,6 +113,10 @@ function requestNotificationPermission() {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
meterStore.initUdid()
|
||||
})
|
||||
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.wrapper-content {
|
||||
|
||||
Reference in New Issue
Block a user