mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-06 00:18:51 +08:00
style: format style
This commit is contained in:
parent
a5172c9476
commit
9bb4f34707
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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[];
|
||||
|
@ -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[];
|
||||
|
@ -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[];
|
||||
|
68
src/utils/http/types.d.ts
vendored
68
src/utils/http/types.d.ts
vendored
@ -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<Method, 'get' | 'post' | 'put' | 'delete' | 'patch' |
|
||||
'option' | 'head'>
|
||||
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<cancelTokenType>
|
||||
clearCancelTokenList(): void
|
||||
request<T>(
|
||||
method: RequestMethods,
|
||||
url: string,
|
||||
param?: AxiosRequestConfig,
|
||||
axiosConfig?: EnclosureHttpRequestConfig
|
||||
): Promise<T>
|
||||
post<T>(
|
||||
url: string,
|
||||
params?: T,
|
||||
config?: EnclosureHttpRequestConfig
|
||||
): Promise<T>
|
||||
get<T>(
|
||||
url: string,
|
||||
params?: T,
|
||||
config?: EnclosureHttpRequestConfig
|
||||
): Promise<T>
|
||||
}
|
||||
cancelTokenList: Array<cancelTokenType>;
|
||||
clearCancelTokenList(): void;
|
||||
request<T>(
|
||||
method: RequestMethods,
|
||||
url: string,
|
||||
param?: AxiosRequestConfig,
|
||||
axiosConfig?: EnclosureHttpRequestConfig
|
||||
): Promise<T>;
|
||||
post<T>(
|
||||
url: string,
|
||||
params?: T,
|
||||
config?: EnclosureHttpRequestConfig
|
||||
): Promise<T>;
|
||||
get<T>(
|
||||
url: string,
|
||||
params?: T,
|
||||
config?: EnclosureHttpRequestConfig
|
||||
): Promise<T>;
|
||||
}
|
||||
|
2
types/global.d.ts
vendored
2
types/global.d.ts
vendored
@ -3,7 +3,7 @@ import type {
|
||||
VNode,
|
||||
ComponentPublicInstance,
|
||||
FunctionalComponent,
|
||||
PropType as VuePropType,
|
||||
PropType as VuePropType
|
||||
} from "vue";
|
||||
|
||||
declare global {
|
||||
|
23
types/index.d.ts
vendored
23
types/index.d.ts
vendored
@ -1,26 +1,27 @@
|
||||
declare interface Fn<T = any, R = T> {
|
||||
(...arg: T[]): R
|
||||
(...arg: T[]): R;
|
||||
}
|
||||
|
||||
declare interface PromiseFn<T = any, R = T> {
|
||||
(...arg: T[]): Promise<R>
|
||||
(...arg: T[]): Promise<R>;
|
||||
}
|
||||
|
||||
declare type RefType<T> = T | null
|
||||
declare type RefType<T> = 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<T extends HTMLElement = HTMLDivElement> {
|
||||
$el: T
|
||||
$el: T;
|
||||
}
|
||||
|
||||
declare type ComponentRef<T extends HTMLElement = HTMLDivElement> = ComponentElRef<T> | null
|
||||
declare type ComponentRef<T extends HTMLElement = HTMLDivElement> =
|
||||
ComponentElRef<T> | null;
|
||||
|
||||
declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>
|
||||
declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>;
|
||||
|
14
types/shims-tsx.d.ts
vendored
14
types/shims-tsx.d.ts
vendored
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user