From 2c3acbcaafa1dba3536577c0909ad4d7823a8b92 Mon Sep 17 00:00:00 2001 From: zhaoyz <11@22.com> Date: Wed, 13 Mar 2024 16:54:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=B0=83=E8=AF=95=E9=80=9A?= =?UTF-8?q?=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 1 + index.html | 13 +- package.json | 3 +- src/api/acl/login.ts | 26 ++ src/utils/other.ts | 33 ++ src/views/login/login.vue | 813 ++++++++++++++++++++------------------ vite.config.ts | 10 + 7 files changed, 497 insertions(+), 402 deletions(-) create mode 100644 .env create mode 100644 src/api/acl/login.ts create mode 100644 src/utils/other.ts diff --git a/.env b/.env new file mode 100644 index 0000000..7b6326e --- /dev/null +++ b/.env @@ -0,0 +1 @@ +VITE_PWD_ENC_KEY='thanks,rax' \ No newline at end of file diff --git a/index.html b/index.html index f09437d..cb1d262 100644 --- a/index.html +++ b/index.html @@ -1,12 +1,13 @@ - + + 瑞鞍星医疗科技 - - -
- - + + +
+ + diff --git a/package.json b/package.json index 6a287bb..17b02ff 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "vant": "^4.8.3", "vue": "^3.2.45", "vue-router": "^4.1.6", - "xlsx": "^0.18.5" + "xlsx": "^0.18.5", + "crypto-js": "4.2.0" }, "devDependencies": { "@types/js-cookie": "^3.0.6", diff --git a/src/api/acl/login.ts b/src/api/acl/login.ts new file mode 100644 index 0000000..8de6f63 --- /dev/null +++ b/src/api/acl/login.ts @@ -0,0 +1,26 @@ +import axios from "axios"; +import * as other from "@/utils/other"; +import {HOST} from "@/utils/request"; + +const FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded'; + +export const login = (data: any) => { + + const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_PWD_ENC_KEY); + + let encPassword = data.password; + + encPassword = other.encryption(data.password, "thanks,rax"); + data.grant_type = 'password'; + data.scope = 'server'; + return axios.request({ + url: '/api/admin/oauth2/token', + method: 'post', + data: {...data, password: encPassword}, + headers: { + skipToken: true, + Authorization: basicAuth, + 'Content-Type': FORM_CONTENT_TYPE, + }, + }); +}; \ No newline at end of file diff --git a/src/utils/other.ts b/src/utils/other.ts new file mode 100644 index 0000000..9830931 --- /dev/null +++ b/src/utils/other.ts @@ -0,0 +1,33 @@ +// @ts-ignore +import * as CryptoJS from 'crypto-js'; + +/** + *加密处理 + */ +export function encryption(src: string, keyWord: string) { + const key = CryptoJS.enc.Utf8.parse(keyWord); + // 加密 + var encrypted = CryptoJS.AES.encrypt(src, key, { + iv: key, + mode: CryptoJS.mode.CFB, + padding: CryptoJS.pad.NoPadding, + }); + return encrypted.toString(); +} + +/** + * 解密 + * @param {*} params 参数列表 + * @returns 明文 + */ +export function decryption(src: string, keyWord: string) { + const key = CryptoJS.enc.Utf8.parse(keyWord); + // 解密逻辑 + var decryptd = CryptoJS.AES.decrypt(src, key, { + iv: key, + mode: CryptoJS.mode.CFB, + padding: CryptoJS.pad.NoPadding, + }); + + return decryptd.toString(CryptoJS.enc.Utf8); +} \ No newline at end of file diff --git a/src/views/login/login.vue b/src/views/login/login.vue index 0115fd7..65bbfdc 100644 --- a/src/views/login/login.vue +++ b/src/views/login/login.vue @@ -1,139 +1,142 @@ diff --git a/vite.config.ts b/vite.config.ts index 48a6955..ec66385 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -19,5 +19,15 @@ export default defineConfig({ additionalData: '@import "./src/assets/css/variable.scss";' //引入scss文件 } } + }, + server: { + proxy: { + '/api': { + target: 'http://localhost:9999', // 目标服务器地址 + ws: true, // 是否启用 WebSocket + changeOrigin: true, // 是否修改请求头中的 Origin 字段 + rewrite: (path) => path.replace(/^\/api/, ''), + } + } } })