mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 01:17:23 +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[];
|
type ProxyList = ProxyItem[];
|
||||||
|
|
||||||
const regExps = (value: string,reg: string): string => {
|
const regExps = (value: string, reg: string): string => {
|
||||||
return value.replace(new RegExp(reg, 'g'), '');
|
return value.replace(new RegExp(reg, "g"), "");
|
||||||
}
|
};
|
||||||
|
|
||||||
export function createProxy(list: ProxyList = []) {
|
export function createProxy(list: ProxyList = []) {
|
||||||
const ret: any = {};
|
const ret: any = {};
|
||||||
@ -12,7 +12,7 @@ export function createProxy(list: ProxyList = []) {
|
|||||||
ret[prefix] = {
|
ret[prefix] = {
|
||||||
target: target,
|
target: target,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path:string) => regExps(path, prefix)
|
rewrite: (path: string) => regExps(path, prefix)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as dotenv from 'dotenv';
|
import * as dotenv from "dotenv";
|
||||||
|
|
||||||
export interface ViteEnv {
|
export interface ViteEnv {
|
||||||
VITE_PORT: number;
|
VITE_PORT: number;
|
||||||
@ -11,25 +11,28 @@ export interface ViteEnv {
|
|||||||
export function loadEnv(): ViteEnv {
|
export function loadEnv(): ViteEnv {
|
||||||
const env = process.env.NODE_ENV;
|
const env = process.env.NODE_ENV;
|
||||||
const ret: any = {};
|
const ret: any = {};
|
||||||
const envList = [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env', ,]
|
// eslint-disable-next-line no-sparse-arrays
|
||||||
envList.forEach((e) => {
|
const envList = [`.env.${env}.local`, `.env.${env}`, ".env.local", ".env", ,];
|
||||||
|
envList.forEach(e => {
|
||||||
dotenv.config({
|
dotenv.config({
|
||||||
path: e,
|
path: e
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
for (const envName of Object.keys(process.env)) {
|
for (const envName of Object.keys(process.env)) {
|
||||||
let realName = (process.env as any)[envName].replace(/\\n/g, '\n');
|
let realName = (process.env as any)[envName].replace(/\\n/g, "\n");
|
||||||
realName = realName === 'true' ? true : realName === 'false' ? false : realName;
|
realName =
|
||||||
if (envName === 'VITE_PORT') {
|
realName === "true" ? true : realName === "false" ? false : realName;
|
||||||
|
if (envName === "VITE_PORT") {
|
||||||
realName = Number(realName);
|
realName = Number(realName);
|
||||||
}
|
}
|
||||||
if (envName === 'VITE_OPEN') {
|
if (envName === "VITE_OPEN") {
|
||||||
realName = Boolean(realName);
|
realName = Boolean(realName);
|
||||||
}
|
}
|
||||||
if (envName === 'VITE_PROXY') {
|
if (envName === "VITE_PROXY") {
|
||||||
try {
|
try {
|
||||||
realName = JSON.parse(realName);
|
realName = JSON.parse(realName);
|
||||||
} catch (error) { }
|
// eslint-disable-next-line no-empty
|
||||||
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
ret[envName] = realName;
|
ret[envName] = realName;
|
||||||
process.env[envName] = realName;
|
process.env[envName] = realName;
|
||||||
|
@ -11,7 +11,7 @@ const systemRouter = {
|
|||||||
title: "message.hssysManagement",
|
title: "message.hssysManagement",
|
||||||
showLink: true,
|
showLink: true,
|
||||||
savedPosition: true,
|
savedPosition: true,
|
||||||
rank: 6,
|
rank: 6
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
@ -20,8 +20,8 @@ const systemRouter = {
|
|||||||
meta: {
|
meta: {
|
||||||
title: "message.hsBaseinfo",
|
title: "message.hsBaseinfo",
|
||||||
showLink: true,
|
showLink: true,
|
||||||
savedPosition: true,
|
savedPosition: true
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/system/dict",
|
path: "/system/dict",
|
||||||
@ -29,10 +29,10 @@ const systemRouter = {
|
|||||||
meta: {
|
meta: {
|
||||||
title: "message.hsDict",
|
title: "message.hsDict",
|
||||||
showLink: true,
|
showLink: true,
|
||||||
savedPosition: true,
|
savedPosition: true
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
const permissionRouter = {
|
const permissionRouter = {
|
||||||
@ -44,7 +44,7 @@ const permissionRouter = {
|
|||||||
icon: "el-icon-lollipop",
|
icon: "el-icon-lollipop",
|
||||||
showLink: true,
|
showLink: true,
|
||||||
savedPosition: true,
|
savedPosition: true,
|
||||||
rank: 3,
|
rank: 3
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
@ -53,8 +53,8 @@ const permissionRouter = {
|
|||||||
meta: {
|
meta: {
|
||||||
title: "message.permissionPage",
|
title: "message.permissionPage",
|
||||||
showLink: true,
|
showLink: true,
|
||||||
savedPosition: true,
|
savedPosition: true
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/permission/button",
|
path: "/permission/button",
|
||||||
@ -63,10 +63,10 @@ const permissionRouter = {
|
|||||||
title: "message.permissionButton",
|
title: "message.permissionButton",
|
||||||
showLink: true,
|
showLink: true,
|
||||||
savedPosition: true,
|
savedPosition: true,
|
||||||
authority: [],
|
authority: []
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
],
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
// 添加不同按钮权限到/permission/button页面中
|
// 添加不同按钮权限到/permission/button页面中
|
||||||
@ -83,14 +83,14 @@ export default [
|
|||||||
if (query.name === "admin") {
|
if (query.name === "admin") {
|
||||||
return {
|
return {
|
||||||
code: 0,
|
code: 0,
|
||||||
info: [systemRouter, setDifAuthority("v-admin", permissionRouter)],
|
info: [systemRouter, setDifAuthority("v-admin", permissionRouter)]
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
code: 0,
|
code: 0,
|
||||||
info: [setDifAuthority("v-test", permissionRouter)],
|
info: [setDifAuthority("v-test", permissionRouter)]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
] as MockMethod[];
|
] as MockMethod[];
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
import { MockMethod } from 'vite-plugin-mock'
|
import { MockMethod } from "vite-plugin-mock";
|
||||||
|
|
||||||
// http://mockjs.com/examples.html#Object
|
// http://mockjs.com/examples.html#Object
|
||||||
const echartsList = (): any => {
|
const echartsList = (): any => {
|
||||||
const result: any[] = []
|
const result: any[] = [];
|
||||||
for (let index = 0; index < 200; index++) {
|
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 [
|
export default [
|
||||||
{
|
{
|
||||||
url: '/getEchartsInfo',
|
url: "/getEchartsInfo",
|
||||||
method: 'get',
|
method: "get",
|
||||||
response: () => {
|
response: () => {
|
||||||
return {
|
return {
|
||||||
code: 0,
|
code: 0,
|
||||||
info: echartsList()
|
info: echartsList()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
] as MockMethod[]
|
] as MockMethod[];
|
||||||
|
@ -9,7 +9,7 @@ const mapList = (): any => {
|
|||||||
driver: "@cname()",
|
driver: "@cname()",
|
||||||
"orientation|1-360": 100,
|
"orientation|1-360": 100,
|
||||||
"lng|113-114.1-10": 1,
|
"lng|113-114.1-10": 1,
|
||||||
"lat|34-35.1-10": 1,
|
"lat|34-35.1-10": 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -22,8 +22,8 @@ export default [
|
|||||||
response: () => {
|
response: () => {
|
||||||
return {
|
return {
|
||||||
code: 0,
|
code: 0,
|
||||||
info: mapList(),
|
info: mapList()
|
||||||
};
|
};
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
] as MockMethod[];
|
] as MockMethod[];
|
||||||
|
30
src/utils/http/types.d.ts
vendored
30
src/utils/http/types.d.ts
vendored
@ -4,45 +4,47 @@ import Axios, {
|
|||||||
AxiosResponse,
|
AxiosResponse,
|
||||||
Method,
|
Method,
|
||||||
AxiosError
|
AxiosError
|
||||||
} from "axios"
|
} 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' |
|
export type RequestMethods = Extract<
|
||||||
'option' | 'head'>
|
Method,
|
||||||
|
"get" | "post" | "put" | "delete" | "patch" | "option" | "head"
|
||||||
|
>;
|
||||||
|
|
||||||
export interface EnclosureHttpRequestConfig extends AxiosRequestConfig {
|
export interface EnclosureHttpRequestConfig extends AxiosRequestConfig {
|
||||||
beforeRequestCallback?: (request: EnclosureHttpRequestConfig) => void // 请求发送之前
|
beforeRequestCallback?: (request: EnclosureHttpRequestConfig) => void; // 请求发送之前
|
||||||
beforeResponseCallback?: (response: EnclosureHttpResoponse) => void // 相应返回之前
|
beforeResponseCallback?: (response: EnclosureHttpResoponse) => void; // 相应返回之前
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EnclosureHttpResoponse extends AxiosResponse {
|
export interface EnclosureHttpResoponse extends AxiosResponse {
|
||||||
config: EnclosureHttpRequestConfig
|
config: EnclosureHttpRequestConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EnclosureHttpError extends AxiosError {
|
export interface EnclosureHttpError extends AxiosError {
|
||||||
isCancelRequest?: boolean
|
isCancelRequest?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class EnclosureHttp {
|
export default class EnclosureHttp {
|
||||||
cancelTokenList: Array<cancelTokenType>
|
cancelTokenList: Array<cancelTokenType>;
|
||||||
clearCancelTokenList(): void
|
clearCancelTokenList(): void;
|
||||||
request<T>(
|
request<T>(
|
||||||
method: RequestMethods,
|
method: RequestMethods,
|
||||||
url: string,
|
url: string,
|
||||||
param?: AxiosRequestConfig,
|
param?: AxiosRequestConfig,
|
||||||
axiosConfig?: EnclosureHttpRequestConfig
|
axiosConfig?: EnclosureHttpRequestConfig
|
||||||
): Promise<T>
|
): Promise<T>;
|
||||||
post<T>(
|
post<T>(
|
||||||
url: string,
|
url: string,
|
||||||
params?: T,
|
params?: T,
|
||||||
config?: EnclosureHttpRequestConfig
|
config?: EnclosureHttpRequestConfig
|
||||||
): Promise<T>
|
): Promise<T>;
|
||||||
get<T>(
|
get<T>(
|
||||||
url: string,
|
url: string,
|
||||||
params?: T,
|
params?: T,
|
||||||
config?: EnclosureHttpRequestConfig
|
config?: EnclosureHttpRequestConfig
|
||||||
): Promise<T>
|
): Promise<T>;
|
||||||
}
|
}
|
2
types/global.d.ts
vendored
2
types/global.d.ts
vendored
@ -3,7 +3,7 @@ import type {
|
|||||||
VNode,
|
VNode,
|
||||||
ComponentPublicInstance,
|
ComponentPublicInstance,
|
||||||
FunctionalComponent,
|
FunctionalComponent,
|
||||||
PropType as VuePropType,
|
PropType as VuePropType
|
||||||
} from "vue";
|
} from "vue";
|
||||||
|
|
||||||
declare global {
|
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> {
|
declare interface Fn<T = any, R = T> {
|
||||||
(...arg: T[]): R
|
(...arg: T[]): R;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare interface PromiseFn<T = any, R = T> {
|
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 = {
|
declare type LabelValueOptions = {
|
||||||
label: string
|
label: string;
|
||||||
value: any
|
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> {
|
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' {
|
declare module "*.tsx" {
|
||||||
import Vue from 'compatible-vue'
|
import Vue from "compatible-vue";
|
||||||
export default Vue
|
export default Vue;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace JSX {
|
namespace JSX {
|
||||||
interface Element extends VNode { }
|
interface Element extends VNode {}
|
||||||
interface ElementClass extends Vue { }
|
interface ElementClass extends Vue {}
|
||||||
interface IntrinsicElements {
|
interface IntrinsicElements {
|
||||||
[elem: string]: any
|
[elem: string]: any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user