配置针对vue文件eslint

This commit is contained in:
2023-03-17 14:40:04 +08:00
parent 884641abbf
commit 8053360878
16 changed files with 1282 additions and 841 deletions

View File

@@ -17,9 +17,9 @@ function loadStaffInfo(): StaffInfo
try
{
obj = JSON.parse(window.localStorage.getItem(STUFF_ITEM) ?? "{}");
obj = JSON.parse( window.localStorage.getItem( STUFF_ITEM ) ?? "{}" );
}
catch (error)
catch ( error )
{
obj = {};
}
@@ -31,16 +31,16 @@ function loadStaffInfo(): StaffInfo
obj._department_code ?? "",
obj._department_name ?? "",
obj._section_office_code ?? "",
obj._section_office_name ?? "");
obj._section_office_name ?? "" );
return stuff;
}
function saveStaffInfo(stuff: StaffInfo): void
function saveStaffInfo( stuff: StaffInfo ): void
{
const json = JSON.stringify(stuff);
const json = JSON.stringify( stuff );
window.localStorage.setItem(STUFF_ITEM, json);
window.localStorage.setItem( STUFF_ITEM, json );
};
export { loadStaffInfo, saveStaffInfo };

View File

@@ -19,27 +19,27 @@ const service: AxiosInstance = axios.create(
// 请求拦截
service.interceptors.request.use(
(config) =>
( config ) =>
{
return config;
},
async (error) =>
async ( error ) =>
{
console.log(error);
console.log( error );
return await Promise.reject(error);
return await Promise.reject( error );
}
);
// 响应拦截
service.interceptors.response.use(
(response) =>
( response ) =>
{
return response;
},
async (error) =>
async ( error ) =>
{
return await Promise.reject(error);
return await Promise.reject( error );
}
);

View File

@@ -15,15 +15,15 @@ type stringkey = Record<string, string>;
* @param url 访问的url
* @returns
*/
function getURLParams(url: string): Record<string, string>
function getURLParams( url: string ): Record<string, string>
{
const arr = url.split("?");
const params = arr[1].split("&");
const arr = url.split( "?" );
const params = arr[1].split( "&" );
const obj: stringkey = {};
for (let i = 0; i < params.length; i++)
for ( let i = 0; i < params.length; i++ )
{
const param = params[i].split("=");
const param = params[i].split( "=" );
obj[param[0]] = param[1];
}
@@ -36,47 +36,47 @@ function getURLParams(url: string): Record<string, string>
* @param url url字符串
* @returns 返回包含url中参数作为key值作为value的对象。
*/
function getParamsFromURL(url: string): stringkey
function getParamsFromURL( url: string ): stringkey
{
const indexOfQuestionMark: number = url.indexOf("?");
const indexOfSharp: number = url.indexOf("#");
const indexOfQuestionMark: number = url.indexOf( "?" );
const indexOfSharp: number = url.indexOf( "#" );
const paramObj: stringkey = {};
let paramString;
// url中没有问号说明没有参数
if (indexOfQuestionMark < 0)
if ( indexOfQuestionMark < 0 )
{
return paramObj;
}
// 检查是否有#号
if (indexOfSharp < 0)
if ( indexOfSharp < 0 )
{
// 没有#号,可以直接截取参数字符串
paramString = url.substring(indexOfQuestionMark);
// 没有#号,可以直接截取参数字符串
paramString = url.substring( indexOfQuestionMark );
}
else
{
// 有#号,截取?和#之间的字符串
// 有#号,截取?和#之间的字符串
const end: number = indexOfQuestionMark < indexOfSharp ? indexOfSharp : url.length;
paramString = url.substring(indexOfQuestionMark + 1, end);
paramString = url.substring( indexOfQuestionMark + 1, end );
}
// 拆分属性
const paramArray: string[] = paramString.split("&");
const paramArray: string[] = paramString.split( "&" );
paramArray.forEach((item) =>
paramArray.forEach( ( item ) =>
{
if (item.length === 0)
if ( item.length === 0 )
{
return;
}
const param = item.split("=");
const param = item.split( "=" );
paramObj[param[0]] = param[1] ?? "";
});
} );
return paramObj;
}