脚本调整,处理下载页面html的apiurl问题,开发环境暂时未处理
This commit is contained in:
@@ -39,5 +39,14 @@ sed -i '/<head[ >]/a <script src="\/config.js" defer><\/script>' /var/www/html/i
|
||||
# 匹配 src="/_app.config.js" 开头,允许后面有 ?v=任意字符
|
||||
sed -i 's|<script[^>]*src="/_app.config.js[^"]*"[^>]*></script>|<!-- 屏蔽构建时配置:<script src="/_app.config.js" /> -->|g' /var/www/html/index.html
|
||||
|
||||
## 在下载页面的静态文件中注入JS
|
||||
# 1. 创建运行时配置文件
|
||||
cat > /var/www/html/static/apps/configApp.js << EOF
|
||||
// 动态注入运行时配置
|
||||
window['downUrl'] = "${VITE_GLOB_API_URL:-http://default-api.com}";
|
||||
EOF
|
||||
|
||||
sed -i '/<head[ >]/a <script src="configApp.js" defer><\/script>' /var/www/html/static/apps/experEnd.html
|
||||
sed -i '/<head[ >]/a <script src="configApp.js" defer><\/script>' /var/www/html/static/apps/index.html
|
||||
# 启动 Nginx
|
||||
exec nginx -g "daemon off;"
|
||||
|
||||
Reference in New Issue
Block a user