소스 검색

2025-05-24 11:45:41

john.hong 2 달 전
부모
커밋
6276f1f7bf
6개의 변경된 파일474개의 추가작업 그리고 21개의 파일을 삭제
  1. 10 1
      .gitignore
  2. 50 0
      README.md
  3. BIN
      better-scroll-docs.zip
  4. 7 0
      docker-compose.yml
  5. 402 20
      nginx.conf
  6. 5 0
      push.sh

+ 10 - 1
.gitignore

@@ -1,4 +1,13 @@
 v2.cn.vuejs.org/
 v2.cn.vuejs.org/
 element/
 element/
 element2/
 element2/
-logs/
+better-scroll-docs/
+2x.ant.design/
+3x.ant.design/
+4x.ant.design/
+ant-design/
+better-scroll/
+docs-zh-cn/
+vant/
+logs/
+.DS_Store

+ 50 - 0
README.md

@@ -0,0 +1,50 @@
+## better-scroll
+
+### 依赖安装
+
+1、可以删除 "puppeteer": "^5.2.1", 因为 mac M1 芯片不支持低版本的puppeteer,同时 Chrome 下载存在问题,可以忽略这个依赖
+2、puppeteer 主要是作为单元测试存在
+
+### 打包
+
+#### 打包失败
+
+由于 node 版本过高需要在打包之前执行下面的方法,避免触发
+
+这个错误是由于 Node.js 版本与项目使用的加密算法不兼容导致的。错误信息显示:Error: error:0308010C:digital envelope routines::unsupported。
+
+这个问题通常出现在使用较新版本的 Node.js(比如 Node.js 18+)运行较旧的项目时。我们可以通过设置环境变量 NODE_OPTIONS 来解决这个问题:
+
+```bash
+export NODE_OPTIONS=--openssl-legacy-provider && yarn vue:build
+export NODE_OPTIONS=--openssl-legacy-provider && yarn docs:build
+```
+
+文档打包成功之后,文件位置是 better-scroll/packages/vuepress-docs/dist
+
+### 可选内容
+
+修改文件内容
+better-scroll/packages/vuepress-docs/docs/.vuepress/config.js
+
+```javascript
+module.exports = {
+  base: '/',
+  publicPath: '/',
+  // ... 维持正常的逻辑
+}
+```
+
+# 配置 /etc/host
+
+```
+127.0.0.1 element2.hht.test
+127.0.0.1 vue2.hht.test
+127.0.0.1 vue3.hht.test
+127.0.0.1 vant.hht.test
+127.0.0.1 ant-design.hht.test
+127.0.0.1 4x-ant-design.hht.test
+127.0.0.1 3x-ant-design.hht.test
+127.0.0.1 2x-ant-design.hht.test
+127.0.0.1 better-scroll-docs.hht.test
+```

BIN
better-scroll-docs.zip


+ 7 - 0
docker-compose.yml

@@ -8,6 +8,13 @@ services:
       - ./nginx.conf:/etc/nginx/nginx.conf:ro
       - ./nginx.conf:/etc/nginx/nginx.conf:ro
       - ./element:/usr/share/nginx/html/element2:ro
       - ./element:/usr/share/nginx/html/element2:ro
       - ./v2.cn.vuejs.org:/usr/share/nginx/html/v2.cn.vuejs.org:ro
       - ./v2.cn.vuejs.org:/usr/share/nginx/html/v2.cn.vuejs.org:ro
+      - ./vant:/usr/share/nginx/html/vant:ro
+      - ./docs-zh-cn:/usr/share/nginx/html/docs-zh-cn:ro
+      - ./ant-design:/usr/share/nginx/html/ant-design:ro
+      - ./4x.ant.design:/usr/share/nginx/html/4x.ant.design:ro
+      - ./3x.ant.design:/usr/share/nginx/html/3x.ant.design:ro
+      - ./2x.ant.design:/usr/share/nginx/html/2x.ant.design:ro
+      - ./better-scroll-docs:/usr/share/nginx/html/better-scroll-docs:ro
       - ./logs:/var/log/nginx
       - ./logs:/var/log/nginx
     restart: always
     restart: always
     networks:
     networks:

+ 402 - 20
nginx.conf

