♻️ Refactoring code. 优化 .env 适配 higress

This commit is contained in:
lbw 2023-07-12 19:37:56 +08:00
parent e8481aa72f
commit e91db1a432
2 changed files with 8 additions and 8 deletions

11
.env
View File

@ -7,20 +7,17 @@ VITE_PUBLIC_PATH = /
# 后端请求前缀
VITE_API_URL = /api
# 前端加密密钥
VITE_PWD_ENC_KEY='thanks,pig4cloud'
# OAUTH2 密码模式客户端信息
VITE_OAUTH2_PASSWORD_CLIENT='pig:pig'
# OAUTH2 短信客户端信息
VITE_OAUTH2_MOBILE_CLIENT='app:app'
# OAUTH2 社交登录客户端信息
VITE_OAUTH2_SOCIAL_CLIENT='social:social'
# 是否开启前端验证码
VITE_VERIFY_ENABLE = true
VITE_VERIFY_ENABLE = false
# 前端加密密钥
VITE_PWD_ENC_KEY='thanks,pig4cloud'
# 是否开启websocket 消息接受,
VITE_WEBSOCKET_ENABLE = false

View File

@ -17,8 +17,11 @@ const FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded';
export const login = (data: any) => {
const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_PASSWORD_CLIENT);
Session.set('basicAuth', basicAuth);
let encPassword = data.password;
// 密码加密
const encPassword = other.encryption(data.password, import.meta.env.VITE_PWD_ENC_KEY);
if (import.meta.env.VITE_PWD_ENC_KEY) {
encPassword = other.encryption(data.password, import.meta.env.VITE_PWD_ENC_KEY);
}
const {username, randomStr, code, grant_type, scope} = data;
return request({
url: '/auth/oauth2/token',