diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..05f381c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +/node_modules +/.git +/.gitignore +/.vscode +/.DS_Store +/*.md +/dist + diff --git a/.env b/.env new file mode 100644 index 0000000..315929d --- /dev/null +++ b/.env @@ -0,0 +1,26 @@ +# 项目根目录 +VITE_BASE_URL = / + +# 项目名称 +VITE_APP_NAME = COI-ADMIN + +# 路由模式 web | hash +VITE_ROUTE_MODE = web + +# 路由加载模式 static | dynamic +VITE_ROUTE_LOAD_MODE = dynamic + +# 设置登陆后跳转地址 +VITE_HOME_PATH = /dashboard + +# 本地存储前缀 +VITE_STORAGE_PREFIX = + +# 版权信息 +VITE_COPYRIGHT_INFO = Copyright © 2024 Leocoder + +# 自动刷新token +VITE_AUTO_REFRESH_TOKEN = Y + +# 默认多语言 enUS | zhCN +VITE_DEFAULT_LANG = zhCN diff --git a/.env.dev b/.env.dev new file mode 100644 index 0000000..a6f9e31 --- /dev/null +++ b/.env.dev @@ -0,0 +1,2 @@ +# 是否开启服务接口代理 Y | N +VITE_HTTP_PROXY=N diff --git a/.env.prod b/.env.prod new file mode 100644 index 0000000..29a3c4e --- /dev/null +++ b/.env.prod @@ -0,0 +1,6 @@ +# 是否开启压缩资源 +VITE_BUILD_COMPRESS=N + +# 压缩算法 gzip | brotliCompress | deflate | deflateRaw +VITE_COMPRESS_TYPE=gzip + diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..29a3c4e --- /dev/null +++ b/.env.test @@ -0,0 +1,6 @@ +# 是否开启压缩资源 +VITE_BUILD_COMPRESS=N + +# 压缩算法 gzip | brotliCompress | deflate | deflateRaw +VITE_COMPRESS_TYPE=gzip + diff --git a/index.html b/index.html new file mode 100644 index 0000000..fbc0533 --- /dev/null +++ b/index.html @@ -0,0 +1,17 @@ + + + + + + + + %VITE_APP_NAME% + + + +
+
+ + + + diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..a661423 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,17 @@ +[build] +publish = "dist" +command = "vite build --mode prod" + +[build.environment] +NODE_VERSION = "20" + +[[redirects]] +from = "/*" +to = "/index.html" +status = 200 + +[[headers]] +for = "/manifest.webmanifest" + +[headers.values] +Content-Type = "application/manifest+json" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..9a275cd --- /dev/null +++ b/nginx.conf @@ -0,0 +1,66 @@ +server { + listen 80; + listen [::]:80; + + # 启用 gzip 压缩 + gzip on; + gzip_vary on; + gzip_min_length 10240; + gzip_proxied expired no-cache no-store private auth; + gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/javascript; + gzip_disable "MSIE [1-6]\."; + + # 设定 MIME types + include /etc/nginx/mime.types; + + # 基本安全设定 + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Content-Type-Options "nosniff"; + + # 增加伺服器效能的配置 + client_max_body_size 100M; + client_body_buffer_size 128k; + proxy_connect_timeout 90; + proxy_send_timeout 90; + proxy_read_timeout 90; + proxy_buffer_size 4k; + proxy_buffers 4 32k; + proxy_busy_buffers_size 64k; + + location / { + root /www; + index index.html; + try_files $uri $uri/ /index.html; + + # 设定快取控制 + location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { + expires 30d; + add_header Cache-Control "public, no-transform"; + } + + # 动态内容不快取 + location = /index.html { + add_header Cache-Control "no-store, no-cache, must-revalidate"; + add_header Pragma "no-cache"; + expires -1; + } + + # 错误处理 + proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; + proxy_intercept_errors on; + + # 基本的代理设定 + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + # 禁止访问隐藏文件 + location ~ /\. { + deny all; + access_log off; + log_not_found off; + } +}