empower_front/src/apis/login/index.js
zong a99af4d2d7 1.加入docker file設定
2.調整組件以使用 window.env 讀取環境變數
2025-09-03 14:52:47 +08:00

28 lines
663 B
JavaScript

import { POST_LOGIN } from "./api";
import instance from "@/util/request";
import apihandler from "@/util/apiHandler";
export async function Login({ account, password }) {
const res = await instance.post(POST_LOGIN, {
account,
password,
});
if (res.code === "0000") {
console.log(res.data);
document.cookie = `JWT-Authorization=${res.data.token}; Max-Age=${
24 * 60 * 60 * 1000
}`;
// 設定 user_name Cookie
document.cookie = `user_name=${res.data.user_name}; Max-Age=${
24 * 60 * 60 * 1000
}`;
}
return apihandler(res.code, res.data, {
msg: res.msg,
code: res.code,
isSuccess: false,
});
}