Files
desktop_task_schedule/code/web/task_schedule/src/utils/account.ts

46 lines
1.0 KiB
TypeScript
Raw Normal View History

2023-03-02 16:59:48 +08:00
/*
* @Author: Kane
* @Date: 2023-03-02 14:48:35
* @LastEditors: Kane
* @FilePath: /task_schedule/src/utils/account.ts
2023-03-06 11:22:43 +08:00
* @Description:
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
2023-03-02 16:59:48 +08:00
*/
2023-03-06 11:22:43 +08:00
import { type AxiosResponse } from "axios";
2023-03-07 17:54:52 +08:00
import { service as instance } from "./api/request.js";
import { API_URL } from "./api/config.js";
2023-03-24 15:11:47 +08:00
import { cleanStaffInfo, clearCallerInfo } from "./api/localStorage.js";
// @ts-expect-error 之后再补充类型文件
import { router } from "../router/index.js";
// declare const require: any;
// const { router, } = require( "../router/index.js" );
2023-03-02 16:59:48 +08:00
interface LoginInfo
{
2023-03-02 19:48:08 +08:00
p13account: string;
2023-03-02 16:59:48 +08:00
password: string;
}
2023-03-17 18:53:13 +08:00
async function login( data: LoginInfo ): Promise<AxiosResponse<any, any>>
2023-03-02 16:59:48 +08:00
{
2023-03-06 11:22:43 +08:00
return await instance.request(
2023-03-02 16:59:48 +08:00
{
method: "post",
url: API_URL.URL_LOGIN,
2023-03-06 11:22:43 +08:00
data,
2023-03-02 16:59:48 +08:00
}
);
}
function logout(): void
{
cleanStaffInfo();
2023-03-24 15:11:47 +08:00
clearCallerInfo();
void router.push( "/login" );
}
export { type LoginInfo, login, logout };