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