mirror of
https://github.com/sunniejs/vue-h5-template.git
synced 2025-04-05 19:42:08 +08:00
feat: 优化项目环境变量
This commit is contained in:
parent
b8dfa9f6b9
commit
18dbf4c9b6
@ -1,3 +1,5 @@
|
||||
VITE_USE_MOCK=true
|
||||
|
||||
VITE_USE_ERUDA=true
|
||||
VITE_USE_ERUDA=false
|
||||
|
||||
VITE_USE_COMPRESS=false
|
@ -1,3 +1,5 @@
|
||||
VITE_USE_MOCK=false
|
||||
VITE_USE_MOCK=true
|
||||
|
||||
VITE_USE_ERUDA=false
|
||||
VITE_USE_ERUDA=false
|
||||
|
||||
VITE_USE_COMPRESS=true
|
@ -1,3 +1,5 @@
|
||||
VITE_USE_MOCK=true
|
||||
|
||||
VITE_USE_ERUDA=true
|
||||
VITE_USE_ERUDA=true
|
||||
|
||||
VITE_USE_COMPRESS=true
|
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -8,6 +8,7 @@
|
||||
"nutui",
|
||||
"pinia",
|
||||
"stylelint",
|
||||
"Tabbar",
|
||||
"unplugin",
|
||||
"vant",
|
||||
"vite",
|
||||
|
@ -20,7 +20,7 @@ import { ConfigImageminPlugin } from './imagemin';
|
||||
import { ConfigVisualizerConfig } from './visualizer';
|
||||
|
||||
export function createVitePlugins(env: ViteEnv, isBuild: boolean) {
|
||||
const { VITE_USE_MOCK, VITE_USE_ERUDA } = env;
|
||||
const { VITE_USE_MOCK, VITE_USE_ERUDA, VITE_USE_COMPRESS } = env;
|
||||
|
||||
const vitePlugins: (PluginOption | PluginOption[])[] = [
|
||||
// vue支持
|
||||
@ -40,9 +40,6 @@ export function createVitePlugins(env: ViteEnv, isBuild: boolean) {
|
||||
// 自动生成路由
|
||||
vitePlugins.push(ConfigPagesPlugin());
|
||||
|
||||
// 开启.gz压缩 rollup-plugin-gzip
|
||||
vitePlugins.push(ConfigCompressPlugin());
|
||||
|
||||
// 监听配置文件改动重启
|
||||
vitePlugins.push(ConfigRestartPlugin());
|
||||
|
||||
@ -64,6 +61,9 @@ export function createVitePlugins(env: ViteEnv, isBuild: boolean) {
|
||||
if (isBuild) {
|
||||
// vite-plugin-imagemin
|
||||
vitePlugins.push(ConfigImageminPlugin());
|
||||
|
||||
// 开启.gz压缩 rollup-plugin-gzip
|
||||
VITE_USE_COMPRESS && vitePlugins.push(ConfigCompressPlugin());
|
||||
}
|
||||
|
||||
return vitePlugins;
|
||||
|
53
types/axios.d.ts
vendored
53
types/axios.d.ts
vendored
@ -1,53 +0,0 @@
|
||||
export type ErrorMessageMode = 'none' | 'modal' | 'message' | undefined;
|
||||
|
||||
export interface RequestOptions {
|
||||
// Splicing request parameters to url
|
||||
joinParamsToUrl?: boolean;
|
||||
// Format request parameter time
|
||||
formatDate?: boolean;
|
||||
// Whether to process the request result
|
||||
isTransformResponse?: boolean;
|
||||
// Whether to return native response headers
|
||||
// For example: use this attribute when you need to get the response headers
|
||||
isReturnNativeResponse?: boolean;
|
||||
// Whether to join url
|
||||
joinPrefix?: boolean;
|
||||
// Interface address, use the default apiUrl if you leave it blank
|
||||
apiUrl?: string;
|
||||
// 请求拼接路径
|
||||
urlPrefix?: string;
|
||||
// Error message prompt type
|
||||
errorMessageMode?: ErrorMessageMode;
|
||||
// Whether to add a timestamp
|
||||
joinTime?: boolean;
|
||||
ignoreCancelToken?: boolean;
|
||||
// Whether to send token in header
|
||||
withToken?: boolean;
|
||||
// 请求重试机制
|
||||
retryRequest?: RetryRequest;
|
||||
}
|
||||
|
||||
export interface RetryRequest {
|
||||
isOpenRetry: boolean;
|
||||
count: number;
|
||||
waitTime: number;
|
||||
}
|
||||
export interface Result<T = any> {
|
||||
code: number;
|
||||
type: 'success' | 'error' | 'warning';
|
||||
message: string;
|
||||
result: T;
|
||||
}
|
||||
|
||||
// multipart/form-data: upload file
|
||||
export interface UploadFileParams {
|
||||
// Other parameters
|
||||
data?: Recordable;
|
||||
// File parameter interface field name
|
||||
name?: string;
|
||||
// file name
|
||||
file: File | Blob;
|
||||
// file name
|
||||
filename?: string;
|
||||
[key: string]: any;
|
||||
}
|
162
types/config.d.ts
vendored
162
types/config.d.ts
vendored
@ -1,162 +0,0 @@
|
||||
import { MenuTypeEnum, MenuModeEnum, TriggerEnum, MixSidebarTriggerEnum } from '/@/enums/menuEnum';
|
||||
import {
|
||||
ContentEnum,
|
||||
PermissionModeEnum,
|
||||
ThemeEnum,
|
||||
RouterTransitionEnum,
|
||||
SettingButtonPositionEnum,
|
||||
SessionTimeoutProcessingEnum,
|
||||
} from '/@/enums/appEnum';
|
||||
|
||||
import { CacheTypeEnum } from '/@/enums/cacheEnum';
|
||||
|
||||
export type LocaleType = 'zh_CN' | 'en' | 'ru' | 'ja' | 'ko';
|
||||
|
||||
export interface MenuSetting {
|
||||
bgColor: string;
|
||||
fixed: boolean;
|
||||
collapsed: boolean;
|
||||
siderHidden: boolean;
|
||||
canDrag: boolean;
|
||||
show: boolean;
|
||||
hidden: boolean;
|
||||
split: boolean;
|
||||
menuWidth: number;
|
||||
mode: MenuModeEnum;
|
||||
type: MenuTypeEnum;
|
||||
theme: ThemeEnum;
|
||||
topMenuAlign: 'start' | 'center' | 'end';
|
||||
trigger: TriggerEnum;
|
||||
accordion: boolean;
|
||||
closeMixSidebarOnChange: boolean;
|
||||
collapsedShowTitle: boolean;
|
||||
mixSideTrigger: MixSidebarTriggerEnum;
|
||||
mixSideFixed: boolean;
|
||||
}
|
||||
|
||||
export interface MultiTabsSetting {
|
||||
cache: boolean;
|
||||
show: boolean;
|
||||
showQuick: boolean;
|
||||
canDrag: boolean;
|
||||
showRedo: boolean;
|
||||
showFold: boolean;
|
||||
}
|
||||
|
||||
export interface HeaderSetting {
|
||||
bgColor: string;
|
||||
fixed: boolean;
|
||||
show: boolean;
|
||||
theme: ThemeEnum;
|
||||
// Turn on full screen
|
||||
showFullScreen: boolean;
|
||||
// Whether to show the lock screen
|
||||
useLockPage: boolean;
|
||||
// Show document button
|
||||
showDoc: boolean;
|
||||
// Show message center button
|
||||
showNotice: boolean;
|
||||
showSearch: boolean;
|
||||
}
|
||||
|
||||
export interface LocaleSetting {
|
||||
showPicker: boolean;
|
||||
// Current language
|
||||
locale: LocaleType;
|
||||
// default language
|
||||
fallback: LocaleType;
|
||||
// available Locales
|
||||
availableLocales: LocaleType[];
|
||||
}
|
||||
|
||||
export interface TransitionSetting {
|
||||
// Whether to open the page switching animation
|
||||
enable: boolean;
|
||||
// Route basic switching animation
|
||||
basicTransition: RouterTransitionEnum;
|
||||
// Whether to open page switching loading
|
||||
openPageLoading: boolean;
|
||||
// Whether to open the top progress bar
|
||||
openNProgress: boolean;
|
||||
}
|
||||
|
||||
export interface ProjectConfig {
|
||||
// Storage location of permission related information
|
||||
permissionCacheType: CacheTypeEnum;
|
||||
// Whether to show the configuration button
|
||||
showSettingButton: boolean;
|
||||
// Whether to show the theme switch button
|
||||
showDarkModeToggle: boolean;
|
||||
// Configure where the button is displayed
|
||||
settingButtonPosition: SettingButtonPositionEnum;
|
||||
// Permission mode
|
||||
permissionMode: PermissionModeEnum;
|
||||
// Session timeout processing
|
||||
sessionTimeoutProcessing: SessionTimeoutProcessingEnum;
|
||||
// Website gray mode, open for possible mourning dates
|
||||
grayMode: boolean;
|
||||
// Whether to turn on the color weak mode
|
||||
colorWeak: boolean;
|
||||
// Theme color
|
||||
themeColor: string;
|
||||
|
||||
// The main interface is displayed in full screen, the menu is not displayed, and the top
|
||||
fullContent: boolean;
|
||||
// content width
|
||||
contentMode: ContentEnum;
|
||||
// Whether to display the logo
|
||||
showLogo: boolean;
|
||||
// Whether to show the global footer
|
||||
showFooter: boolean;
|
||||
// menuType: MenuTypeEnum;
|
||||
headerSetting: HeaderSetting;
|
||||
// menuSetting
|
||||
menuSetting: MenuSetting;
|
||||
// Multi-tab settings
|
||||
multiTabsSetting: MultiTabsSetting;
|
||||
// Animation configuration
|
||||
transitionSetting: TransitionSetting;
|
||||
// pageLayout whether to enable keep-alive
|
||||
openKeepAlive: boolean;
|
||||
// Lock screen time
|
||||
lockTime: number;
|
||||
// Show breadcrumbs
|
||||
showBreadCrumb: boolean;
|
||||
// Show breadcrumb icon
|
||||
showBreadCrumbIcon: boolean;
|
||||
// Use error-handler-plugin
|
||||
useErrorHandle: boolean;
|
||||
// Whether to open back to top
|
||||
useOpenBackTop: boolean;
|
||||
// Is it possible to embed iframe pages
|
||||
canEmbedIFramePage: boolean;
|
||||
// Whether to delete unclosed messages and notify when switching the interface
|
||||
closeMessageOnSwitch: boolean;
|
||||
// Whether to cancel the http request that has been sent but not responded when switching the interface.
|
||||
removeAllHttpPending: boolean;
|
||||
}
|
||||
|
||||
export interface GlobConfig {
|
||||
// Site title
|
||||
title: string;
|
||||
// Service interface url
|
||||
apiUrl: string;
|
||||
// Upload url
|
||||
uploadUrl?: string;
|
||||
// Service interface url prefix
|
||||
urlPrefix?: string;
|
||||
// Project abbreviation
|
||||
shortName: string;
|
||||
}
|
||||
export interface GlobEnvConfig {
|
||||
// Site title
|
||||
VITE_GLOB_APP_TITLE: string;
|
||||
// Service interface url
|
||||
VITE_GLOB_API_URL: string;
|
||||
// Service interface url prefix
|
||||
VITE_GLOB_API_URL_PREFIX?: string;
|
||||
// Project abbreviation
|
||||
VITE_GLOB_APP_SHORT_NAME: string;
|
||||
// Upload url
|
||||
VITE_GLOB_UPLOAD_URL?: string;
|
||||
}
|
5
types/global.d.ts
vendored
5
types/global.d.ts
vendored
@ -10,10 +10,6 @@ declare global {
|
||||
};
|
||||
lastBuildTime: string;
|
||||
};
|
||||
// declare interface Window {
|
||||
// // Global vue app instance
|
||||
// __APP__: App<Element>;
|
||||
// }
|
||||
|
||||
// vue
|
||||
declare type PropType<T> = VuePropType<T>;
|
||||
@ -52,6 +48,7 @@ declare global {
|
||||
declare interface ViteEnv {
|
||||
VITE_USE_MOCK: Boolean;
|
||||
VITE_USE_ERUDA: Boolean;
|
||||
VITE_USE_COMPRESS: Boolean;
|
||||
}
|
||||
|
||||
declare function parseInt(s: string | number, radix?: number): number;
|
||||
|
48
types/store.d.ts
vendored
48
types/store.d.ts
vendored
@ -1,48 +0,0 @@
|
||||
import { ErrorTypeEnum } from '/@/enums/exceptionEnum';
|
||||
import { MenuModeEnum, MenuTypeEnum } from '/@/enums/menuEnum';
|
||||
import { RoleInfo } from '/@/api/sys/model/userModel';
|
||||
|
||||
// Lock screen information
|
||||
export interface LockInfo {
|
||||
// Password required
|
||||
pwd?: string | undefined;
|
||||
// Is it locked?
|
||||
isLock?: boolean;
|
||||
}
|
||||
|
||||
// Error-log information
|
||||
export interface ErrorLogInfo {
|
||||
// Type of error
|
||||
type: ErrorTypeEnum;
|
||||
// Error file
|
||||
file: string;
|
||||
// Error name
|
||||
name?: string;
|
||||
// Error message
|
||||
message: string;
|
||||
// Error stack
|
||||
stack?: string;
|
||||
// Error detail
|
||||
detail: string;
|
||||
// Error url
|
||||
url: string;
|
||||
// Error time
|
||||
time?: string;
|
||||
}
|
||||
|
||||
export interface UserInfo {
|
||||
userId: string | number;
|
||||
username: string;
|
||||
realName: string;
|
||||
avatar: string;
|
||||
desc?: string;
|
||||
homePath?: string;
|
||||
roles: RoleInfo[];
|
||||
}
|
||||
|
||||
export interface BeforeMiniState {
|
||||
menuCollapsed?: boolean;
|
||||
menuSplit?: boolean;
|
||||
menuMode?: MenuModeEnum;
|
||||
menuType?: MenuTypeEnum;
|
||||
}
|
45
types/vue-router.d.ts
vendored
45
types/vue-router.d.ts
vendored
@ -1,45 +0,0 @@
|
||||
export {};
|
||||
|
||||
declare module 'vue-router' {
|
||||
interface RouteMeta extends Record<string | number | symbol, unknown> {
|
||||
orderNo?: number;
|
||||
// title
|
||||
title: string;
|
||||
// dynamic router level.
|
||||
dynamicLevel?: number;
|
||||
// dynamic router real route path (For performance).
|
||||
realPath?: string;
|
||||
// Whether to ignore permissions
|
||||
ignoreAuth?: boolean;
|
||||
// role info
|
||||
roles?: RoleEnum[];
|
||||
// Whether not to cache
|
||||
ignoreKeepAlive?: boolean;
|
||||
// Is it fixed on tab
|
||||
affix?: boolean;
|
||||
// icon on tab
|
||||
icon?: string;
|
||||
frameSrc?: string;
|
||||
// current page transition
|
||||
transitionName?: string;
|
||||
// Whether the route has been dynamically added
|
||||
hideBreadcrumb?: boolean;
|
||||
// Hide submenu
|
||||
hideChildrenInMenu?: boolean;
|
||||
// Carrying parameters
|
||||
carryParam?: boolean;
|
||||
// Used internally to mark single-level menus
|
||||
single?: boolean;
|
||||
// Currently active menu
|
||||
currentActiveMenu?: string;
|
||||
// Never show in tab
|
||||
hideTab?: boolean;
|
||||
// Never show in menu
|
||||
hideMenu?: boolean;
|
||||
isLink?: boolean;
|
||||
// only build for Menu
|
||||
ignoreRoute?: boolean;
|
||||
// Hide path for children
|
||||
hidePathForChildren?: boolean;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user