feat(frontend): implement P0 optimization baseline

This commit is contained in:
yml2213
2026-05-15 16:07:04 +08:00
parent 11678a7f83
commit f43cee1ba0
4 changed files with 574 additions and 9 deletions
+12 -5
View File
@@ -8,6 +8,7 @@ import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const allowedHosts = parseAllowedHosts(env.VITE_ALLOWED_HOSTS)
return {
plugins: [
@@ -28,11 +29,8 @@ export default defineConfig(({ mode }) => {
},
},
server: {
// 👇 加入这行,允许通过 IP 和网络访问
host: true,
// 👇 加入这行,允许所有外部域名(包括 Cloudflare 分配的域名)访问
allowedHosts: true,
host: env.VITE_DEV_HOST === 'true',
allowedHosts: env.VITE_ALLOW_ALL_HOSTS === 'true' ? true : allowedHosts,
proxy: {
'/api': {
target: env.VITE_API_TARGET || 'http://localhost:3000',
@@ -42,3 +40,12 @@ export default defineConfig(({ mode }) => {
},
}
})
function parseAllowedHosts(value?: string) {
const hosts = value
?.split(',')
.map((host) => host.trim())
.filter(Boolean)
return hosts && hosts.length > 0 ? hosts : ['localhost', '127.0.0.1']
}