提交代码
parent
07e50117a2
commit
66fc6709bf
|
@ -3,9 +3,9 @@ VITE_APP_PORT = 3000
|
||||||
|
|
||||||
# 代理前缀
|
# 代理前缀
|
||||||
VITE_APP_BASE_API = '/api'
|
VITE_APP_BASE_API = '/api'
|
||||||
VITE_APP_API_URL = http://62.234.3.186/mk/ai/api
|
# VITE_APP_API_URL = http://62.234.3.186/mk/ai/api
|
||||||
# 线上接口地址
|
# 线上接口地址
|
||||||
# VITE_APP_API_URL = http://62.234.3.186
|
VITE_APP_API_URL = http://10.5.1.137:8800
|
||||||
# 开发接口地址
|
# 开发接口地址
|
||||||
# VITE_APP_API_URL = http://localhost:8989
|
# VITE_APP_API_URL = http://localhost:8989
|
||||||
|
|
||||||
|
|
|
@ -8,48 +8,45 @@ class AuthAPI {
|
||||||
* @param data {LoginData}
|
* @param data {LoginData}
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
static login(data: LoginData) {
|
static login(data: LoginData) {
|
||||||
/*
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("username", data.username);
|
formData.append("username", data.username);
|
||||||
formData.append("password", data.password);
|
formData.append("password", data.password);
|
||||||
formData.append("captchaKey", data.captchaKey || "");
|
formData.append("captchaKey", data.captchaKey || "");
|
||||||
formData.append("captchaCode", data.captchaCode || "");
|
formData.append("captchaCode", data.captchaCode || "");
|
||||||
return request<any, LoginResult>({
|
return request<any, LoginResult>({
|
||||||
url: "/api/v1/auth/login",
|
url: "/session/login",
|
||||||
method: "post",
|
method: "post",
|
||||||
data: formData,
|
data: formData,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "multipart/form-data",
|
"Content-Type": "multipart/form-data",
|
||||||
},
|
},
|
||||||
});*/
|
|
||||||
return new Promise((resolve,reject)=>{
|
|
||||||
if(data.username!='admin' || data.password!='123456'){
|
|
||||||
reject("用户名或密码错误");
|
|
||||||
}else{
|
|
||||||
resolve( {
|
|
||||||
"accessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImRlcHRJZCI6MSwiZGF0YVNjb3BlIjoxLCJleHAiOjE3MTYyMjY0OTksInVzZXJJZCI6MiwiaWF0IjoxNzE2MjE5Mjk5LCJhdXRob3JpdGllcyI6WyJST0xFX0FETUlOIl0sImp0aSI6IjVmMWIwNTExNmZjZDQxZmE5YTVlNjU4ZjQ5YmRmNmEyIn0.BBCWh3-bffEtgT0zhxSQ0ncithh9iIGDtbg1DPN0TvA",
|
|
||||||
"tokenType": "Bearer",
|
|
||||||
"refreshToken": null,
|
|
||||||
"expires": null
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
// return new Promise((resolve,reject)=>{
|
||||||
|
// if(data.username!='admin' || data.password!='123456'){
|
||||||
|
// reject("用户名或密码错误");
|
||||||
|
// }else{
|
||||||
|
// resolve( {
|
||||||
|
// "accessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImRlcHRJZCI6MSwiZGF0YVNjb3BlIjoxLCJleHAiOjE3MTYyMjY0OTksInVzZXJJZCI6MiwiaWF0IjoxNzE2MjE5Mjk5LCJhdXRob3JpdGllcyI6WyJST0xFX0FETUlOIl0sImp0aSI6IjVmMWIwNTExNmZjZDQxZmE5YTVlNjU4ZjQ5YmRmNmEyIn0.BBCWh3-bffEtgT0zhxSQ0ncithh9iIGDtbg1DPN0TvA",
|
||||||
|
// "tokenType": "Bearer",
|
||||||
|
// "refreshToken": null,
|
||||||
|
// "expires": null
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注销API
|
* 注销API
|
||||||
*/
|
*/
|
||||||
static logout() {
|
static logout() {
|
||||||
return new Promise(r=>{
|
|
||||||
r({});
|
|
||||||
});
|
|
||||||
/*
|
|
||||||
return request({
|
return request({
|
||||||
url: "/api/v1/auth/logout",
|
url: "/session/logout",
|
||||||
method: "delete",
|
method: "post",
|
||||||
});
|
});
|
||||||
*/
|
// return new Promise(r=>{
|
||||||
|
// r({});
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,3 +2,7 @@
|
||||||
* 令牌缓存Key
|
* 令牌缓存Key
|
||||||
*/
|
*/
|
||||||
export const TOKEN_KEY = "accessToken";
|
export const TOKEN_KEY = "accessToken";
|
||||||
|
|
||||||
|
export const UNAME_KEY = "userNameKey";
|
||||||
|
|
||||||
|
export const UROLE_KEY = "userRoleKey";
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { store } from "@/store";
|
||||||
|
|
||||||
import { LoginData } from "@/api/auth/model";
|
import { LoginData } from "@/api/auth/model";
|
||||||
import { UserInfo } from "@/api/user/model";
|
import { UserInfo } from "@/api/user/model";
|
||||||
import { TOKEN_KEY } from "@/enums/CacheEnum";
|
import { TOKEN_KEY,UNAME_KEY,UROLE_KEY } from "@/enums/CacheEnum";
|
||||||
|
|
||||||
export const useUserStore = defineStore("user", () => {
|
export const useUserStore = defineStore("user", () => {
|
||||||
const user = ref<UserInfo>({
|
const user = ref<UserInfo>({
|
||||||
|
@ -24,8 +24,11 @@ export const useUserStore = defineStore("user", () => {
|
||||||
AuthAPI.login(loginData)
|
AuthAPI.login(loginData)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
const { tokenType, accessToken } = data;
|
const { tokenType, accessToken } = data;
|
||||||
|
localStorage.setItem(UNAME_KEY, loginData.username);
|
||||||
|
localStorage.setItem(UROLE_KEY, data.role);
|
||||||
localStorage.setItem(TOKEN_KEY, tokenType + " " + accessToken); // Bearer eyJhbGciOiJIUzI1NiJ9.xxx.xxx
|
localStorage.setItem(TOKEN_KEY, tokenType + " " + accessToken); // Bearer eyJhbGciOiJIUzI1NiJ9.xxx.xxx
|
||||||
resolve();
|
resolve();
|
||||||
|
resolve();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
reject(error);
|
reject(error);
|
||||||
|
|
|
@ -95,7 +95,7 @@ const { height } = useWindowSize();
|
||||||
|
|
||||||
const loginData = ref<LoginData>({
|
const loginData = ref<LoginData>({
|
||||||
username: "admin",
|
username: "admin",
|
||||||
password: "123456",
|
password: "12345678",
|
||||||
});
|
});
|
||||||
|
|
||||||
const loginRules = computed(() => {
|
const loginRules = computed(() => {
|
||||||
|
|
Loading…
Reference in New Issue