From 9c7477aaf3dc3b84f9810874504ebe5478ab0105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E6=9D=B0=E5=88=9A?= <1543758718@qq.com> Date: Fri, 23 May 2025 00:20:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=AF=86=E7=A0=81md5?= =?UTF-8?q?=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/main.ts | 4 +++- src/pages/login/index.vue | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 86b5289..b54308f 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "dayjs": "1.11.13", "element-plus": "2.9.7", "js-cookie": "3.0.5", + "js-md5": "0.8.3", "lodash-es": "4.17.21", "mitt": "3.0.1", "normalize.css": "8.0.1", diff --git a/src/main.ts b/src/main.ts index 5852e16..a9ca3d7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,10 +12,12 @@ import "element-plus/theme-chalk/dark/css-vars.css"; import "vxe-table/lib/style.css"; import "@@/assets/styles/index.scss"; import "virtual:uno.css"; +import md5 from 'js-md5'; // 创建应用实例 const app = createApp(App); - +//md5 +app.provide('md5', md5); // 安装插件(全局组件、自定义指令等) installPlugins(app); diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index f6055b6..ba043cb 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -12,7 +12,9 @@ import { Lock, User, Iphone, Promotion, Check } from "@element-plus/icons-vue"; import { loginApi } from "./apis"; import Owl from "./components/Owl.vue"; import { useFocus } from "./composables/useFocus"; -import { reactive, ref } from "vue"; +import { reactive, ref ,inject } from "vue"; +const $md5 = inject('md5') + const router = useRouter(); const userStore = useUserStore(); @@ -154,6 +156,7 @@ async function handleUserLogin(formEl) { await formEl.validate((valid, fields) => { if (valid) { loading.value = true; + loginFormData.password = $md5(loginFormData.password) loginApi(loginFormData) .then(({ data }) => { userStore.setToken(data.token);