整理代码!
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
import { type AxiosResponse } from "axios";
|
||||
import { service as instance } from "./api/request.js";
|
||||
import { API_URL } from "./api/config.js";
|
||||
import { cleanStaffInfo } from "./api/localStorage.js";
|
||||
import { cleanStaffInfo, clearCallerInfo } from "./api/localStorage.js";
|
||||
|
||||
// @ts-expect-error 之后再补充类型文件
|
||||
import { router } from "../router/index.js";
|
||||
@@ -38,6 +38,7 @@ async function login( data: LoginInfo ): Promise<AxiosResponse<any, any>>
|
||||
function logout(): void
|
||||
{
|
||||
cleanStaffInfo();
|
||||
clearCallerInfo();
|
||||
|
||||
void router.push( "/login" );
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@
|
||||
import { StaffInfo } from "@/data/cpicxim/StaffInfo.js";
|
||||
|
||||
const STUFF_ITEM = "stuff_info";
|
||||
const CALLER_ITEM = "call_info";
|
||||
const USER_TYPE_ITEM = "user_type";
|
||||
|
||||
function loadStaffInfo(): StaffInfo
|
||||
@@ -61,10 +62,28 @@ function getUserType(): string
|
||||
return userType;
|
||||
}
|
||||
|
||||
function saveCallerInfo( callerCode: string ): void
|
||||
{
|
||||
window.localStorage.setItem( CALLER_ITEM, callerCode );
|
||||
}
|
||||
|
||||
function getCallerInfo(): string
|
||||
{
|
||||
return window.localStorage.getItem( CALLER_ITEM ) ?? "";
|
||||
}
|
||||
|
||||
function clearCallerInfo(): void
|
||||
{
|
||||
window.localStorage.removeItem( CALLER_ITEM );
|
||||
}
|
||||
|
||||
export {
|
||||
loadStaffInfo,
|
||||
saveStaffInfo,
|
||||
cleanStaffInfo,
|
||||
saveUserType,
|
||||
getUserType
|
||||
getUserType,
|
||||
saveCallerInfo,
|
||||
getCallerInfo,
|
||||
clearCallerInfo
|
||||
};
|
||||
|
@@ -66,7 +66,7 @@ function getParamsFromURL( url: string ): stringkey
|
||||
// 拆分属性
|
||||
const paramArray: string[] = paramString.split( "&" );
|
||||
|
||||
paramArray.forEach( ( item ) =>
|
||||
paramArray.forEach(( item ) =>
|
||||
{
|
||||
if ( item.length === 0 )
|
||||
{
|
||||
@@ -76,7 +76,7 @@ function getParamsFromURL( url: string ): stringkey
|
||||
const param = item.split( "=" );
|
||||
|
||||
paramObj[param[0]] = param[1] ?? "";
|
||||
} );
|
||||
});
|
||||
|
||||
return paramObj;
|
||||
}
|
||||
|
@@ -30,11 +30,11 @@ interface Archievement
|
||||
*/
|
||||
function queryDepartmentArchievement( render: any ): void
|
||||
{
|
||||
instance.request( {
|
||||
instance.request({
|
||||
method: "post",
|
||||
url: API_URL.URL_DEPARTMENT_ARCHIEVEMENT,
|
||||
} )
|
||||
.then( ( response ) =>
|
||||
})
|
||||
.then(( response ) =>
|
||||
{
|
||||
const archievement: Archievement = {
|
||||
success: false,
|
||||
@@ -60,11 +60,11 @@ function queryDepartmentArchievement( render: any ): void
|
||||
archievement.backward_list = data.backward_list ?? [];
|
||||
|
||||
render( data );
|
||||
} )
|
||||
.catch( ( error ) =>
|
||||
})
|
||||
.catch(( error ) =>
|
||||
{
|
||||
console.log( error );
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
export { queryDepartmentArchievement, type Archievement };
|
||||
|
Reference in New Issue
Block a user