代码优化
This commit is contained in:
		@@ -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",],
 | 
			
		||||
 
 | 
			
		||||
@@ -3,11 +3,12 @@
 | 
			
		||||
 * @Date: 2023-03-02 14:48:35
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @FilePath: /task_schedule/src/utils/account.ts
 | 
			
		||||
 * @Description: 
 | 
			
		||||
 * 
 | 
			
		||||
 * Copyright (c) ${2022} by Kane, All Rights Reserved. 
 | 
			
		||||
 * @Description:
 | 
			
		||||
 *
 | 
			
		||||
 * 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 };
 | 
			
		||||
 
 | 
			
		||||
@@ -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 };
 | 
			
		||||
 
 | 
			
		||||
@@ -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 };
 | 
			
		||||
 
 | 
			
		||||
@@ -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
											
										
									
								
							
		Reference in New Issue
	
	Block a user