diff --git a/.eslintrc b/.eslintrc
deleted file mode 100644
index 90d2f69..0000000
--- a/.eslintrc
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "extends": [
- "@kirklin"
- ],
- "rules": {
- "@typescript-eslint/no-unsafe-argument": "off",
- "@typescript-eslint/no-unsafe-assignment": "off",
- "@typescript-eslint/no-unsafe-call": "off",
- "@typescript-eslint/no-unsafe-member-access": "off"
- }
-}
diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
index 00c616c..bfa5870 100644
--- a/.github/CODE_OF_CONDUCT.md
+++ b/.github/CODE_OF_CONDUCT.md
@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:
-* Using welcoming and inclusive language
-* Being respectful of differing viewpoints and experiences
-* Gracefully accepting constructive criticism
-* Focusing on what is best for the community
-* Showing empathy towards other community members
+- Using welcoming and inclusive language
+- Being respectful of differing viewpoints and experiences
+- Gracefully accepting constructive criticism
+- Focusing on what is best for the community
+- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
-* The use of sexualized language or imagery and unwelcome sexual attention or
- advances
-* Trolling, insulting/derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or electronic
- address, without explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
- professional setting
+- The use of sexualized language or imagery and unwelcome sexual attention or
+ advances
+- Trolling, insulting/derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+- Other conduct which could reasonably be considered inappropriate in a
+ professional setting
## Our Responsibilities
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported by contacting the project team.
+reported by contacting the project team.
All complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 23fa589..2157ce5 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -11,6 +11,7 @@ Before submitting the PR, please make sure you do the following:
- Added necessary documentation (if appropriate)
-->
+
## Proposed changes
@@ -27,7 +28,6 @@ _Put an `x` in the boxes that apply_
## Linked Issues
-
## Further comments
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 61ff277..317284b 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,29 +1,49 @@
{
+ // 禁用默认的格式化程序,改用ESLint进行格式化
+ "prettier.enable": false,
"editor.formatOnSave": false,
+
+ // 自动修复
"editor.codeActionsOnSave": {
- "source.fixAll": false,
- "source.fixAll.eslint": true, // this allows ESLint to auto fix on save
- "source.organizeImports": false
- },
- // ESLint config: https://github.com/kirklin/eslint-config
- "eslint.codeAction.showDocumentation": {
- "enable": true
+ "source.fixAll.eslint": "explicit",
+ "source.organizeImports": "never"
},
- "eslint.quiet": true,
+
+ // 在IDE中隐藏样式规则的提示,但仍然自动修复它们
+ "eslint.rules.customizations": [
+ { "rule": "style/*", "severity": "off" },
+ { "rule": "format/*", "severity": "off" },
+ { "rule": "*-indent", "severity": "off" },
+ { "rule": "*-spacing", "severity": "off" },
+ { "rule": "*-spaces", "severity": "off" },
+ { "rule": "*-order", "severity": "off" },
+ { "rule": "*-dangle", "severity": "off" },
+ { "rule": "*-newline", "severity": "off" },
+ { "rule": "*quotes", "severity": "off" },
+ { "rule": "*semi", "severity": "off" }
+ ],
+
+ // 为所有支持的语言启用ESLint
"eslint.validate": [
"javascript",
- "typescript",
"javascriptreact",
+ "typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
- "json5"
- ],
- "prettier.enable": false,
- "prettier.printWidth": 200,
- "prettier.semi": true,
- "prettier.singleQuote": false
+ "yaml",
+ "toml",
+ "xml",
+ "gql",
+ "graphql",
+ "astro",
+ "css",
+ "less",
+ "scss",
+ "pcss",
+ "postcss"
+ ]
}
diff --git a/eslint.config.mjs b/eslint.config.mjs
new file mode 100644
index 0000000..30d5159
--- /dev/null
+++ b/eslint.config.mjs
@@ -0,0 +1,26 @@
+import kirklin from "@kirklin/eslint-config";
+
+export default kirklin({
+ rules: {
+ "node/prefer-global/process": "off",
+ "no-console": "warn",
+ },
+ formatters: {
+ /**
+ * 格式化CSS、LESS、SCSS文件,以及Vue中的`
diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue
index 52f79bf..256618d 100644
--- a/src/pages/login/index.vue
+++ b/src/pages/login/index.vue
@@ -18,13 +18,13 @@ const loginFormData = shallowReactive({
const isPasswordLogin = ref(true);
const smsCode = ref("");
-const handleLogin = async () => {
+async function handleLogin() {
if (!loginFormData.agree) {
return showToast("请勾选协议");
}
showSuccessToast("登录成功");
await router.replace("/home");
-};
+}
// 发送短信验证码
const { sendMobileCode, countdownValue, formRef } = useMobileCode(
@@ -103,5 +103,5 @@ const { sendMobileCode, countdownValue, formRef } = useMobileCode(
diff --git a/src/pages/user/index.vue b/src/pages/user/index.vue
index 1f7dc4f..492b218 100644
--- a/src/pages/user/index.vue
+++ b/src/pages/user/index.vue
@@ -20,13 +20,13 @@ const tools = [
{ label: "系统设置", path: "/user" },
];
const router = useRouter();
-const handleLogout = async () => {
+async function handleLogout() {
await showConfirmDialog({
title: "温馨提示",
message: "您是否确认退出APP?",
});
await router.push("/login");
-};
+}
@@ -120,7 +120,11 @@ const handleLogout = async () => {
padding: 0 15px 150px;
&-head {
height: 200px;
- background: linear-gradient(180deg, rgb(149, 206, 232), rgba(44, 181, 165, 0));
+ background: linear-gradient(
+ 180deg,
+ rgb(149, 206, 232),
+ rgba(44, 181, 165, 0)
+ );
margin: 0 -15px;
padding: 0 15px;
&-top {
diff --git a/src/request/src/CheckStatus.ts b/src/request/src/CheckStatus.ts
index 51c3a84..8ad6909 100644
--- a/src/request/src/CheckStatus.ts
+++ b/src/request/src/CheckStatus.ts
@@ -5,7 +5,7 @@ import { HttpStatusConstants } from "~/request/src/requestConstants";
// 定义一个状态码处理策略接口
interface CheckStrategy {
- check(status: number, msg?: string): void;
+ check: (status: number, msg?: string) => void;
}
// Processing = 102
class ProcessingCheckStrategy implements CheckStrategy {
diff --git a/src/request/src/axiosCancel.ts b/src/request/src/axiosCancel.ts
index 96cdd8e..90e0620 100644
--- a/src/request/src/axiosCancel.ts
+++ b/src/request/src/axiosCancel.ts
@@ -3,9 +3,9 @@ import type { AxiosRequestConfig } from "axios";
// 用于存储每个请求的标识和取消函数
const pendingMap = new Map();
-const getPendingUrl = (config: AxiosRequestConfig): string => {
+function getPendingUrl(config: AxiosRequestConfig): string {
return [config.method, config.url].join("&");
-};
+}
export class AxiosCanceler {
/**
diff --git a/src/request/src/options/transform/defaultTransform.ts b/src/request/src/options/transform/defaultTransform.ts
index c0f3d04..6f429cb 100644
--- a/src/request/src/options/transform/defaultTransform.ts
+++ b/src/request/src/options/transform/defaultTransform.ts
@@ -112,7 +112,8 @@ export const defaultTransform: AxiosTransform = {
*/
onRequestError(error: Error, options: RequestOptions): any {
return {
- error, options,
+ error,
+ options,
};
},
diff --git a/src/request/src/utils.ts b/src/request/src/utils.ts
index ab26e60..6eba591 100644
--- a/src/request/src/utils.ts
+++ b/src/request/src/utils.ts
@@ -20,7 +20,7 @@ export function joinTimestamp(join: boolean, restful = false): string | object {
/**
* @description: Format request parameter time
*/
-export const formatRequestDate = (params: Record) => {
+export function formatRequestDate(params: Record) {
if (!isObject(params)) {
return;
}
@@ -44,7 +44,7 @@ export const formatRequestDate = (params: Record) => {
formatRequestDate(params[key]);
}
});
-};
+}
/**
* Add the object as a parameter to the URL
* @param baseUrl url
diff --git a/src/store/plugin/persist.ts b/src/store/plugin/persist.ts
index 48f60c3..72cfd96 100644
--- a/src/store/plugin/persist.ts
+++ b/src/store/plugin/persist.ts
@@ -28,7 +28,7 @@ export const PERSIST_KEY_PREFIX = createStorageName(import.meta.e
* @param shouldEnableEncryption whether to enable encryption for storage data 是否启用存储数据加密
* @returns serializer
*/
-const customSerializer = (shouldEnableEncryption: boolean): Serializer => {
+function customSerializer(shouldEnableEncryption: boolean): Serializer {
if (shouldEnableEncryption) {
return {
deserialize: (value) => {
@@ -50,7 +50,7 @@ const customSerializer = (shouldEnableEncryption: boolean): Serializer => {
},
};
}
-};
+}
/**
* Register Pinia Persist Plugin
diff --git a/src/styles/main.scss b/src/styles/main.scss
index 86303d6..136f584 100644
--- a/src/styles/main.scss
+++ b/src/styles/main.scss
@@ -12,7 +12,15 @@ a {
color: var(--bv-text2);
}
-h1, h2, h3, h4, h5, h6, p, ul, ol {
+h1,
+h2,
+h3,
+h4,
+h5,
+h6,
+p,
+ul,
+ol {
margin: 0;
padding: 0;
}
diff --git a/src/styles/variables.scss b/src/styles/variables.scss
index fd9e991..187a365 100644
--- a/src/styles/variables.scss
+++ b/src/styles/variables.scss
@@ -1,18 +1,18 @@
:root {
- --bv-primary: #3491FA;
- --bv-primary-active: #3491FA50;
- --bv-plain: #EAF8F6;
- --bv-orange: #FCA21C;
+ --bv-primary: #3491fa;
+ --bv-primary-active: #3491fa50;
+ --bv-plain: #eaf8f6;
+ --bv-orange: #fca21c;
--bv-text1: #121826;
- --bv-text2: #3C3E42;
- --bv-text3: #6F6F6F;
+ --bv-text2: #3c3e42;
+ --bv-text3: #6f6f6f;
--bv-tag: #848484;
--bv-dark: #979797;
- --bv-tip: #C3C3C5;
- --bv-disable: #D9DBDE;
- --bv-line: #EDEDED;
- --bv-bg: #F6F7F9;
- --bv-price: #EB5757;
+ --bv-tip: #c3c3c5;
+ --bv-disable: #d9dbde;
+ --bv-line: #ededed;
+ --bv-bg: #f6f7f9;
+ --bv-price: #eb5757;
/* 覆盖 Vant 的主色变量 */
--van-primary-color: var(--bv-primary);
diff --git a/src/utils/src/__test__/dateUtil.test.ts b/src/utils/src/__test__/dateUtil.test.ts
index 3196191..1d2ff30 100644
--- a/src/utils/src/__test__/dateUtil.test.ts
+++ b/src/utils/src/__test__/dateUtil.test.ts
@@ -1,15 +1,15 @@
-import { describe, expect, test } from "vitest";
+import { describe, expect, it } from "vitest";
import { formatToDate, formatToDateTime } from "../dateUtil";
describe("formatToDate function", () => {
- test("should return formatted date when given a valid date object", () => {
+ it("should return formatted date when given a valid date object", () => {
const validDate = new Date("2023-01-01T00:00:00.000Z");
const expectedOutput = "2023-01-01";
const actualOutput = formatToDate(validDate);
expect(actualOutput).toBe(expectedOutput);
});
- test("should return formatted date with the given format when passed a valid date object and a format string", () => {
+ it("should return formatted date with the given format when passed a valid date object and a format string", () => {
const validDate = new Date("2023-01-01T00:00:00.000Z");
const formatString = "YYYY-MM-DD";
const expectedOutput = "2023-01-01";
@@ -17,7 +17,7 @@ describe("formatToDate function", () => {
expect(actualOutput).toBe(expectedOutput);
});
- test("should throw an error when passed an invalid date string", () => {
+ it("should throw an error when passed an invalid date string", () => {
const invalidDate = "2018-10-10-10-10-10";
const expectedOutput = "Invalid Date";
const actualOutput = formatToDate(invalidDate);
@@ -26,14 +26,14 @@ describe("formatToDate function", () => {
});
describe("formatToDateTime function", () => {
- test("should return formatted date and time when given a valid date object", () => {
+ it("should return formatted date and time when given a valid date object", () => {
const validDate = new Date("2023-01-01T00:00:00.000");
const expectedOutput = "2023-01-01 00:00:00"; // assuming timezone offset is +08:00
const actualOutput = formatToDateTime(validDate);
expect(actualOutput).toBe(expectedOutput);
});
- test("should throw an error when passed an invalid date string", () => {
+ it("should throw an error when passed an invalid date string", () => {
const invalidDate = "2018-10-10-10-10-10";
const expectedOutput = "Invalid Date";
const actualOutput = formatToDateTime(invalidDate);
diff --git a/src/utils/src/__test__/deepMerge.test.ts b/src/utils/src/__test__/deepMerge.test.ts
index e05df9a..6b09a7d 100644
--- a/src/utils/src/__test__/deepMerge.test.ts
+++ b/src/utils/src/__test__/deepMerge.test.ts
@@ -1,8 +1,8 @@
-import { describe, expect, test } from "vitest";
+import { describe, expect, it } from "vitest";
import { deepMerge } from "../util";
describe("deepMerge function", () => {
- test("should correctly merge basic data types", () => {
+ it("should correctly merge basic data types", () => {
const source = { a: 1, b: 2, c: null };
const target = {
a: 2,
@@ -17,7 +17,7 @@ describe("deepMerge function", () => {
expect(deepMerge(source, target)).toStrictEqual(expected);
});
- test("should return the same date if only 1 is passed", () => {
+ it("should return the same date if only 1 is passed", () => {
const foo = new Date();
const merged = deepMerge(foo, null);
const merged2 = deepMerge(undefined, foo);
@@ -26,7 +26,7 @@ describe("deepMerge function", () => {
expect(merged).toStrictEqual(merged2);
});
- test("should merge two objects recursively", () => {
+ it("should merge two objects recursively", () => {
const source = {
a: { b: { c: 1 }, d: [1, 2] },
e: [1, 2],
@@ -69,7 +69,7 @@ describe("deepMerge function", () => {
expect(deepMerge(source, target)).toStrictEqual(expected);
});
- test("should replace arrays by default", () => {
+ it("should replace arrays by default", () => {
const source = {
a: { b: { d: [1, 2] } },
e: [1, 2],
@@ -85,7 +85,7 @@ describe("deepMerge function", () => {
expect(deepMerge(source, target)).toStrictEqual(expected);
});
- test("should union arrays using mergeArrays = 'union'", () => {
+ it("should union arrays using mergeArrays = 'union'", () => {
const source = {
a: { b: { d: [1, 2] } },
e: [1, 2],
@@ -101,7 +101,7 @@ describe("deepMerge function", () => {
expect(deepMerge(source, target, "union")).toStrictEqual(expected);
});
- test("should intersect arrays using mergeArrays = 'intersection'", () => {
+ it("should intersect arrays using mergeArrays = 'intersection'", () => {
const source = {
a: { b: { d: [1, 2] } },
e: [1, 2],
@@ -117,7 +117,7 @@ describe("deepMerge function", () => {
expect(deepMerge(source, target, "intersection")).toStrictEqual(expected);
});
- test("should concatenate arrays using mergeArrays = 'concat'", () => {
+ it("should concatenate arrays using mergeArrays = 'concat'", () => {
const source = {
a: { b: { d: [1, 2] } },
e: [1, 2],
diff --git a/src/utils/src/__test__/snowflake.test.ts b/src/utils/src/__test__/snowflake.test.ts
index a1aa0f6..8a42695 100644
--- a/src/utils/src/__test__/snowflake.test.ts
+++ b/src/utils/src/__test__/snowflake.test.ts
@@ -1,7 +1,7 @@
import { describe, expect, it } from "vitest";
import { Snowflake } from "../snowflake";
-describe("Snowflake", () => {
+describe("snowflake", () => {
it("generates unique IDs", () => {
const snowflake1 = new Snowflake(1, 2);
const snowflake2 = new Snowflake(3, 4);
@@ -38,8 +38,6 @@ describe("Snowflake", () => {
const snowflake = new Snowflake(0, 0);
snowflake.nextId();
const timestamp = Date.now();
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-expect-error
snowflake.lastTimestamp = BigInt(timestamp + 1000);
expect(() => snowflake.nextId()).toThrow();
});
diff --git a/src/utils/src/__test__/treeHelper.test.ts b/src/utils/src/__test__/treeHelper.test.ts
index 392f45c..e23a772 100644
--- a/src/utils/src/__test__/treeHelper.test.ts
+++ b/src/utils/src/__test__/treeHelper.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from "vitest";
import {
- filterTree, findAllNodePaths,
+ filterTree,
+ findAllNodePaths,
findFirstNodePath,
findTreeNode,
findTreeNodes,
@@ -13,7 +14,7 @@ import {
traverseTreeRecursive,
} from "../treeHelper";
-describe("Tree Helper", () => {
+describe("tree Helper", () => {
interface TreeNode {
id: number;
parentId: number | null;
diff --git a/src/utils/src/__test__/utils.test.ts b/src/utils/src/__test__/utils.test.ts
index a3b403f..c91311f 100644
--- a/src/utils/src/__test__/utils.test.ts
+++ b/src/utils/src/__test__/utils.test.ts
@@ -1,18 +1,18 @@
-import { describe, expect, test } from "vitest";
+import { describe, expect, it } from "vitest";
import { getErrorMessage } from "../util";
describe("getErrorMessage", () => {
- test("should return the error message if the error object is an instance of Error", () => {
+ it("should return the error message if the error object is an instance of Error", () => {
const error = new Error("This is an error message");
expect(getErrorMessage(error)).toBe("This is an error message");
});
- test("should convert the error object to string if it is not an instance of Error", () => {
+ it("should convert the error object to string if it is not an instance of Error", () => {
const error = { message: "This is not an Error instance" };
expect(getErrorMessage(error)).toBe("This is not an Error instance");
});
- test("should return the error message as string if the error object is a string", () => {
+ it("should return the error message as string if the error object is a string", () => {
const error = "This is a string error";
expect(getErrorMessage(error)).toBe("This is a string error");
});
diff --git a/src/utils/src/browserHelper.ts b/src/utils/src/browserHelper.ts
index 01021f9..d83c594 100644
--- a/src/utils/src/browserHelper.ts
+++ b/src/utils/src/browserHelper.ts
@@ -13,16 +13,16 @@ import { isClient } from "../index";
* @param {string} options.target - 新窗口的名称或特殊选项,默认为 "_blank"
* @param {string} options.features - 新窗口的特性(大小,位置等),默认为 "noopener=yes,noreferrer=yes"
*/
-export const openWindow = (url: string, { target = "_blank", features = "noopener=yes,noreferrer=yes" }: {
+export function openWindow(url: string, { target = "_blank", features = "noopener=yes,noreferrer=yes" }: {
target?: "_blank" | "_self" | "_parent" | "_top"; // 新窗口的名称或特殊选项,默认为 "_blank"
features?: string; // 新窗口的特性(大小,位置等),默认为 "noopener=yes,noreferrer=yes"
-} = {}) => {
+} = {}) {
window.open(url, target, features);
-};
+}
// copy text to clipboard
// 将文本复制到剪贴板
-export const copyToClipboard = (text: string) => {
+export function copyToClipboard(text: string) {
// Try to use the navigator.clipboard.writeText method
// 尝试使用navigator.clipboard.writeText方法
void navigator.clipboard.writeText(text).then(() => {
@@ -44,7 +44,7 @@ export const copyToClipboard = (text: string) => {
logger.info("Copy Success", field("Content:", text));
}
});
-};
+}
/**
* Checks if the current environment supports touch events, typically indicating touch-enabled devices.
diff --git a/src/utils/src/cipher.ts b/src/utils/src/cipher.ts
index 77b77b6..e108e12 100644
--- a/src/utils/src/cipher.ts
+++ b/src/utils/src/cipher.ts
@@ -10,13 +10,13 @@ import SHA512 from "crypto-js/sha512";
// Define an interface for encryption
// 定义一个加密器的接口
export interface Encryption {
- encrypt(plainText: string): string;
- decrypt(cipherText: string): string;
+ encrypt: (plainText: string) => string;
+ decrypt: (cipherText: string) => string;
}
// Define an interface for Hashing
// 定义一个哈希算法的接口
export interface Hashing {
- hash(data: string): string;
+ hash: (data: string) => string;
}
export interface EncryptionParams {
diff --git a/src/utils/src/config.ts b/src/utils/src/config.ts
index eeaa89a..8158ebe 100644
--- a/src/utils/src/config.ts
+++ b/src/utils/src/config.ts
@@ -21,7 +21,7 @@ export function getAppGlobalConfig(env: GlobEnvConfig): GlobConfig {
const { VITE_GLOB_APP_TITLE, VITE_GLOB_API_URL, VITE_GLOB_APP_SHORT_NAME, VITE_GLOB_API_URL_SSR, VITE_GLOB_API_URL_PREFIX }
= getAppGlobalEnvConfig(env);
- if (!/^[a-zA-Z_]*$/.test(VITE_GLOB_APP_SHORT_NAME)) {
+ if (!/^[a-z_]*$/i.test(VITE_GLOB_APP_SHORT_NAME)) {
console.warn(
"VITE_GLOB_APP_SHORT_NAME Variables can only be characters/underscores, please modify in the environment variables and re-running.",
);
diff --git a/src/utils/src/domUtils.ts b/src/utils/src/domUtils.ts
index b9954fb..d6dbdf4 100644
--- a/src/utils/src/domUtils.ts
+++ b/src/utils/src/domUtils.ts
@@ -166,17 +166,14 @@ export const off = (() => {
* @returns {HTMLElement | undefined} The first element that matches the selectors within the container, or undefined if not found.
* 与选择器匹配的第一个元素(在容器内),如果找不到则返回 undefined。
*/
-export const querySelector = (
- selectors: string,
- container?: Document | HTMLElement,
-): HTMLElement | undefined => {
+export function querySelector(selectors: string, container?: Document | HTMLElement): HTMLElement | undefined {
if (isServerRendering) {
return NOOP();
}
return (
(container ?? document).querySelector(selectors) ?? undefined
);
-};
+}
/**
* Gets the DOM element based on the target string, element, or undefined input within the given container.
@@ -202,13 +199,10 @@ export const querySelector = (
* @returns {HTMLElement | undefined} The DOM element based on the target input, or undefined if not found or if the input is undefined.
* 根据目标输入获取的 DOM 元素,如果未找到或输入为 undefined,则返回 undefined。
*/
-export const getElement = (
- target: string | HTMLElement | undefined,
- container?: Document | HTMLElement,
-): HTMLElement | undefined => {
+export function getElement(target: string | HTMLElement | undefined, container?: Document | HTMLElement): HTMLElement | undefined {
if (isString(target)) {
const selector = target[0] === "#" ? `[id='${target.slice(1)}']` : target;
return querySelector(selector, container);
}
return target;
-};
+}
diff --git a/src/utils/src/mitt.ts b/src/utils/src/mitt.ts
index 3a7a2a3..81ddb11 100644
--- a/src/utils/src/mitt.ts
+++ b/src/utils/src/mitt.ts
@@ -25,15 +25,12 @@ export type EventHandlerMap> = Map<
export interface Emitter> {
all: EventHandlerMap;
- on(type: Key, handler: Handler): void;
- on(type: "*", handler: WildcardHandler): void;
+ on: ((type: Key, handler: Handler) => void) & ((type: "*", handler: WildcardHandler) => void);
- off(type: Key, handler?: Handler): void;
- off(type: "*", handler: WildcardHandler): void;
+ off: ((type: Key, handler?: Handler) => void) & ((type: "*", handler: WildcardHandler) => void);
- emit(type: Key, event: Events[Key]): void;
- emit(type: undefined extends Events[Key] ? Key : never): void;
- clear(): void;
+ emit: ((type: Key, event: Events[Key]) => void) & ((type: undefined extends Events[Key] ? Key : never) => void);
+ clear: () => void;
}
/**
diff --git a/src/utils/src/rules.ts b/src/utils/src/rules.ts
index 802cabe..a206d45 100644
--- a/src/utils/src/rules.ts
+++ b/src/utils/src/rules.ts
@@ -32,7 +32,7 @@ const codeRules: FieldRule[] = [
*/
const nameRules: FieldRule[] = [
{ required: true, message: "请输入真实姓名" },
- { pattern: /^(?:[\u4E00-\u9FA5·]{2,16})$/, message: "姓名必须为2-16个中文字符,可包含中间点" },
+ { pattern: /^[\u4E00-\u9FA5·]{2,16}$/, message: "姓名必须为2-16个中文字符,可包含中间点" },
];
/**
@@ -42,7 +42,7 @@ const idCardRules: FieldRule[] = [
{ required: true, message: "请输入身份证号" },
{
pattern:
- /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/,
+ /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[12]\d|30|31)\d{3}[\dX]$/i,
message: "身份证号格式不正确,请输入合法的身份证号码",
},
];
diff --git a/src/utils/src/typeChecks.ts b/src/utils/src/typeChecks.ts
index 46fb00c..ca8ce3a 100644
--- a/src/utils/src/typeChecks.ts
+++ b/src/utils/src/typeChecks.ts
@@ -85,8 +85,6 @@ export function isHttpUrl(path: string): boolean {
return regex.test(path);
}
-export const isComponentInstance = (
- value: any,
-): value is ComponentPublicInstance => {
+export function isComponentInstance(value: any): value is ComponentPublicInstance {
return value?.$ !== undefined;
-};
+}
diff --git a/src/utils/src/util.ts b/src/utils/src/util.ts
index ad0eb7b..c134dff 100644
--- a/src/utils/src/util.ts
+++ b/src/utils/src/util.ts
@@ -170,7 +170,6 @@ export function getErrorMessage(error: Error | { message: string } | string): st
// A constant function that does nothing and returns undefined
// 一个什么都不做并返回 undefined 的常量函数
-export const NOOP = (): undefined => {
- // eslint-disable-next-line no-void
+export function NOOP(): undefined {
return void 0;
-};
+}
diff --git a/src/utils/src/vue/install.ts b/src/utils/src/vue/install.ts
index 06c0986..c6b14e0 100644
--- a/src/utils/src/vue/install.ts
+++ b/src/utils/src/vue/install.ts
@@ -6,10 +6,7 @@ export type SFCWithInstall = T & Plugin;
export type SFCInstallWithContext = SFCWithInstall & {
_context: AppContext | null;
};
-export const withInstall = >(
- main: T,
- extra?: E,
-) => {
+export function withInstall>(main: T, extra?: E) {
(main as SFCWithInstall).install = (app): void => {
for (const comp of [main, ...Object.values(extra ?? {})]) {
app.component(comp.name, comp);
@@ -22,30 +19,27 @@ export const withInstall = >(
}
}
return main as SFCWithInstall & E;
-};
+}
-export const withInstallFunction = (fn: T, name: string) => {
+export function withInstallFunction(fn: T, name: string) {
(fn as SFCWithInstall).install = (app: App) => {
(fn as SFCInstallWithContext)._context = app._context;
app.config.globalProperties[name] = fn;
};
return fn as SFCInstallWithContext;
-};
+}
-export const withInstallDirective = (
- directive: T,
- name: string,
-) => {
+export function withInstallDirective(directive: T, name: string) {
(directive as SFCWithInstall).install = (app: App): void => {
app.directive(name, directive);
};
return directive as SFCWithInstall;
-};
+}
-export const withNoopInstall = (component: T) => {
+export function withNoopInstall(component: T) {
(component as SFCWithInstall).install = NOOP;
return component as SFCWithInstall;
-};
+}
diff --git a/tsconfig.json b/tsconfig.json
index 0f669a9..ca80759 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,30 +1,30 @@
{
"compilerOptions": {
"target": "ESNext",
- "lib": ["DOM", "ESNext"],
"jsx": "preserve",
+ "lib": ["DOM", "ESNext"],
+ "baseUrl": ".",
"module": "ESNext",
"moduleResolution": "node",
- "baseUrl": ".",
"paths": {
"~/*": ["src/*"],
"#/*": ["types/*"]
},
+ "resolveJsonModule": true,
+ "typeRoots": ["./types"],
"types": [
"vitest",
"vite/client",
"unplugin-icons/types/vue",
"@intlify/unplugin-vue-i18n/messages"
],
- "typeRoots": ["./types"],
- "resolveJsonModule": true,
"allowJs": true,
- "isolatedModules": true,
- "esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "isolatedModules": true,
"skipLibCheck": true
},
"exclude": ["dist", "node_modules"]
diff --git a/types/env.d.ts b/types/env.d.ts
index 4af4bfd..f5d8917 100644
--- a/types/env.d.ts
+++ b/types/env.d.ts
@@ -2,7 +2,7 @@
declare module "*.vue" {
import type { DefineComponent } from "vue";
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
- const component: DefineComponent<{}, {}, any>;
+
+ const component: DefineComponent