代码优化

This commit is contained in:
2023-03-06 11:22:43 +08:00
parent b2712087a0
commit ef78c2e42e
6 changed files with 4759 additions and 4750 deletions

View File

@@ -3,9 +3,9 @@
* @Date: 2023-02-28 09:26:45
* @LastEditors: Kane
* @FilePath: /task_schedule/src/utils/api/localStorage.ts
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
*/
import { StaffInfo } from "@/data/cpicxim/StaffInfo";
@@ -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,23 +25,22 @@ 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);
window.localStorage.setItem(STUFF_ITEM, json);
};
export { loadStaffInfo, saveStaffInfo };
export { loadStaffInfo, saveStaffInfo };

View File

@@ -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,30 +17,30 @@ 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);
}
);
export { service };
export { service };

View File

@@ -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;