init
This commit is contained in:
@@ -3,6 +3,7 @@ import { baseUrlApi } from "./utils";
|
||||
|
||||
export type UserResult = {
|
||||
success: boolean;
|
||||
status: number;
|
||||
data: {
|
||||
/** 头像 */
|
||||
avatar: string;
|
||||
|
||||
@@ -66,12 +66,20 @@ export const useUserStore = defineStore({
|
||||
},
|
||||
/** 登入 */
|
||||
async loginByUsername(data) {
|
||||
console.info("```````````````````````````````````````````````");
|
||||
console.info(data);
|
||||
return new Promise<UserResult>((resolve, reject) => {
|
||||
getLogin(data)
|
||||
.then(data => {
|
||||
console.log("loginByUsername");
|
||||
console.log(data.data);
|
||||
if (data?.success) setToken(data.data);
|
||||
console.log(data.status);
|
||||
console.log(data);
|
||||
//if (data?.success) setToken(data.data);
|
||||
// if(data?.status==200) setToken(data.data);
|
||||
if (data && data.status == 200) {
|
||||
setToken(data.data);
|
||||
}
|
||||
resolve(data);
|
||||
})
|
||||
.catch(error => {
|
||||
|
||||
@@ -34,7 +34,7 @@ const { title } = useNav();
|
||||
|
||||
const ruleForm = reactive({
|
||||
username: "admin",
|
||||
password: "admin123"
|
||||
password: "comcat@2019"
|
||||
});
|
||||
|
||||
const onLogin = async (formEl: FormInstance | undefined) => {
|
||||
@@ -45,10 +45,22 @@ const onLogin = async (formEl: FormInstance | undefined) => {
|
||||
useUserStoreHook()
|
||||
.loginByUsername({
|
||||
username: ruleForm.username,
|
||||
password: ruleForm.password
|
||||
password: ruleForm.password,
|
||||
isBackendUser: 1
|
||||
})
|
||||
.then(res => {
|
||||
if (res.success) {
|
||||
console.log(res);
|
||||
console.log("res.status = " + res.status);
|
||||
console.log("res.success = " + res.success);
|
||||
// if (res.success) {
|
||||
console.info(typeof res.status);
|
||||
if (res.status) {
|
||||
console.log(res.status);
|
||||
} else {
|
||||
console.info(res);
|
||||
console.error("res.status is undefined");
|
||||
}
|
||||
if (res.status === 200) {
|
||||
// 获取后端路由
|
||||
return initRouter().then(() => {
|
||||
router.push(getTopMenu(true).path).then(() => {
|
||||
|
||||
@@ -29,13 +29,41 @@ export default ({ mode }: ConfigEnv): UserConfigExport => {
|
||||
"/base": {
|
||||
target: "http://127.0.0.1:9098",
|
||||
changeOrigin: true,
|
||||
rewrite: path => path.replace(/^\/base/, "")
|
||||
rewrite: path => path.replace(/^\/base/, ""),
|
||||
configure: (proxy, options) => {
|
||||
// 添加调试日志
|
||||
proxy.on("proxyReq", (proxyReq, req, res) => {
|
||||
console.log(res);
|
||||
console.log("代理请求:", {
|
||||
from: req.url,
|
||||
to: options.target + proxyReq.path
|
||||
});
|
||||
});
|
||||
proxy.on("proxyRes", (proxyRes, req, res) => {
|
||||
console.log(res);
|
||||
console.log("代理响应:", {
|
||||
path: req.url,
|
||||
status: proxyRes.statusCode
|
||||
});
|
||||
});
|
||||
proxy.on("error", (err, req, res) => {
|
||||
console.log(res);
|
||||
console.log(req);
|
||||
console.error("代理错误:", err);
|
||||
});
|
||||
}
|
||||
},
|
||||
// 第二个代理后端地址
|
||||
"/otherApi": {
|
||||
target: "http://127.0.0.1:3290",
|
||||
changeOrigin: true,
|
||||
rewrite: path => path.replace(/^\/otherApi/, "")
|
||||
},
|
||||
// 第三个代理后端地址
|
||||
"/biz": {
|
||||
target: "http://127.0.0.1:8089",
|
||||
changeOrigin: true,
|
||||
rewrite: path => path.replace(/^\/biz/, "")
|
||||
}
|
||||
},
|
||||
// 预热文件以提前转换和缓存结果,降低启动期间的初始页面加载时长并防止转换瀑布
|
||||
|
||||
Reference in New Issue
Block a user