Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CFFP-HB
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chao Sun
CFFP-HB
Commits
17c31fdb
Commit
17c31fdb
authored
Jul 24, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
fcb1a7b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
19 deletions
+62
-19
main.js
+35
-5
nginx.conf
+27
-14
No files found.
main.js
View file @
17c31fdb
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
)
}
nginx.conf
View file @
17c31fdb
...
...
@@ -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/htm
l
;
interna
l
;
}
# 访问日志
access_log
/var/log/nginx/access.log
;
error_log
/var/log/nginx/error.log
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment