代码优化
This commit is contained in:
parent
b2712087a0
commit
ef78c2e42e
@ -84,7 +84,7 @@ module.exports = {
|
||||
"@typescript-eslint/quotes": ["error", "double",],
|
||||
"@typescript-eslint/space-before-function-paren": "off",
|
||||
"@typescript-eslint/strict-boolean-expressions": ["error", {
|
||||
"allowString": true,
|
||||
"allowString": false,
|
||||
},],
|
||||
"comma-style": ["error", "last",], //逗号在行位
|
||||
"array-bracket-spacing": ["error", "never",],
|
||||
|
@ -8,6 +8,7 @@
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
|
||||
import { type AxiosResponse } from "axios";
|
||||
import { service as instance } from "./api/request";
|
||||
import { API_URL } from "./api/config";
|
||||
interface LoginInfo
|
||||
@ -16,15 +17,15 @@ interface LoginInfo
|
||||
password: string;
|
||||
}
|
||||
|
||||
function login(data: LoginInfo)
|
||||
async function login(data: LoginInfo): Promise<AxiosResponse<any, any>>
|
||||
{
|
||||
return instance.request(
|
||||
return await instance.request(
|
||||
{
|
||||
method: "post",
|
||||
url: API_URL.URL_LOGIN,
|
||||
data: data,
|
||||
data,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export { LoginInfo, login };
|
||||
export { type LoginInfo, login };
|
||||
|
@ -17,7 +17,7 @@ function loadStaffInfo(): StaffInfo
|
||||
|
||||
try
|
||||
{
|
||||
obj = JSON.parse(window.localStorage.getItem(STUFF_ITEM) || "{}");
|
||||
obj = JSON.parse(window.localStorage.getItem(STUFF_ITEM) ?? "{}");
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
@ -25,19 +25,18 @@ function loadStaffInfo(): StaffInfo
|
||||
}
|
||||
|
||||
const stuff = new StaffInfo(
|
||||
obj._p13uid || "",
|
||||
obj._stuffCode || "",
|
||||
obj._stuffName || "",
|
||||
obj._department_code || "",
|
||||
obj._department_name || "",
|
||||
obj._section_office_code || "",
|
||||
obj._section_office_name || "");
|
||||
|
||||
obj._p13uid ?? "",
|
||||
obj._stuffCode ?? "",
|
||||
obj._stuffName ?? "",
|
||||
obj._department_code ?? "",
|
||||
obj._department_name ?? "",
|
||||
obj._section_office_code ?? "",
|
||||
obj._section_office_name ?? "");
|
||||
|
||||
return stuff;
|
||||
}
|
||||
|
||||
function saveStaffInfo(stuff: StaffInfo)
|
||||
function saveStaffInfo(stuff: StaffInfo): void
|
||||
{
|
||||
const json = JSON.stringify(stuff);
|
||||
|
||||
|
@ -1,3 +1,12 @@
|
||||
/*
|
||||
* @Author: Kane
|
||||
* @Date: 2023-02-28 17:47:22
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /task_schedule/src/utils/api/request.ts
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
|
||||
import axios from "axios";
|
||||
|
||||
@ -8,29 +17,29 @@ const service = axios.create(
|
||||
}
|
||||
);
|
||||
|
||||
//请求拦截
|
||||
// 请求拦截
|
||||
service.interceptors.request.use(
|
||||
(config) =>
|
||||
{
|
||||
return config;
|
||||
},
|
||||
(error) =>
|
||||
async (error) =>
|
||||
{
|
||||
console.log(error);
|
||||
|
||||
return Promise.reject(error);
|
||||
return await Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
//响应拦截
|
||||
// 响应拦截
|
||||
service.interceptors.response.use(
|
||||
(response) =>
|
||||
{
|
||||
return response;
|
||||
},
|
||||
(error) =>
|
||||
async (error) =>
|
||||
{
|
||||
return Promise.reject(error);
|
||||
return await Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -75,7 +75,7 @@ function getParamsFromURL(url: string): stringkey
|
||||
|
||||
const param = item.split("=");
|
||||
|
||||
paramObj[param[0]] = param[1] || "";
|
||||
paramObj[param[0]] = param[1] ?? "";
|
||||
});
|
||||
|
||||
return paramObj;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user