feat:跟新密码加密 共享白板功能

This commit is contained in:
leilei
2025-10-11 17:28:20 +08:00
parent e429e4286a
commit db72ea9f33
18 changed files with 1434 additions and 412 deletions

View File

@@ -40,15 +40,20 @@
import useUserStore from '@/stores/modules/user'
import { watch, ref, getCurrentInstance, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElNotification } from 'element-plus'
import { getInfo } from "@/api/login";
import { ElNotification,ElMessage } from 'element-plus'
import { getInfo } from "@/api/login";
import CryptoJS from 'crypto-js';
import { useMeterStore } from '@/stores/modules/meter'
const userStore = useUserStore()
const router = useRouter()
const route = useRoute()
const { proxy } = getCurrentInstance()
const showLogin = ref(false)
const meterStore = useMeterStore()
const redirect = ref(undefined);
const loginView = ref(false)
@@ -73,14 +78,30 @@ 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();
console.log(secretKey,message,ciphertext)
// 调用action的登录方法
userStore
.login({
password: loginForm.value.password,
// password: loginForm.value.password,
password: ciphertext,
username: loginForm.value.username,
})
.then(async (res) => {
const userInfo = JSON.parse(localStorage.getItem('userData'))
.then(async (res) => {
const userInfo = JSON.parse(sessionStorage.getItem('userData'))
router.push({
path: '/coordinate',
})
@@ -99,6 +120,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 {*}
@@ -113,6 +144,7 @@ function requestNotificationPermission() {
onMounted(async () => {
meterStore.initUdid()
try {
loginView.value = true
const res = await getInfo("self");
@@ -125,8 +157,8 @@ onMounted(async () => {
// query: { room_uid: 'nxst-ok4j' }
// })
router.push({
path: '/coordinate',
})
path: '/coordinate',
})
}
loginView.value = false
} catch (err) {