diff --git a/build/proxy.ts b/build/proxy.ts index 80004cadd..7cae8eba0 100644 --- a/build/proxy.ts +++ b/build/proxy.ts @@ -2,9 +2,9 @@ type ProxyItem = [string, string]; type ProxyList = ProxyItem[]; -const regExps = (value: string,reg: string): string => { - return value.replace(new RegExp(reg, 'g'), ''); -} +const regExps = (value: string, reg: string): string => { + return value.replace(new RegExp(reg, "g"), ""); +}; export function createProxy(list: ProxyList = []) { const ret: any = {}; @@ -12,8 +12,8 @@ export function createProxy(list: ProxyList = []) { ret[prefix] = { target: target, changeOrigin: true, - rewrite: (path:string) => regExps(path, prefix) + rewrite: (path: string) => regExps(path, prefix) }; } return ret; -} \ No newline at end of file +} diff --git a/build/utils.ts b/build/utils.ts index 8161d1a1d..dfda2ff8c 100644 --- a/build/utils.ts +++ b/build/utils.ts @@ -1,4 +1,4 @@ -import * as dotenv from 'dotenv'; +import * as dotenv from "dotenv"; export interface ViteEnv { VITE_PORT: number; @@ -11,25 +11,28 @@ export interface ViteEnv { export function loadEnv(): ViteEnv { const env = process.env.NODE_ENV; const ret: any = {}; - const envList = [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env', ,] - envList.forEach((e) => { + // eslint-disable-next-line no-sparse-arrays + const envList = [`.env.${env}.local`, `.env.${env}`, ".env.local", ".env", ,]; + envList.forEach(e => { dotenv.config({ - path: e, + path: e }); }); for (const envName of Object.keys(process.env)) { - let realName = (process.env as any)[envName].replace(/\\n/g, '\n'); - realName = realName === 'true' ? true : realName === 'false' ? false : realName; - if (envName === 'VITE_PORT') { + let realName = (process.env as any)[envName].replace(/\\n/g, "\n"); + realName = + realName === "true" ? true : realName === "false" ? false : realName; + if (envName === "VITE_PORT") { realName = Number(realName); } - if (envName === 'VITE_OPEN') { + if (envName === "VITE_OPEN") { realName = Boolean(realName); } - if (envName === 'VITE_PROXY') { + if (envName === "VITE_PROXY") { try { realName = JSON.parse(realName); - } catch (error) { } + // eslint-disable-next-line no-empty + } catch (error) {} } ret[envName] = realName; process.env[envName] = realName; diff --git a/mock/asyncRoutes.ts b/mock/asyncRoutes.ts index 2eb386bd7..3adb46122 100644 --- a/mock/asyncRoutes.ts +++ b/mock/asyncRoutes.ts @@ -11,7 +11,7 @@ const systemRouter = { title: "message.hssysManagement", showLink: true, savedPosition: true, - rank: 6, + rank: 6 }, children: [ { @@ -20,8 +20,8 @@ const systemRouter = { meta: { title: "message.hsBaseinfo", showLink: true, - savedPosition: true, - }, + savedPosition: true + } }, { path: "/system/dict", @@ -29,10 +29,10 @@ const systemRouter = { meta: { title: "message.hsDict", showLink: true, - savedPosition: true, - }, - }, - ], + savedPosition: true + } + } + ] }; const permissionRouter = { @@ -44,7 +44,7 @@ const permissionRouter = { icon: "el-icon-lollipop", showLink: true, savedPosition: true, - rank: 3, + rank: 3 }, children: [ { @@ -53,8 +53,8 @@ const permissionRouter = { meta: { title: "message.permissionPage", showLink: true, - savedPosition: true, - }, + savedPosition: true + } }, { path: "/permission/button", @@ -63,10 +63,10 @@ const permissionRouter = { title: "message.permissionButton", showLink: true, savedPosition: true, - authority: [], - }, - }, - ], + authority: [] + } + } + ] }; // 添加不同按钮权限到/permission/button页面中 @@ -83,14 +83,14 @@ export default [ if (query.name === "admin") { return { code: 0, - info: [systemRouter, setDifAuthority("v-admin", permissionRouter)], + info: [systemRouter, setDifAuthority("v-admin", permissionRouter)] }; } else { return { code: 0, - info: [setDifAuthority("v-test", permissionRouter)], + info: [setDifAuthority("v-test", permissionRouter)] }; } - }, - }, + } + } ] as MockMethod[]; diff --git a/mock/echarts.ts b/mock/echarts.ts index b1f0aabd1..fbf2ffd6d 100644 --- a/mock/echarts.ts +++ b/mock/echarts.ts @@ -1,23 +1,23 @@ -import { MockMethod } from 'vite-plugin-mock' +import { MockMethod } from "vite-plugin-mock"; // http://mockjs.com/examples.html#Object const echartsList = (): any => { - const result: any[] = [] + const result: any[] = []; for (let index = 0; index < 200; index++) { - result.push(['@date', Math.floor(Math.random() * 300)]) + result.push(["@date", Math.floor(Math.random() * 300)]); } - return result -} + return result; +}; export default [ { - url: '/getEchartsInfo', - method: 'get', + url: "/getEchartsInfo", + method: "get", response: () => { return { code: 0, info: echartsList() - } - }, + }; + } } -] as MockMethod[] +] as MockMethod[]; diff --git a/mock/map.ts b/mock/map.ts index 4ff83e6ca..942231a91 100644 --- a/mock/map.ts +++ b/mock/map.ts @@ -9,7 +9,7 @@ const mapList = (): any => { driver: "@cname()", "orientation|1-360": 100, "lng|113-114.1-10": 1, - "lat|34-35.1-10": 1, + "lat|34-35.1-10": 1 }); } return result; @@ -22,8 +22,8 @@ export default [ response: () => { return { code: 0, - info: mapList(), + info: mapList() }; - }, - }, + } + } ] as MockMethod[]; diff --git a/src/utils/http/types.d.ts b/src/utils/http/types.d.ts index 4c5564fe8..444c04283 100644 --- a/src/utils/http/types.d.ts +++ b/src/utils/http/types.d.ts @@ -1,48 +1,50 @@ import Axios, { - AxiosRequestConfig, - Canceler, - AxiosResponse, - Method, - AxiosError -} from "axios" + AxiosRequestConfig, + Canceler, + AxiosResponse, + Method, + AxiosError +} from "axios"; -import { METHODS } from './config' +import { METHODS } from "./config"; -export type cancelTokenType = { cancelKey: string, cancelExecutor: Canceler } +export type cancelTokenType = { cancelKey: string; cancelExecutor: Canceler }; -export type RequestMethods = Extract +export type RequestMethods = Extract< + Method, + "get" | "post" | "put" | "delete" | "patch" | "option" | "head" +>; export interface EnclosureHttpRequestConfig extends AxiosRequestConfig { - beforeRequestCallback?: (request: EnclosureHttpRequestConfig) => void // 请求发送之前 - beforeResponseCallback?: (response: EnclosureHttpResoponse) => void // 相应返回之前 + beforeRequestCallback?: (request: EnclosureHttpRequestConfig) => void; // 请求发送之前 + beforeResponseCallback?: (response: EnclosureHttpResoponse) => void; // 相应返回之前 } export interface EnclosureHttpResoponse extends AxiosResponse { - config: EnclosureHttpRequestConfig + config: EnclosureHttpRequestConfig; } export interface EnclosureHttpError extends AxiosError { - isCancelRequest?: boolean + isCancelRequest?: boolean; } export default class EnclosureHttp { - cancelTokenList: Array - clearCancelTokenList(): void - request( - method: RequestMethods, - url: string, - param?: AxiosRequestConfig, - axiosConfig?: EnclosureHttpRequestConfig - ): Promise - post( - url: string, - params?: T, - config?: EnclosureHttpRequestConfig - ): Promise - get( - url: string, - params?: T, - config?: EnclosureHttpRequestConfig - ): Promise -} \ No newline at end of file + cancelTokenList: Array; + clearCancelTokenList(): void; + request( + method: RequestMethods, + url: string, + param?: AxiosRequestConfig, + axiosConfig?: EnclosureHttpRequestConfig + ): Promise; + post( + url: string, + params?: T, + config?: EnclosureHttpRequestConfig + ): Promise; + get( + url: string, + params?: T, + config?: EnclosureHttpRequestConfig + ): Promise; +} diff --git a/types/global.d.ts b/types/global.d.ts index 99e415012..bf7f8d309 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -3,7 +3,7 @@ import type { VNode, ComponentPublicInstance, FunctionalComponent, - PropType as VuePropType, + PropType as VuePropType } from "vue"; declare global { diff --git a/types/index.d.ts b/types/index.d.ts index 4b29ded3f..314e07fc2 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,26 +1,27 @@ declare interface Fn { - (...arg: T[]): R + (...arg: T[]): R; } declare interface PromiseFn { - (...arg: T[]): Promise + (...arg: T[]): Promise; } -declare type RefType = T | null +declare type RefType = T | null; declare type LabelValueOptions = { - label: string - value: any -}[] + label: string; + value: any; +}[]; -declare type EmitType = (event: string, ...args: any[]) => void +declare type EmitType = (event: string, ...args: any[]) => void; -declare type TargetContext = '_self' | '_blank' +declare type TargetContext = "_self" | "_blank"; declare interface ComponentElRef { - $el: T + $el: T; } -declare type ComponentRef = ComponentElRef | null +declare type ComponentRef = + ComponentElRef | null; -declare type ElRef = Nullable +declare type ElRef = Nullable; diff --git a/types/shims-tsx.d.ts b/types/shims-tsx.d.ts index c67e97937..4d21788cc 100644 --- a/types/shims-tsx.d.ts +++ b/types/shims-tsx.d.ts @@ -1,16 +1,16 @@ -import Vue, { VNode } from "vue" +import Vue, { VNode } from "vue"; -declare module '*.tsx' { - import Vue from 'compatible-vue' - export default Vue +declare module "*.tsx" { + import Vue from "compatible-vue"; + export default Vue; } declare global { namespace JSX { - interface Element extends VNode { } - interface ElementClass extends Vue { } + interface Element extends VNode {} + interface ElementClass extends Vue {} interface IntrinsicElements { - [elem: string]: any + [elem: string]: any; } } }