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
235d9bcd
Commit
235d9bcd
authored
Jul 24, 2025
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
6976404d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
6 deletions
+36
-6
nginx.conf
+2
-2
vite.config.js
+34
-4
No files found.
nginx.conf
View file @
235d9bcd
...
...
@@ -11,9 +11,9 @@ server {
add_header
Cache-Control
"no-store,
no-cache,
must-revalidate"
;
}
# 子应用 /cffp/ 路由
# 子应用 /cffp/ 路由
(关键修正)
location
/cffp/
{
try_files
$uri
$uri
/
/
cffp/index.html
;
# 移除 alias,直接使用 root
try_files
$uri
$uri
/
/
index.html
;
# 改为指向根目录的 index.html
}
# 禁止访问 .env 文件
...
...
vite.config.js
View file @
235d9bcd
// vite.config.js
import
{
defineConfig
}
from
'vite'
import
{
createVuePlugin
}
from
'vite-plugin-vue2'
import
path
from
'path'
export
default
defineConfig
({
// 关键修改:设置 base 路径,与 Nginx 配置匹配
base
:
'/cffp/'
,
plugins
:
[
createVuePlugin
()],
resolve
:
{
extensions
:
[
'.vue'
,
'.js'
,
'.ts'
,
'.json'
],
// 添加 .ts 支持
extensions
:
[
'.vue'
,
'.js'
,
'.ts'
,
'.json'
],
alias
:
{
'@'
:
path
.
resolve
(
__dirname
),
// 指向项目根目录
'@api'
:
path
.
resolve
(
__dirname
,
'api'
)
// 直接指向 api 目录
'@'
:
path
.
resolve
(
__dirname
),
'@api'
:
path
.
resolve
(
__dirname
,
'api'
)
}
},
// 开发服务器配置(可选)
server
:
{
port
:
8080
,
proxy
:
{
// 代理后端 API 请求,避免跨域问题
'/cffpApi'
:
{
target
:
'http://localhost:8080'
,
changeOrigin
:
true
,
rewrite
:
(
path
)
=>
path
.
replace
(
/^
\/
cffpApi/
,
''
)
}
}
},
// 生产环境构建配置
build
:
{
outDir
:
'dist'
,
// 输出目录
assetsDir
:
'assets'
,
// 静态资源目录
rollupOptions
:
{
output
:
{
// 确保生成的资源路径正确
assetFileNames
:
'assets/[name].[hash].[ext]'
,
chunkFileNames
:
'assets/[name].[hash].js'
,
entryFileNames
:
'assets/[name].[hash].js'
}
}
}
})
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