mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-24 04:54:58 +08:00
parent
2c3acbcaaf
commit
c962e9f5fe
4
.env
4
.env
|
@ -1 +1,3 @@
|
||||||
VITE_PWD_ENC_KEY='thanks,rax'
|
VITE_PWD_ENC_KEY='thanks,rax4cloud'
|
||||||
|
|
||||||
|
VITE_OAUTH2_PASSWORD_CLIENT='rax:rax'
|
|
@ -1,26 +1,39 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import * as other from "@/utils/other";
|
import * as other from "@/utils/other";
|
||||||
import {HOST} from "@/utils/request";
|
import {HOST} from "@/utils/request";
|
||||||
|
import {ElMessage} from "element-plus";
|
||||||
|
|
||||||
const FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded';
|
const FORM_CONTENT_TYPE = 'application/x-www-form-urlencoded';
|
||||||
|
|
||||||
export const login = (data: any) => {
|
export const login = (data: any) => {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_OAUTH2_PASSWORD_CLIENT);
|
||||||
|
|
||||||
const basicAuth = 'Basic ' + window.btoa(import.meta.env.VITE_PWD_ENC_KEY);
|
let encPassword = data.password;
|
||||||
|
if (import.meta.env.VITE_PWD_ENC_KEY) {
|
||||||
|
encPassword = other.encryption(data.password, import.meta.env.VITE_PWD_ENC_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
let encPassword = data.password;
|
data.grant_type = 'password';
|
||||||
|
data.scope = 'server';
|
||||||
|
|
||||||
encPassword = other.encryption(data.password, "thanks,rax");
|
axios.request({
|
||||||
data.grant_type = 'password';
|
url: '/api/admin/oauth2/token',
|
||||||
data.scope = 'server';
|
method: 'post',
|
||||||
return axios.request({
|
data: {...data, password: encPassword},
|
||||||
url: '/api/admin/oauth2/token',
|
headers: {
|
||||||
method: 'post',
|
skipToken: true,
|
||||||
data: {...data, password: encPassword},
|
Authorization: basicAuth,
|
||||||
headers: {
|
'Content-Type': FORM_CONTENT_TYPE,
|
||||||
skipToken: true,
|
},
|
||||||
Authorization: basicAuth,
|
}).then(res => {
|
||||||
'Content-Type': FORM_CONTENT_TYPE,
|
resolve(res.data);
|
||||||
},
|
}).catch(err => {
|
||||||
});
|
if (err && err.response && err.response.data && err.response.data.msg) {
|
||||||
|
ElMessage.error(err.response.data.msg)
|
||||||
|
} else {
|
||||||
|
ElMessage.error('系统异常请联系管理员')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
};
|
};
|
|
@ -1,13 +1,12 @@
|
||||||
/*
|
|
||||||
import Cookies from 'js-cookie';
|
import Cookies from 'js-cookie';
|
||||||
|
|
||||||
/!**
|
/**
|
||||||
* window.localStorage 浏览器永久缓存
|
* window.localStorage 浏览器永久缓存
|
||||||
* @method set 设置永久缓存
|
* @method set 设置永久缓存
|
||||||
* @method get 获取永久缓存
|
* @method get 获取永久缓存
|
||||||
* @method remove 移除永久缓存
|
* @method remove 移除永久缓存
|
||||||
* @method clear 移除全部永久缓存
|
* @method clear 移除全部永久缓存
|
||||||
*!/
|
*/
|
||||||
export const Local = {
|
export const Local = {
|
||||||
// 查看 v2.4.3版本更新日志
|
// 查看 v2.4.3版本更新日志
|
||||||
setKey(key: string) {
|
setKey(key: string) {
|
||||||
|
@ -33,13 +32,13 @@ export const Local = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/!**
|
/**
|
||||||
* window.sessionStorage 浏览器临时缓存
|
* window.sessionStorage 浏览器临时缓存
|
||||||
* @method set 设置临时缓存
|
* @method set 设置临时缓存
|
||||||
* @method get 获取临时缓存
|
* @method get 获取临时缓存
|
||||||
* @method remove 移除临时缓存
|
* @method remove 移除临时缓存
|
||||||
* @method clear 移除全部临时缓存
|
* @method clear 移除全部临时缓存
|
||||||
*!/
|
*/
|
||||||
export const Session = {
|
export const Session = {
|
||||||
// 设置临时缓存
|
// 设置临时缓存
|
||||||
set(key: string, val: any) {
|
set(key: string, val: any) {
|
||||||
|
@ -75,4 +74,3 @@ export const Session = {
|
||||||
return Local.get('tenantId') ? Local.get('tenantId') : 1;
|
return Local.get('tenantId') ? Local.get('tenantId') : 1;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
|
|
|
@ -137,6 +137,7 @@ import {v4} from "uuid";
|
||||||
import {HOST, post} from "@/utils/request";
|
import {HOST, post} from "@/utils/request";
|
||||||
import SliderVerify from "@/components/SliderVerify/index.vue";
|
import SliderVerify from "@/components/SliderVerify/index.vue";
|
||||||
import * as loginApi from "@/api/acl/login";
|
import * as loginApi from "@/api/acl/login";
|
||||||
|
import {Session} from "@/utils/storage";
|
||||||
|
|
||||||
|
|
||||||
//引入用户相关的小仓库
|
//引入用户相关的小仓库
|
||||||
|
@ -283,7 +284,7 @@ const register = async () => {
|
||||||
loginParams.value.account = registerFormRef.value.account
|
loginParams.value.account = registerFormRef.value.account
|
||||||
loginParams.value.name = registerFormRef.value.name
|
loginParams.value.name = registerFormRef.value.name
|
||||||
currentHospital.value = registerFormRef.value.hospital
|
currentHospital.value = registerFormRef.value.hospital
|
||||||
toHome()
|
isShowRegister.value = false;
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
@ -364,7 +365,7 @@ function getCaptchaCode() {
|
||||||
|
|
||||||
function refreshImg() {
|
function refreshImg() {
|
||||||
const randomStr = v4()
|
const randomStr = v4()
|
||||||
captchaImgUrl.value = HOST + '/admin/code/textImage?randomStr=' + randomStr
|
captchaImgUrl.value = '/api/admin/code/textImage?randomStr=' + randomStr
|
||||||
}
|
}
|
||||||
|
|
||||||
function sliderSuccess() {
|
function sliderSuccess() {
|
||||||
|
@ -373,10 +374,12 @@ function sliderSuccess() {
|
||||||
password: loginParams.value.password, // 密码
|
password: loginParams.value.password, // 密码
|
||||||
randomStr: v4()
|
randomStr: v4()
|
||||||
}).then((data: any) => {
|
}).then((data: any) => {
|
||||||
|
// 存储token 信息
|
||||||
|
Session.set('token', data.access_token);
|
||||||
|
Session.set('refresh_token', data.refresh_token);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
toHome()
|
||||||
})
|
})
|
||||||
|
|
||||||
// toHome()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const toHome = () => {
|
const toHome = () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user