diff --git a/.env.development b/.env.development index 705528ef..8f01027c 100644 --- a/.env.development +++ b/.env.development @@ -1 +1 @@ -VITE_HTTP_PROXY=true +VITE_HTTP_PROXY=1 diff --git a/.env.production b/.env.production index 3165da1b..ee2e998c 100644 --- a/.env.production +++ b/.env.production @@ -1,6 +1,6 @@ -VITE_VISUALIZER=false +VITE_VISUALIZER=0 -VITE_COMPRESS=false +VITE_COMPRESS=0 # gzip | brotliCompress | deflate | deflateRaw VITE_COMPRESS_TYPE=gzip diff --git a/build/plugins/index.ts b/build/plugins/index.ts index cf543120..228fcc13 100644 --- a/build/plugins/index.ts +++ b/build/plugins/index.ts @@ -14,10 +14,10 @@ import compress from './compress'; export function setupVitePlugins(viteEnv: ImportMetaEnv): (PluginOption | PluginOption[])[] { const plugins = [...vue, html(viteEnv), ...unplugin, unocss, mock]; - if (viteEnv.VITE_VISUALIZER === 'true') { + if (viteEnv.VITE_VISUALIZER === '1') { plugins.push(visualizer); } - if (viteEnv.VITE_COMPRESS === 'true') { + if (viteEnv.VITE_COMPRESS === '1') { plugins.push(compress(viteEnv)); } diff --git a/package.json b/package.json index cd8c5aa8..2adfc3b7 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "build": "npm run typecheck && cross-env VITE_ENV_TYPE=prod vite build", "build:dev": "npm run typecheck && cross-env VITE_ENV_TYPE=dev vite build", "build:test": "npm run typecheck && cross-env VITE_ENV_TYPE=test vite build", - "build:vercel": "cross-env VITE_HASH_ROUTE=true vite build", + "build:vercel": "cross-env VITE_HASH_ROUTE=1 VITE_VERCEL=1 vite build", "preview": "vite preview", "typecheck": "vue-tsc --noEmit --skipLibCheck", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix", diff --git a/src/assets/fonts/aguazyuan-bold.ttf b/src/assets/fonts/aguazyuan-bold.ttf new file mode 100644 index 00000000..d9bd718d Binary files /dev/null and b/src/assets/fonts/aguazyuan-bold.ttf differ diff --git a/src/assets/fonts/aguazyuan-light.ttf b/src/assets/fonts/aguazyuan-light.ttf new file mode 100644 index 00000000..85e2e5de Binary files /dev/null and b/src/assets/fonts/aguazyuan-light.ttf differ diff --git a/src/assets/fonts/aguazyuan-regular.ttf b/src/assets/fonts/aguazyuan-regular.ttf new file mode 100644 index 00000000..f01c6fe0 Binary files /dev/null and b/src/assets/fonts/aguazyuan-regular.ttf differ diff --git a/src/context/demo.ts b/src/context/demo.ts index e40d8f6c..71f21af5 100644 --- a/src/context/demo.ts +++ b/src/context/demo.ts @@ -7,7 +7,7 @@ interface DemoContext { setCounts: (count: number) => void; } -const { useProvide: useDemoProvider, useInject: useDemoInject } = useContext(); +const { useProvide: useDemoProvide, useInject: useDemoInject } = useContext(); export function useDemoContext() { const counts = ref(0); @@ -21,12 +21,12 @@ export function useDemoContext() { setCounts }; - function useProvider() { - useDemoProvider(demoContext); + function useProvide() { + useDemoProvide(demoContext); } return { - useProvider, + useProvide, useInject: useDemoInject }; } @@ -34,8 +34,8 @@ export function useDemoContext() { // 示例用法: A.vue为父组件, B.vue为子孙组件 C.vue为子孙组件 // A.vue // import { useDemoContext } from '@/context'; -// const { useProvider } = useDemoContext(); -// useProvider(); +// const { useProvide } = useDemoContext(); +// useProvide(); // B.vue 和 C.vue : 共享状态 counts // import { useDemoContext } from '@/context'; diff --git a/src/layouts/common/GlobalHeader/index.vue b/src/layouts/common/GlobalHeader/index.vue index c25acdde..a5192b27 100644 --- a/src/layouts/common/GlobalHeader/index.vue +++ b/src/layouts/common/GlobalHeader/index.vue @@ -12,7 +12,7 @@ - + @@ -47,7 +47,7 @@ defineProps(); const theme = useThemeStore(); -const isProd = import.meta.env.PROD; +const showButton = import.meta.env.PROD && import.meta.env.VITE_VERCEL !== '1'; diff --git a/src/router/index.ts b/src/router/index.ts index 0efbb137..647edd7e 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -5,10 +5,10 @@ import { constantRoutes } from './routes'; import { scrollBehavior } from './helpers'; import { createRouterGuard } from './guard'; -const { VITE_HASH_ROUTE = 'false', VITE_BASE_URL } = import.meta.env; +const { VITE_HASH_ROUTE = '0', VITE_BASE_URL } = import.meta.env; export const router = createRouter({ - history: VITE_HASH_ROUTE === 'true' ? createWebHashHistory(VITE_BASE_URL) : createWebHistory(VITE_BASE_URL), + history: VITE_HASH_ROUTE === '1' ? createWebHashHistory(VITE_BASE_URL) : createWebHistory(VITE_BASE_URL), routes: transformAuthRoutesToVueRoutes(constantRoutes), scrollBehavior }); diff --git a/src/service/request/index.ts b/src/service/request/index.ts index a773940d..0c34b7c0 100644 --- a/src/service/request/index.ts +++ b/src/service/request/index.ts @@ -2,7 +2,7 @@ import { getEnvConfig } from '~/.env-config'; import { createRequest } from './request'; const envConfig = getEnvConfig(import.meta.env); -const isHttpProxy = import.meta.env.VITE_HTTP_PROXY === 'true'; +const isHttpProxy = import.meta.env.VITE_HTTP_PROXY === '1'; export const request = createRequest({ baseURL: isHttpProxy ? envConfig.proxy : envConfig.url }); diff --git a/src/typings/env.d.ts b/src/typings/env.d.ts index 7f99e555..0f2e2ad7 100644 --- a/src/typings/env.d.ts +++ b/src/typings/env.d.ts @@ -30,19 +30,21 @@ interface ImportMetaEnv { */ readonly VITE_AUTH_ROUTE_MODE: 'static' | 'dynamic'; /** 路由首页的路径 */ - readonly VITE_ROUTE_HOME_PATH: Exclude; + readonly VITE_ROUTE_HOME_PATH: Exclude; /** vite环境类型 */ readonly VITE_ENV_TYPE?: EnvType; /** 开启请求代理 */ - readonly VITE_HTTP_PROXY?: 'true' | 'false'; + readonly VITE_HTTP_PROXY?: '1' | '0'; /** 是否开启打包文件大小结果分析 */ - readonly VITE_VISUALIZER?: 'true' | 'false'; + readonly VITE_VISUALIZER?: '1' | '0'; /** 是否开启打包压缩 */ - readonly VITE_COMPRESS?: 'true' | 'false'; + readonly VITE_COMPRESS?: '1' | '0'; /** 压缩算法类型 */ readonly VITE_COMPRESS_TYPE?: 'gzip' | 'brotliCompress' | 'deflate' | 'deflateRaw'; /** hash路由模式 */ - readonly VITE_HASH_ROUTE?: 'true' | 'false'; + readonly VITE_HASH_ROUTE?: '1' | '0'; + /** 是否是部署的vercel */ + readonly VITE_VERCEL?: '1' | '0'; } interface ImportMeta { diff --git a/src/typings/system.d.ts b/src/typings/system.d.ts index 508a3160..d2917b5f 100644 --- a/src/typings/system.d.ts +++ b/src/typings/system.d.ts @@ -21,11 +21,6 @@ declare namespace EnumType { /** 请求的相关类型 */ declare namespace Service { - /** 请求环境类型 - * - test:测试环境 - * - prod:正式环境 */ - type HttpEnv = 'test' | 'prod'; - /** * 请求的错误类型: * - axios: axios错误:网络错误, 请求超时, 默认的兜底错误 diff --git a/tsconfig.json b/tsconfig.json index 637ede1c..db0d0aaa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,8 +13,8 @@ "strictNullChecks": true, "forceConsistentCasingInFileNames": true, "paths": { - "@/*": ["./src/*"], - "~/*": ["./*"] + "~/*": ["./*"], + "@/*": ["./src/*"] }, "types": [ "vite/client", @@ -23,5 +23,5 @@ "naive-ui/volar" ] }, - "exclude": ["dist", "node_modules"] + "exclude": ["node_modules", "dist"] } diff --git a/uno.config.ts b/uno.config.ts index 4010dd88..5eb52008 100644 --- a/uno.config.ts +++ b/uno.config.ts @@ -1,7 +1,7 @@ import { defineConfig, presetUno } from 'unocss'; export default defineConfig({ - exclude: ['node_modules', '.git', 'dist', 'mock', './stats.html'], + exclude: ['node_modules', '.git', '.husky', '.vscode', 'dist', 'public', 'build', 'mock', './stats.html'], presets: [presetUno({ dark: 'class' })], shortcuts: { 'wh-full': 'w-full h-full', diff --git a/vite.config.ts b/vite.config.ts index e046b574..f2a8b372 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -8,7 +8,7 @@ export default defineConfig(configEnv => { const rootPath = getRootPath(); const srcPath = getSrcPath(); - const isOpenProxy = viteEnv.VITE_HTTP_PROXY === 'true'; + const isOpenProxy = viteEnv.VITE_HTTP_PROXY === '1'; const envConfig = getEnvConfig(viteEnv); return {