Commit 17c31fdb by zhangxingmin

push

parent fcb1a7b3
import App from './App.vue';
import { createApp } from 'vue'
// 创建 Vue 3 应用实例
const app = createApp(App)
// 挂载应用到 DOM
app.mount('#app')
// 添加挂载前检查
const rootElement = document.getElementById('app')
if (!rootElement) {
console.error('⚠️ 未找到挂载元素 #app')
// 创建备用挂载点
const fallbackApp = document.createElement('div')
fallbackApp.id = 'app'
document.body.appendChild(fallbackApp)
app.mount('#app')
} else {
console.log('✅ 找到挂载元素 #app')
app.mount('#app')
}
// 添加应用加载完成事件
window.addEventListener('DOMContentLoaded', () => {
console.log('🚀 DOM内容加载完成')
if (document.getElementById('app').childElementCount === 0) {
console.warn('⚠️ 应用挂载点为空,可能未正确渲染')
// 显示错误信息
const errorDiv = document.createElement('div')
errorDiv.style = "padding:20px;color:red;font-size:20px;text-align:center;"
errorDiv.innerHTML = `
<h1>应用初始化失败</h1>
<p>请检查控制台错误信息</p>
<p>当前路径: ${window.location.href}</p>
<p>Base路径: /cffp/</p>
`
document.getElementById('app').appendChild(errorDiv)
}
})
// H5 环境特定代码
// H5环境特定代码
if (typeof window !== 'undefined') {
window.sessionStorage.setItem('firstEntryUrl', window.location.href.split('#')[0])
const firstEntryUrl = window.location.href.split('#')[0]
window.sessionStorage.setItem('firstEntryUrl', firstEntryUrl)
console.log('🌐 记录首次访问URL:', firstEntryUrl)
}
......@@ -5,29 +5,42 @@ server {
root /usr/share/nginx/html;
index index.html;
# 禁用缓存确保获取最新资源
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate";
add_header Pragma "no-cache";
expires 0;
# Vue路由模式支持
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-store, no-cache, must-revalidate"; # 禁用缓存
}
# 匹配manifest.json中的base路径
location /cffp/ {
alias /usr/share/nginx/html/;
try_files $uri $uri/ /cffp/index.html;
}
# 禁止访问 .env 文件
location ~ /\.env {
deny all;
return 404;
# 代理API请求
location /cffpApi {
proxy_pass http://cffpApi;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# 错误处理
# 错误日志
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# 错误页面
error_page 404 /404.html;
location = /404.html {
internal;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
internal;
}
# 访问日志
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment