From b2712087a0c4f61e3691c6ca2f4262e9c1e5ae8b Mon Sep 17 00:00:00 2001 From: Kane Date: Sun, 5 Mar 2023 22:55:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E8=BF=9B=E5=BA=A6=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/web/task_schedule/.eslintrc.cjs | 9 ++++++++- code/web/task_schedule/src/utils/api/url.ts | 21 ++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/code/web/task_schedule/.eslintrc.cjs b/code/web/task_schedule/.eslintrc.cjs index a327082..f1e585f 100644 --- a/code/web/task_schedule/.eslintrc.cjs +++ b/code/web/task_schedule/.eslintrc.cjs @@ -2,7 +2,7 @@ * @Author: Kane * @Date: 2022-12-14 15:12:46 * @LastEditors: Kane - * @LastEditTime: 2023-03-05 00:14:41 + * @LastEditTime: 2023-03-05 21:35:01 * @FilePath: /task_schedule/.eslintrc.cjs * @Description: * @@ -81,6 +81,11 @@ module.exports = { "exports": "never", "functions": "never", },], //数组和对象键值对最后一个逗号 + "@typescript-eslint/quotes": ["error", "double",], + "@typescript-eslint/space-before-function-paren": "off", + "@typescript-eslint/strict-boolean-expressions": ["error", { + "allowString": true, + },], "comma-style": ["error", "last",], //逗号在行位 "array-bracket-spacing": ["error", "never",], "no-undef-init": "error", @@ -88,6 +93,8 @@ module.exports = { "no-use-before-define": "error", "no-shadow-restricted-names": "error", //禁止对一些关键字或者保留字进行赋值操作,比如NaN、Infinity、undefined、eval、arguments等 "prefer-const": "warn", + "spaced-comment": "error", + "space-before-function-paren": "off", }, }, ], diff --git a/code/web/task_schedule/src/utils/api/url.ts b/code/web/task_schedule/src/utils/api/url.ts index 2e8be7e..8290b56 100644 --- a/code/web/task_schedule/src/utils/api/url.ts +++ b/code/web/task_schedule/src/utils/api/url.ts @@ -4,8 +4,8 @@ * @LastEditors: Kane * @FilePath: /task_schedule/src/utils/api/url.ts * @Description: 对URL的操作 - * - * Copyright (c) ${2022} by Kane, All Rights Reserved. + * + * Copyright (c) ${2022} by Kane, All Rights Reserved. */ type stringkey = Record; @@ -15,7 +15,7 @@ type stringkey = Record; * @param url 访问的url * @returns */ -function getURLParams(url: string) +function getURLParams(url: string): Record { const arr = url.split("?"); const params = arr[1].split("&"); @@ -38,38 +38,37 @@ function getURLParams(url: string) */ function getParamsFromURL(url: string): stringkey { - const indexOfQuestionMark: number = url.indexOf("?"); const indexOfSharp: number = url.indexOf("#"); const paramObj: stringkey = {}; let paramString; - //url中没有问号,说明没有参数 + // url中没有问号,说明没有参数 if (indexOfQuestionMark < 0) { return paramObj; } - //检查是否有#号 + // 检查是否有#号 if (indexOfSharp < 0) { - //没有#号,可以直接截取参数字符串 + // 没有#号,可以直接截取参数字符串 paramString = url.substring(indexOfQuestionMark); } else { - //有#号,截取?和#之间的字符串 + // 有#号,截取?和#之间的字符串 const end: number = indexOfQuestionMark < indexOfSharp ? indexOfSharp : url.length; paramString = url.substring(indexOfQuestionMark + 1, end); } - //拆分属性 + // 拆分属性 const paramArray: string[] = paramString.split("&"); paramArray.forEach((item) => { - if (item.length == 0) + if (item.length === 0) { return; } @@ -82,4 +81,4 @@ function getParamsFromURL(url: string): stringkey return paramObj; } -export { getURLParams, getParamsFromURL }; \ No newline at end of file +export { getURLParams, getParamsFromURL };