@@ -18,6 +18,21 @@ http {
     types_hash_max_size 2048;
     types_hash_max_size 2048;
     server_tokens off;  # 隐藏版本号
     server_tokens off;  # 隐藏版本号
 
 
+    # 性能优化配置
+    client_max_body_size 20m;
+    client_body_buffer_size 128k;
+    proxy_buffer_size 4k;
+    proxy_buffers 4 32k;
+    proxy_busy_buffers_size 64k;
+
+    # 全局 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]\.";
+
     # 日志配置优化
     # 日志配置优化
     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                       '$status $body_bytes_sent "$http_referer" '
                       '$status $body_bytes_sent "$http_referer" '
@@ -48,28 +63,36 @@ http {
     add_header X-Content-Type-Options "nosniff" always;
     add_header X-Content-Type-Options "nosniff" always;
     add_header Referrer-Policy "no-referrer-when-downgrade" always;
     add_header Referrer-Policy "no-referrer-when-downgrade" always;
     add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
     add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always;
+    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
+    add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
+
+    # 错误页面配置
+    error_page 404 /404.html;
+    error_page 500 502 503 504 /50x.html;
 
 
     # Element2 子域名配置
     # Element2 子域名配置
     server {
     server {
         listen 80;
         listen 80;
         server_name element2.hht.test;
         server_name element2.hht.test;
 
 
-        # 开启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]\.";
+        access_log /var/log/nginx/element2.access.log main;
+        error_log /var/log/nginx/element2.error.log warn;
 
 
         location / {
         location / {
             root /usr/share/nginx/html/element2;
             root /usr/share/nginx/html/element2;
             index index.html index.htm;
             index index.html index.htm;
             try_files $uri $uri/ /index.html;
             try_files $uri $uri/ /index.html;
 
 
-            # 缓存控制
-            expires 1h;
-            add_header Cache-Control "public, no-transform";
+            # 针对不同类型的文件设置不同的缓存时间
+            location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
+                expires 7d;
+                add_header Cache-Control "public, no-transform";
+            }
+            
+            location ~* \.(html|htm)$ {
+                expires 1h;
+                add_header Cache-Control "public, no-transform";
+            }
 
 
             # 跨域支持
             # 跨域支持
             add_header 'Access-Control-Allow-Origin' $cors_origin always;
             add_header 'Access-Control-Allow-Origin' $cors_origin always;
@@ -78,28 +101,360 @@ http {
             add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
             add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
         }
         }
     }
     }
-
+    
     # Vue2 子域名配置
     # Vue2 子域名配置
     server {
     server {
         listen 80;
         listen 80;
         server_name vue2.hht.test;
         server_name vue2.hht.test;
 
 
-        # 开启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]\.";
+        access_log /var/log/nginx/vue2.access.log main;
+        error_log /var/log/nginx/vue2.error.log warn;
 
 
         location / {
         location / {
             alias /usr/share/nginx/html/v2.cn.vuejs.org/;
             alias /usr/share/nginx/html/v2.cn.vuejs.org/;
             index index.html index.htm;
             index index.html index.htm;
             try_files $uri $uri/ /index.html;
             try_files $uri $uri/ /index.html;
 
 
-            # 缓存控制
-            expires 1h;
+            # 针对不同类型的文件设置不同的缓存时间
+            location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
+                expires 7d;
+                add_header Cache-Control "public, no-transform";
+            }
+            
+            location ~* \.(html|htm)$ {
+                expires 1h;
+                add_header Cache-Control "public, no-transform";
+            }
+
+            # 跨域支持
+            add_header 'Access-Control-Allow-Origin' $cors_origin always;
+            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
+            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
+            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
+        }
+    }
+    
+    # Vant 子域名配置
+    server {
+        listen 80;
+        server_name vant.hht.test;
+
+        access_log /var/log/nginx/vant.access.log main;
+        error_log /var/log/nginx/vant.error.log warn;
+
+        location / {
+            alias /usr/share/nginx/html/vant/;
+            index index.html index.htm;
+            try_files $uri $uri/ /index.html;
+
+            # 针对不同类型的文件设置不同的缓存时间
+            location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
+                expires 7d;
+                add_header Cache-Control "public, no-transform";
+            }
+            
+            location ~* \.(html|htm)$ {
+                expires 1h;
+                add_header Cache-Control "public, no-transform";
+            }
+
+            # 跨域支持
+            add_header 'Access-Control-Allow-Origin' $cors_origin always;
+            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
+            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
+            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
+        }
+        
+        location /vant/ {
+            alias  /usr/share/nginx/html/vant/;
+            try_files $uri $uri/ /tparking/index.html;
+            index  index.html;
+            # 跨域支持
+            add_header 'Access-Control-Allow-Origin' $cors_origin always;
+            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
+            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
+            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
+        }
+    }
+    
+    # Vue3 子域名配置
+    server {
+        listen 80;
+        listen 8877;  # 添加 8877 端口监听
+        server_name vue3.hht.test;
+
+        # 日志配置
+        access_log /var/log/nginx/vue3.access.log main buffer=32k flush=5s;
+        error_log /var/log/nginx/vue3.error.log warn;
+
+        # 安全相关配置
+        add_header X-Frame-Options "SAMEORIGIN" always;
+        add_header X-XSS-Protection "1; mode=block" always;
+        add_header X-Content-Type-Options "nosniff" always;
+
+        # 性能优化
+        client_max_body_size 10m;
+        client_body_timeout 12;
+        client_header_timeout 12;
+        keepalive_timeout 15;
+        send_timeout 10;
+
+        # 字体文件 MIME 类型
+        include /etc/nginx/mime.types;
+        types {
+            font/woff2 woff2;
+            font/woff woff;
+            font/ttf ttf;
+            font/eot eot;
+        }
+
+        location / {
+            alias /usr/share/nginx/html/docs-zh-cn/.vitepress/dist/;
+            index index.html index.htm;
+            try_files $uri $uri/ /index.html;
+
+            # 针对不同类型的文件设置不同的缓存时间
+            location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
+                expires 7d;
+                add_header Cache-Control "public, no-transform";
+                access_log off;
+            }
+            
+            location ~* \.(html|htm)$ {
+                expires 1h;
+                add_header Cache-Control "public, no-transform";
+            }
+
+            # 禁止访问隐藏文件
+            location ~ /\. {
+                deny all;
+                access_log off;
+                log_not_found off;
+            }
+
+            # 禁止访问 .git 目录
+            location ~ /\.git {
+                deny all;
+                access_log off;
+                log_not_found off;
+            }
+        }
+
+        # 静态资源缓存优化
+        location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
+            root /usr/share/nginx/html/docs-zh-cn/.vitepress/dist;
+            expires 7d;
+            add_header Cache-Control "public, no-transform";
+            access_log off;
+            tcp_nodelay off;
+            open_file_cache max=1000 inactive=20s;
+            open_file_cache_valid 30s;
+            open_file_cache_min_uses 2;
+            open_file_cache_errors on;
+            try_files $uri =404;
+        }
+
+        # 错误页面配置
+        error_page 404 /404.html;
+        error_page 500 502 503 504 /50x.html;
+        location = /404.html {
+            internal;
+        }
+        location = /50x.html {
+            internal;
+        }
+    }
+
+    # 2x ant-design 子域名配置
+    server {
+        listen 80;
+        server_name 2x-ant-design.hht.test;
+
+        access_log /var/log/nginx/2x-ant-design.access.log main;
+        error_log /var/log/nginx/2x-ant-design.error.log warn;
+    
+        location / {
+            root /usr/share/nginx/html/2x.ant.design;
+            index index.html index.htm;
+            try_files $uri $uri/ @router;
+
+            # 针对不同类型的文件设置不同的缓存时间
+            location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
+                expires 7d;
+                add_header Cache-Control "public, no-transform";
+            }
+            
+            location ~* \.(html|htm)$ {
+                expires 1h;
+                add_header Cache-Control "public, no-transform";
+            }
+
+            # 跨域支持
+            add_header 'Access-Control-Allow-Origin' $cors_origin always;
+            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
+            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
+            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
+        }
+        location @router {
+            rewrite ^.*$ /index.html last;
+        }
+    }
+
+    # 3x ant-design 子域名配置
+    server {
+        listen 80;
+        server_name 3x-ant-design.hht.test;
+
+        access_log /var/log/nginx/3x-ant-design.access.log main;
+        error_log /var/log/nginx/3x-ant-design.error.log warn;
+    
+        location / {
+            root /usr/share/nginx/html/3x.ant.design;
+            index index.html index.htm;
+            try_files $uri $uri/ @router;
+
+            # 针对不同类型的文件设置不同的缓存时间
+            location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
+                expires 7d;
+                add_header Cache-Control "public, no-transform";
+            }
+            
+            location ~* \.(html|htm)$ {
+                expires 1h;
+                add_header Cache-Control "public, no-transform";
+            }
+
+            # 跨域支持
+            add_header 'Access-Control-Allow-Origin' $cors_origin always;
+            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
+            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
+            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
+        }
+        location @router {
+            rewrite ^.*$ /index.html last;
+        }
+    }
+    
+    # 4x ant-design 子域名配置
+    server {
+        listen 80;
+        server_name 4x-ant-design.hht.test;
+
+        # 日志配置
+        access_log /var/log/nginx/4x-ant-design.access.log main buffer=32k flush=5s;
+        error_log /var/log/nginx/4x-ant-design.error.log warn;
+
+        # 安全相关配置
+        add_header X-Frame-Options "SAMEORIGIN" always;
+        add_header X-XSS-Protection "1; mode=block" always;
+        add_header X-Content-Type-Options "nosniff" always;
+
+        # 性能优化
+        client_max_body_size 10m;
+        client_body_timeout 12;
+        client_header_timeout 12;
+        keepalive_timeout 15;
+        send_timeout 10;
+
+        # 字体文件 MIME 类型
+        include /etc/nginx/mime.types;
+        types {
+            font/woff2 woff2;
+            font/woff woff;
+            font/ttf ttf;
+            font/eot eot;
+        }
+    
+        location / {
+            root /usr/share/nginx/html/4x.ant.design;
+            index index.html index.htm;
+            try_files $uri $uri/ @router;
+
+            # 针对不同类型的文件设置不同的缓存时间
+            location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
+                expires 7d;
+                add_header Cache-Control "public, no-transform";
+                access_log off;
+            }
+            
+            location ~* \.(html|htm)$ {
+                expires 1h;
+                add_header Cache-Control "public, no-transform";
+            }
+
+            # 禁止访问隐藏文件
+            location ~ /\. {
+                deny all;
+                access_log off;
+                log_not_found off;
+            }
+
+            # 禁止访问 .git 目录
+            location ~ /\.git {
+                deny all;
+                access_log off;
+                log_not_found off;
+            }
+
+            # 跨域支持
+            add_header 'Access-Control-Allow-Origin' $cors_origin always;
+            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
+            add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
+            add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
+        }
+
+        # 静态资源缓存优化
+        location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
+            root /usr/share/nginx/html/4x-ant-design;
+            expires 7d;
             add_header Cache-Control "public, no-transform";
             add_header Cache-Control "public, no-transform";
