脚本调整,处理下载页面html的apiurl问题,开发环境暂时未处理

This commit is contained in:
2025-11-05 17:46:03 +08:00
parent 6125c6fc87
commit 66a0c2f4d6
4 changed files with 15 additions and 6 deletions
+9
View File
@@ -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;"
+2 -2
View File
@@ -87,7 +87,7 @@
}
function androidLoad() {
// window.open('https://a.app.qq.com/o/simple.jsp?pkgname=com.sw.healthyclients');
fetch(`https://api-jkglpt.iosp.ydpt.tech/health-system/version/getSysVersionDetailByPackageName?androidOrIos=1&packageName=com.xjjk.healthexpertclient`)
fetch(window['downUrl']+`/health-system/version/getSysVersionDetailByPackageName?androidOrIos=1&packageName=com.xjjk.healthexpertclient`)
.then(response => {
if (!response.ok) {
throw new Error('网络响应不正常');
@@ -96,7 +96,7 @@
})
.then(data => {
if (data.code === 200) {
window.open(`https://api-jkglpt.iosp.ydpt.tech/file/down/${data.result.appUrl}`)
window.open(window['downUrl']+`/file/down/${data.result.appUrl}`)
} else {
window.alert('网络异常');
}
+2 -2
View File
@@ -89,7 +89,7 @@
}
}
function androidLoad() {
window.open('https://api.cqygjk.com/health-system/api/anon/sys/toAppDown?pkg=com.sw.healthexpertclient&type=1');
window.open(window['downUrl']+'/health-system/api/anon/sys/toAppDown?pkg=com.sw.healthexpertclient&type=1');
}
function iosLoad() {
// 响应App store
@@ -104,4 +104,4 @@
androidLoad();
}
}
</script>
</script>
+2 -2
View File
@@ -85,7 +85,7 @@
}
}
function androidLoad() {
fetch(`https://api-jkglpt.iosp.ydpt.tech/health-system/version/getSysVersionDetailByPackageName?androidOrIos=1&packageName=com.xjjk.healthyclients`)
fetch(window['downUrl']+`/health-system/version/getSysVersionDetailByPackageName?androidOrIos=1&packageName=com.xjjk.healthyclients`)
.then(response => {
if (!response.ok) {
throw new Error('网络响应不正常');
@@ -94,7 +94,7 @@
})
.then(data => {
if (data.code === 200) {
window.open(`https://api-jkglpt.iosp.ydpt.tech/file/down/${data.result.appUrl}`)
window.open(window['downUrl']+`/file/down/${data.result.appUrl}`)
} else {
window.alert('网络异常');
}