@dazhicheng/common 1.0.42 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.test CHANGED
@@ -1,16 +1,16 @@
1
- # 【测试】环境变量
2
-
3
- # 应用部署基础路径(如部署在子目录 /admin,则设置为 /admin/)
4
- VITE_BASE_URL = /
5
-
6
- # API 地址前缀
7
- VITE_API_URL = test-api
8
-
9
- # Delete console
10
- VITE_DROP_CONSOLE = true
11
-
12
- # 飞书扫码登录回调地址
13
- VITE_FEISHU_REDIRECT_URI = http://fulfillment-qd.tiantai-jp.com:23006/feishuOAuth
14
-
15
- # webSocket地址
16
- VITE_WEBSOCKET_URL = ws://116.6.49.180:11001
1
+ # 【测试】环境变量
2
+
3
+ # 应用部署基础路径(如部署在子目录 /admin,则设置为 /admin/)
4
+ VITE_BASE_URL = /
5
+
6
+ # API 地址前缀
7
+ VITE_API_URL = test-api
8
+
9
+ # Delete console
10
+ VITE_DROP_CONSOLE = true
11
+
12
+ # 飞书扫码登录回调地址
13
+ VITE_FEISHU_REDIRECT_URI = http://fulfillment-qd.tiantai-jp.com:23006/feishuOAuth
14
+
15
+ # webSocket地址
16
+ VITE_WEBSOCKET_URL = ws://fulfillment-test.tiantai-jp.com:11000
package/.gitignore CHANGED
@@ -1,8 +1,8 @@
1
- node_modules
2
- .DS_Store
3
- dist
4
- dist-ssr
5
- *.local
6
- .cursorrules
7
- .vite
8
- .claude
1
+ node_modules
2
+ .DS_Store
3
+ dist
4
+ dist-ssr
5
+ *.local
6
+ .cursorrules
7
+ .vite
8
+ .claude
package/.husky/commit-msg CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env sh
1
+ #!/usr/bin/env sh
2
2
  pnpm exec commitlint < "$1"
package/.husky/pre-commit CHANGED
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env sh
2
- pnpm run typecheck
3
- pnpm run lint:lint-staged
1
+ #!/usr/bin/env sh
2
+ pnpm run typecheck
3
+ pnpm run lint:lint-staged
package/.prettierrc.txt CHANGED
@@ -1,21 +1,21 @@
1
- {
2
- "printWidth": 100,
3
- "tabWidth": 2,
4
- "useTabs": false,
5
- "semi": true,
6
- "vueIndentScriptAndStyle": true,
7
- "singleQuote": true,
8
- "quoteProps": "as-needed",
9
- "bracketSpacing": true,
10
- "trailingComma": "all",
11
- "bracketSameLine": false,
12
- "jsxSingleQuote": false,
13
- "arrowParens": "always",
14
- "insertPragma": false,
15
- "requirePragma": false,
16
- "proseWrap": "never",
17
- "htmlWhitespaceSensitivity": "strict",
18
- "endOfLine": "auto",
19
- "rangeStart": 0,
20
- <<<自定义>>>
21
- }
1
+ {
2
+ "printWidth": 100,
3
+ "tabWidth": 2,
4
+ "useTabs": false,
5
+ "semi": true,
6
+ "vueIndentScriptAndStyle": true,
7
+ "singleQuote": true,
8
+ "quoteProps": "as-needed",
9
+ "bracketSpacing": true,
10
+ "trailingComma": "all",
11
+ "bracketSameLine": false,
12
+ "jsxSingleQuote": false,
13
+ "arrowParens": "always",
14
+ "insertPragma": false,
15
+ "requirePragma": false,
16
+ "proseWrap": "never",
17
+ "htmlWhitespaceSensitivity": "strict",
18
+ "endOfLine": "auto",
19
+ "rangeStart": 0,
20
+ <<<自定义>>>
21
+ }
package/.stylelintignore CHANGED
@@ -1,8 +1,8 @@
1
- dist
2
- node_modules
3
- public
4
- .husky
5
- .vscode
6
- src/components/Layout/MenuLeft/index.vue
7
- src/assets
1
+ dist
2
+ node_modules
3
+ public
4
+ .husky
5
+ .vscode
6
+ src/components/Layout/MenuLeft/index.vue
7
+ src/assets
8
8
  stats.html
@@ -1,21 +1,21 @@
1
- #!/bin/sh
2
- set -e
3
-
4
- HTML_ROOT=/usr/share/nginx/html
5
- DIST_ROOT=/app/dist
6
- # 保留最近 N 天的历史 hashed 资源,供已打开旧页面继续懒加载
7
- ASSET_RETENTION_DAYS="${ASSET_RETENTION_DAYS:-14}"
8
-
9
- mkdir -p "$HTML_ROOT"
10
-
11
- # 合并拷贝:覆盖同名文件(如 index.html),保留卷中已有、本次构建不含的旧 chunk
12
- if [ -d "$DIST_ROOT" ]; then
13
- cp -a "$DIST_ROOT"/. "$HTML_ROOT"/
14
- fi
15
-
16
- # 清理过期静态资源,避免磁盘无限增长(不影响未过期的旧入口)
17
- if [ -d "$HTML_ROOT/assets" ]; then
18
- find "$HTML_ROOT/assets" -type f -mtime "+${ASSET_RETENTION_DAYS}" -delete 2>/dev/null || true
19
- fi
20
-
21
- exec "$@"
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ HTML_ROOT=/usr/share/nginx/html
5
+ DIST_ROOT=/app/dist
6
+ # 保留最近 N 天的历史 hashed 资源,供已打开旧页面继续懒加载
7
+ ASSET_RETENTION_DAYS="${ASSET_RETENTION_DAYS:-14}"
8
+
9
+ mkdir -p "$HTML_ROOT"
10
+
11
+ # 合并拷贝:覆盖同名文件(如 index.html),保留卷中已有、本次构建不含的旧 chunk
12
+ if [ -d "$DIST_ROOT" ]; then
13
+ cp -a "$DIST_ROOT"/. "$HTML_ROOT"/
14
+ fi
15
+
16
+ # 清理过期静态资源,避免磁盘无限增长(不影响未过期的旧入口)
17
+ if [ -d "$HTML_ROOT/assets" ]; then
18
+ find "$HTML_ROOT/assets" -type f -mtime "+${ASSET_RETENTION_DAYS}" -delete 2>/dev/null || true
19
+ fi
20
+
21
+ exec "$@"
@@ -1,94 +1,94 @@
1
- // 从 URL 和路径模块中导入必要的功能
2
- import fs from 'fs';
3
- import path, { dirname } from 'path';
4
- import { fileURLToPath } from 'url';
5
-
6
- // 从 ESLint 插件中导入推荐配置
7
- import pluginJs from '@eslint/js';
8
- import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
9
- import pluginVue from 'eslint-plugin-vue';
10
- import globals from 'globals';
11
- import tseslint from 'typescript-eslint';
12
-
13
- // 使用 import.meta.url 获取当前模块的路径
14
- const __filename = fileURLToPath(import.meta.url);
15
- const __dirname = dirname(__filename);
16
-
17
- // 读取 .auto-import.json 文件的内容,并将其解析为 JSON 对象
18
- const autoImportConfig = JSON.parse(
19
- fs.readFileSync(path.resolve(__dirname, '.auto-import.json'), 'utf-8'),
20
- );
21
-
22
- export default [
23
- // 指定文件匹配规则
24
- {
25
- files: ['**/*.{js,mjs,cjs,ts,vue}'],
26
- },
27
- // 指定全局变量和环境
28
- {
29
- languageOptions: {
30
- globals: {
31
- ...globals.browser,
32
- ...globals.node,
33
- },
34
- },
35
- },
36
- // 扩展配置
37
- pluginJs.configs.recommended,
38
- ...tseslint.configs.recommended,
39
- ...pluginVue.configs['flat/essential'],
40
- // 自定义规则
41
- {
42
- // 针对所有 JavaScript、TypeScript 和 Vue 文件应用以下配置
43
- files: ['**/*.{js,mjs,cjs,ts,vue}'],
44
-
45
- languageOptions: {
46
- globals: {
47
- // 合并从 autoImportConfig 中读取的全局变量配置
48
- ...autoImportConfig.globals,
49
- // TypeScript 全局命名空间
50
- Api: 'readonly',
51
- Dict: 'readonly',
52
- },
53
- },
54
- rules: {
55
- 'no-undef': 'off', // TypeScript 自身已处理未定义变量检查
56
- quotes: ['error', 'single'], // 使用单引号
57
- semi: ['error', 'never'], // 语句末尾不加分号
58
- 'no-var': 'error', // 要求使用 let 或 const 而不是 var
59
- '@typescript-eslint/no-explicit-any': 'off', // 禁用 any 检查
60
- 'vue/multi-word-component-names': 'off', // 禁用对 Vue 组件名称的多词要求检查
61
- 'no-multiple-empty-lines': ['warn', { max: 1, maxEOF: 1 }], // 不允许多个空行
62
- 'no-unexpected-multiline': 'error', // 禁止空余的多行
63
- 'no-unused-vars': 'off', // 禁用未使用的变量检查
64
- '@typescript-eslint/no-unused-vars': 'off', // 禁用 TypeScript 未使用的变量检查
65
- },
66
- },
67
- // vue 规则
68
- {
69
- files: ['**/*.vue'],
70
- languageOptions: {
71
- parserOptions: {
72
- parser: tseslint.parser,
73
- ecmaFeatures: {
74
- jsx: true,
75
- },
76
- },
77
- },
78
- },
79
- // 忽略文件
80
- {
81
- ignores: [
82
- 'node_modules',
83
- 'dist',
84
- 'public',
85
- '.vscode/**',
86
- 'src/assets/**',
87
- 'src/utils/console.ts',
88
- 'src/api',
89
- 'src/api/**',
90
- ],
91
- },
92
- // prettier 配置
93
- eslintPluginPrettierRecommended,
94
- ];
1
+ // 从 URL 和路径模块中导入必要的功能
2
+ import fs from 'fs';
3
+ import path, { dirname } from 'path';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ // 从 ESLint 插件中导入推荐配置
7
+ import pluginJs from '@eslint/js';
8
+ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
9
+ import pluginVue from 'eslint-plugin-vue';
10
+ import globals from 'globals';
11
+ import tseslint from 'typescript-eslint';
12
+
13
+ // 使用 import.meta.url 获取当前模块的路径
14
+ const __filename = fileURLToPath(import.meta.url);
15
+ const __dirname = dirname(__filename);
16
+
17
+ // 读取 .auto-import.json 文件的内容,并将其解析为 JSON 对象
18
+ const autoImportConfig = JSON.parse(
19
+ fs.readFileSync(path.resolve(__dirname, '.auto-import.json'), 'utf-8'),
20
+ );
21
+
22
+ export default [
23
+ // 指定文件匹配规则
24
+ {
25
+ files: ['**/*.{js,mjs,cjs,ts,vue}'],
26
+ },
27
+ // 指定全局变量和环境
28
+ {
29
+ languageOptions: {
30
+ globals: {
31
+ ...globals.browser,
32
+ ...globals.node,
33
+ },
34
+ },
35
+ },
36
+ // 扩展配置
37
+ pluginJs.configs.recommended,
38
+ ...tseslint.configs.recommended,
39
+ ...pluginVue.configs['flat/essential'],
40
+ // 自定义规则
41
+ {
42
+ // 针对所有 JavaScript、TypeScript 和 Vue 文件应用以下配置
43
+ files: ['**/*.{js,mjs,cjs,ts,vue}'],
44
+
45
+ languageOptions: {
46
+ globals: {
47
+ // 合并从 autoImportConfig 中读取的全局变量配置
48
+ ...autoImportConfig.globals,
49
+ // TypeScript 全局命名空间
50
+ Api: 'readonly',
51
+ Dict: 'readonly',
52
+ },
53
+ },
54
+ rules: {
55
+ 'no-undef': 'off', // TypeScript 自身已处理未定义变量检查
56
+ quotes: ['error', 'single'], // 使用单引号
57
+ semi: ['error', 'never'], // 语句末尾不加分号
58
+ 'no-var': 'error', // 要求使用 let 或 const 而不是 var
59
+ '@typescript-eslint/no-explicit-any': 'off', // 禁用 any 检查
60
+ 'vue/multi-word-component-names': 'off', // 禁用对 Vue 组件名称的多词要求检查
61
+ 'no-multiple-empty-lines': ['warn', { max: 1, maxEOF: 1 }], // 不允许多个空行
62
+ 'no-unexpected-multiline': 'error', // 禁止空余的多行
63
+ 'no-unused-vars': 'off', // 禁用未使用的变量检查
64
+ '@typescript-eslint/no-unused-vars': 'off', // 禁用 TypeScript 未使用的变量检查
65
+ },
66
+ },
67
+ // vue 规则
68
+ {
69
+ files: ['**/*.vue'],
70
+ languageOptions: {
71
+ parserOptions: {
72
+ parser: tseslint.parser,
73
+ ecmaFeatures: {
74
+ jsx: true,
75
+ },
76
+ },
77
+ },
78
+ },
79
+ // 忽略文件
80
+ {
81
+ ignores: [
82
+ 'node_modules',
83
+ 'dist',
84
+ 'public',
85
+ '.vscode/**',
86
+ 'src/assets/**',
87
+ 'src/utils/console.ts',
88
+ 'src/api',
89
+ 'src/api/**',
90
+ ],
91
+ },
92
+ // prettier 配置
93
+ eslintPluginPrettierRecommended,
94
+ ];
package/nginx_dev.conf CHANGED
@@ -1,80 +1,85 @@
1
- # 自定义日志格式:包含实际转发的后端地址
2
- log_format proxy_log
3
- '[$time_local] $status $request | '
4
- 'client=$remote_addr upstream=$upstream_addr | '
5
- 'upstream_status=$upstream_status upstream_time=${upstream_response_time}s | '
6
- 'referer="$http_referer" agent="$http_user_agent"';
7
-
8
- # 根据请求IP分配后端地址(公网IP走公网,默认走内网)
9
- map $host $dev_backend_addr {
10
- # fulfillment-dev.tiantai-jp.com -> 192.168.128.215
11
- default fulfillment-dev.tiantai-jp.com:11000; # 默认走内网
12
- # ly-dev.tiantai-jp.com -> 14.127.204.225
13
- #
14
- 120.76.61.203 ly-dev.tiantai-jp.com:11000; # 公网IP走公网
15
- }
16
-
17
- # HTTP 服务器 - 保持原有配置
18
- server {
19
- <<<listen>>>
20
- server_name localhost;
21
- charset utf-8;
22
-
23
- resolver 8.8.8.8 1.1.1.1 ipv6=off;
24
-
25
- # 使用自定义日志格式,记录后端转发地址
26
- access_log /var/log/nginx/access.log proxy_log;
27
-
28
- root /usr/share/nginx/html;
29
- index index.html;
30
-
31
- # 带 hash 的构建资源:长缓存;缺失时返回 404(禁止回退成 index.html,避免把 HTML 当 JS)
32
- location /assets/ {
33
- try_files $uri =404;
34
- expires 1y;
35
- add_header Cache-Control "public, max-age=31536000, immutable" always;
36
-
37
- # CORS 配置
38
- add_header 'Access-Control-Allow-Origin' '*' always;
39
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
40
- add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
41
- <<<assets_CORS配置>>>
42
- gzip_static on;
43
- }
44
-
45
- # 入口 HTML:禁止缓存,确保新开/刷新拿到最新入口
46
- location = /index.html {
47
- add_header Cache-Control "no-cache, no-store, must-revalidate" always;
48
- add_header Pragma "no-cache" always;
49
- add_header Expires "0" always;
50
-
51
- # CORS 配置
52
- add_header 'Access-Control-Allow-Origin' '*' always;
53
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
54
- add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
55
- <<<index_html_CORS配置>>>
56
- }
57
-
58
- location / {
59
- try_files $uri $uri/ /index.html;
60
- add_header Cache-Control "no-cache" always;
61
- add_header 'Access-Control-Allow-Origin' '*' always;
62
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
63
- add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
64
- <<<index_CORS配置>>>
65
- }
66
-
67
- location /dev-api/ {
68
- proxy_set_header Host $host;
69
- proxy_set_header X-Real-Ip $remote_addr;
70
- proxy_set_header X-Forwarded-For $remote_addr;
71
-
72
- rewrite ^/dev-api/(.*) /$1 break;
73
- proxy_pass http://$dev_backend_addr;
74
- }
75
-
76
- error_page 500 502 503 504 /50x.html;
77
- location = /50x.html {
78
- root html;
79
- }
80
- }
1
+ # 自定义日志格式:包含实际转发的后端地址
2
+ log_format proxy_log
3
+ '[$time_local] $status $request | '
4
+ 'client=$remote_addr upstream=$upstream_addr | '
5
+ 'upstream_status=$upstream_status upstream_time=${upstream_response_time}s | '
6
+ 'referer="$http_referer" agent="$http_user_agent"';
7
+
8
+ # 根据请求IP分配后端地址(公网IP走公网,默认走内网)
9
+ map $host $dev_backend_addr {
10
+ # fulfillment-dev.tiantai-jp.com -> 192.168.128.215
11
+ default fulfillment-dev.tiantai-jp.com:11000; # 默认走内网
12
+ # ly-dev.tiantai-jp.com -> 14.127.204.225
13
+ #
14
+ 120.76.61.203 ly-dev.tiantai-jp.com:11000; # 公网IP走公网
15
+ }
16
+
17
+ # HTTP 服务器 - 保持原有配置
18
+ server {
19
+ <<<listen>>>
20
+ server_name localhost;
21
+ charset utf-8;
22
+
23
+ resolver 8.8.8.8 1.1.1.1 ipv6=off;
24
+
25
+ # 使用自定义日志格式,记录后端转发地址
26
+ access_log /var/log/nginx/access.log proxy_log;
27
+
28
+ root /usr/share/nginx/html;
29
+ index index.html;
30
+
31
+ # 带 hash 的构建资源:长缓存;缺失时返回 404(禁止回退成 index.html,避免把 HTML 当 JS)
32
+ location /assets/ {
33
+ try_files $uri =404;
34
+ expires 1y;
35
+ add_header Cache-Control "public, max-age=31536000, immutable" always;
36
+
37
+ # CORS 配置
38
+ add_header 'Access-Control-Allow-Origin' '*' always;
39
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
40
+ add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
41
+ <<<assets_CORS配置>>>
42
+ gzip_static on;
43
+ }
44
+
45
+ # 入口 HTML:禁止缓存,确保新开/刷新拿到最新入口
46
+ location = /index.html {
47
+ add_header Cache-Control "no-cache, no-store, must-revalidate" always;
48
+ add_header Pragma "no-cache" always;
49
+ add_header Expires "0" always;
50
+
51
+ # CORS 配置
52
+ add_header 'Access-Control-Allow-Origin' '*' always;
53
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
54
+ add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
55
+ <<<index_html_CORS配置>>>
56
+ }
57
+
58
+ location / {
59
+ try_files $uri $uri/ /index.html;
60
+ add_header Cache-Control "no-cache" always;
61
+ add_header 'Access-Control-Allow-Origin' '*' always;
62
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
63
+ add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
64
+ <<<index_CORS配置>>>
65
+ }
66
+
67
+ location /dev-api/ {
68
+ proxy_set_header Host $host;
69
+ proxy_set_header X-Real-Ip $remote_addr;
70
+ proxy_set_header X-Forwarded-For $remote_addr;
71
+
72
+ # 与前端 TtHttp REQUEST_TIMEOUT 对齐:10 分钟
73
+ proxy_connect_timeout 600s;
74
+ proxy_send_timeout 600s;
75
+ proxy_read_timeout 600s;
76
+
77
+ rewrite ^/dev-api/(.*) /$1 break;
78
+ proxy_pass http://$dev_backend_addr;
79
+ }
80
+
81
+ error_page 500 502 503 504 /50x.html;
82
+ location = /50x.html {
83
+ root html;
84
+ }
85
+ }
package/nginx_test.conf CHANGED
@@ -1,82 +1,87 @@
1
- # 自定义日志格式:包含实际转发的后端地址
2
- log_format proxy_log
3
- '[$time_local] $status $request | '
4
- 'client=$remote_addr upstream=$upstream_addr | '
5
- 'upstream_status=$upstream_status upstream_time=${upstream_response_time}s | '
6
- 'referer="$http_referer" agent="$http_user_agent"';
7
-
8
- # 根据请求IP分配后端地址(公网IP走公网,默认走内网)
9
- map $host $test_backend_addr {
10
- # fulfillment-test.tiantai-jp.com -> 192.168.127.73
11
- default fulfillment-test.tiantai-jp.com:11000; # 默认走内网
12
- # ly-test.tiantai-jp.com -> 116.6.49.180
13
- 120.76.61.203 ly-test.tiantai-jp.com:11000; # 公网IP走公网
14
- }
15
-
16
- # HTTP 服务器 - 保持原有配置
17
- server {
18
- <<<listen>>>
19
- server_name localhost;
20
- charset utf-8;
21
-
22
- resolver 8.8.8.8 1.1.1.1 ipv6=off;
23
-
24
- # 使用自定义日志格式,记录后端转发地址
25
- access_log /var/log/nginx/access.log proxy_log;
26
-
27
- root /usr/share/nginx/html;
28
- index index.html;
29
-
30
- # 带 hash 的构建资源:长缓存;缺失时返回 404(禁止回退成 index.html,避免把 HTML 当 JS)
31
- location /assets/ {
32
- try_files $uri =404;
33
- expires 1y;
34
- add_header Cache-Control "public, max-age=31536000, immutable" always;
35
-
36
- # CORS 配置
37
- add_header 'Access-Control-Allow-Origin' '*' always;
38
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
39
- add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
40
- <<<assets_CORS配置>>>
41
- gzip_static on;
42
- }
43
-
44
- # 入口 HTML:禁止缓存,确保新开/刷新拿到最新入口
45
- location = /index.html {
46
- add_header Cache-Control "no-cache, no-store, must-revalidate" always;
47
- add_header Pragma "no-cache" always;
48
- add_header Expires "0" always;
49
-
50
- # CORS 配置
51
- add_header 'Access-Control-Allow-Origin' '*' always;
52
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
53
- add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
54
- <<<index_html_CORS配置>>>
55
- }
56
-
57
- location / {
58
- try_files $uri $uri/ /index.html;
59
- add_header Cache-Control "no-cache" always;
60
-
61
- # CORS 配置
62
- add_header 'Access-Control-Allow-Origin' '*' always;
63
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
64
- add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
65
- <<<index_CORS配置>>>
66
- }
67
-
68
- location /test-api/ {
69
- proxy_set_header Host $host;
70
- proxy_set_header X-Real-Ip $remote_addr;
71
- proxy_set_header X-Forwarded-For $remote_addr;
72
-
73
- rewrite ^/test-api/(.*) /$1 break;
74
- proxy_pass http://$test_backend_addr;
75
- }
76
- <<<其他location配置>>>
77
-
78
- error_page 500 502 503 504 /50x.html;
79
- location = /50x.html {
80
- root html;
81
- }
82
- }
1
+ # 自定义日志格式:包含实际转发的后端地址
2
+ log_format proxy_log
3
+ '[$time_local] $status $request | '
4
+ 'client=$remote_addr upstream=$upstream_addr | '
5
+ 'upstream_status=$upstream_status upstream_time=${upstream_response_time}s | '
6
+ 'referer="$http_referer" agent="$http_user_agent"';
7
+
8
+ # 根据请求IP分配后端地址(公网IP走公网,默认走内网)
9
+ map $host $test_backend_addr {
10
+ # fulfillment-test.tiantai-jp.com -> 192.168.127.73
11
+ default fulfillment-test.tiantai-jp.com:11000; # 默认走内网
12
+ # ly-test.tiantai-jp.com -> 116.6.49.180
13
+ 120.76.61.203 ly-test.tiantai-jp.com:11000; # 公网IP走公网
14
+ }
15
+
16
+ # HTTP 服务器 - 保持原有配置
17
+ server {
18
+ <<<listen>>>
19
+ server_name localhost;
20
+ charset utf-8;
21
+
22
+ resolver 8.8.8.8 1.1.1.1 ipv6=off;
23
+
24
+ # 使用自定义日志格式,记录后端转发地址
25
+ access_log /var/log/nginx/access.log proxy_log;
26
+
27
+ root /usr/share/nginx/html;
28
+ index index.html;
29
+
30
+ # 带 hash 的构建资源:长缓存;缺失时返回 404(禁止回退成 index.html,避免把 HTML 当 JS)
31
+ location /assets/ {
32
+ try_files $uri =404;
33
+ expires 1y;
34
+ add_header Cache-Control "public, max-age=31536000, immutable" always;
35
+
36
+ # CORS 配置
37
+ add_header 'Access-Control-Allow-Origin' '*' always;
38
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
39
+ add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
40
+ <<<assets_CORS配置>>>
41
+ gzip_static on;
42
+ }
43
+
44
+ # 入口 HTML:禁止缓存,确保新开/刷新拿到最新入口
45
+ location = /index.html {
46
+ add_header Cache-Control "no-cache, no-store, must-revalidate" always;
47
+ add_header Pragma "no-cache" always;
48
+ add_header Expires "0" always;
49
+
50
+ # CORS 配置
51
+ add_header 'Access-Control-Allow-Origin' '*' always;
52
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
53
+ add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
54
+ <<<index_html_CORS配置>>>
55
+ }
56
+
57
+ location / {
58
+ try_files $uri $uri/ /index.html;
59
+ add_header Cache-Control "no-cache" always;
60
+
61
+ # CORS 配置
62
+ add_header 'Access-Control-Allow-Origin' '*' always;
63
+ add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
64
+ add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
65
+ <<<index_CORS配置>>>
66
+ }
67
+
68
+ location /test-api/ {
69
+ proxy_set_header Host $host;
70
+ proxy_set_header X-Real-Ip $remote_addr;
71
+ proxy_set_header X-Forwarded-For $remote_addr;
72
+
73
+ # 与前端 TtHttp REQUEST_TIMEOUT 对齐:10 分钟
74
+ proxy_connect_timeout 600s;
75
+ proxy_send_timeout 600s;
76
+ proxy_read_timeout 600s;
77
+
78
+ rewrite ^/test-api/(.*) /$1 break;
79
+ proxy_pass http://$test_backend_addr;
80
+ }
81
+ <<<其他location配置>>>
82
+
83
+ error_page 500 502 503 504 /50x.html;
84
+ location = /50x.html {
85
+ root html;
86
+ }
87
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazhicheng/common",
3
- "version": "1.0.42",
3
+ "version": "1.0.45",
4
4
  "description": "共享配置文件",
5
5
  "type": "module",
6
6
  "types": "./src/types/index.d.ts",
@@ -1,9 +1,9 @@
1
- minimumReleaseAge: 0
2
-
3
- allowBuilds:
4
- '@parcel/watcher': true
5
- core-js: true
6
- es5-ext: true
7
- esbuild: true
8
- vue-demi: true
9
- '@tailwindcss/oxide': true
1
+ minimumReleaseAge: 0
2
+
3
+ allowBuilds:
4
+ '@parcel/watcher': true
5
+ core-js: true
6
+ es5-ext: true
7
+ esbuild: true
8
+ vue-demi: true
9
+ '@tailwindcss/oxide': true
@@ -1 +0,0 @@
1
- export {};