+            access_log off;
+            tcp_nodelay off;
+            open_file_cache max=1000 inactive=20s;
+            open_file_cache_valid 30s;
+            open_file_cache_min_uses 2;
+            open_file_cache_errors on;
+            try_files $uri =404;
+        }
+
+        location @router {
+            rewrite ^.*$ /index.html last;
+        }
+
+        # 错误页面配置
+        error_page 404 /404.html;
+        error_page 500 502 503 504 /50x.html;
+        location = /404.html {
+            internal;
+        }
+        location = /50x.html {
+            internal;
+        }
+    }
+    
+    # ant-design 子域名配置
+    server {
+        listen 80;
+        server_name ant-design.hht.test;
+
+        access_log /var/log/nginx/ant-design.access.log main;
+        error_log /var/log/nginx/ant-design.error.log warn;
+    
+        location / {
+            root /usr/share/nginx/html/ant-design;
+            index index.html index.htm;
+            try_files $uri $uri/ @router;
+
+            # 针对不同类型的文件设置不同的缓存时间
+            location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
+                expires 7d;
+                add_header Cache-Control "public, no-transform";
+            }
+            
+            location ~* \.(html|htm)$ {
+                expires 1h;
+                add_header Cache-Control "public, no-transform";
+            }
 
 
             # 跨域支持
             # 跨域支持
             add_header 'Access-Control-Allow-Origin' $cors_origin always;
             add_header 'Access-Control-Allow-Origin' $cors_origin always;
@@ -107,6 +462,33 @@ http {
             add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
             add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
             add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
             add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
         }
         }
+        location @router {
+            rewrite ^.*$ /index.html last;
+        }
+    }
+
+    # better-scroll 子域名配置
+    server {
+        listen 80;
+        server_name better-scroll-docs.hht.test;
+
+        location / {
+            #root /Users/sysadmin/code/vue_project/better-scroll-docs/zh-CN;
+            #index index.html index.htm;
+
+            alias  /usr/share/nginx/html/better-scroll-docs/zh-CN/;
+            try_files $uri $uri/ /index.html;
+            index  index.html;
+            add_header Access-Control-Allow-Origin *;
+        }
+        
+        location /docs/ {
+            alias  /usr/share/nginx/html/better-scroll-docs/;
+            #try_files $uri $uri/ /tparking/index.html;
+            #index  index.html;
+            #add_header Access-Control-Allow-Origin *;
+        }
+        
     }
     }
 
 
     # 默认服务器配置
     # 默认服务器配置

+ 5 - 0
push.sh

@@ -0,0 +1,5 @@
+#!/bin/sh
+time=$(TZ=UTC-8 date +%Y-%m-%d" "%H:%M:%S)
+git add . &&
+git commit -m "$time" && 
+git push