Skip to content

Commit e5b4f3e

Browse files
committed
fix:图渲染异常
1 parent 82dc35e commit e5b4f3e

File tree

4 files changed

+42
-20
lines changed

4 files changed

+42
-20
lines changed

deploy.sh

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,17 @@ server {
376376
access_log /var/log/nginx/tinyflow_access.log;
377377
error_log /var/log/nginx/tinyflow_error.log;
378378
379-
# 前端路由
380-
location / {
381-
try_files \$uri \$uri/ /index.html;
379+
# 重要:短链接跳转(必须放在前端路由之前,使用正则匹配)
380+
location ~ ^/[a-zA-Z0-9]{4,8}\$ {
381+
proxy_pass http://localhost:8080;
382+
proxy_set_header Host \$host;
383+
proxy_set_header X-Real-IP \$remote_addr;
384+
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
385+
proxy_set_header X-Forwarded-Proto \$scheme;
382386
}
383387
384-
# 后端 API 代理
385-
location /api {
388+
# 后端 API 代理(使用 ^~ 提高优先级)
389+
location ^~ /api {
386390
proxy_pass http://localhost:8080;
387391
proxy_set_header Host \$host;
388392
proxy_set_header X-Real-IP \$remote_addr;
@@ -394,20 +398,24 @@ server {
394398
proxy_read_timeout 60s;
395399
}
396400
397-
# 短链接跳转
398-
location ~ ^/[a-zA-Z0-9]{4,8}\$ {
399-
proxy_pass http://localhost:8080;
400-
proxy_set_header Host \$host;
401-
proxy_set_header X-Real-IP \$remote_addr;
402-
}
403-
404-
# 健康检查
405-
location /actuator {
401+
# 健康检查(使用 ^~ 提高优先级)
402+
location ^~ /actuator {
406403
proxy_pass http://localhost:8080;
407404
allow 127.0.0.1;
408405
deny all;
409406
}
410407
408+
# 静态资源缓存
409+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)\$ {
410+
expires 1y;
411+
add_header Cache-Control "public, immutable";
412+
}
413+
414+
# 前端路由(放在最后)
415+
location / {
416+
try_files \$uri \$uri/ /index.html;
417+
}
418+
411419
# Gzip 压缩
412420
gzip on;
413421
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ services:
5555
- SPRING_RABBITMQ_USERNAME=guest
5656
- SPRING_RABBITMQ_PASSWORD=guest
5757
- SERVER_PORT=8080
58+
- APP_DOMAIN=http://localhost:8080
5859
ports:
5960
- "8080:8080"
6061
restart: unless-stopped

web/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html lang="zh-CN">
33
<head>
44
<meta charset="UTF-8" />
5-
<link rel="icon" type="image/png" href="/logo.png" />
5+
<link rel="icon" type="image/svg+xml" href="/logo.png" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>TinyFlow</title>
7+
<title>TinyFlow - 短链接服务</title>
88
</head>
99
<body>
1010
<div id="app"></div>

web/src/pages/DashboardPage.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@
129129
<td>
130130
<div class="flex gap-2">
131131
<router-link :to="'/stats/' + url.shortCode" class="action-link">详情</router-link>
132-
<button @click="copyUrl(url.shortCode)" class="action-link">复制</button>
132+
<button @click="copyUrl(url.shortCode)" class="action-link">
133+
{{ copyingCode === url.shortCode ? '已复制' : '复制' }}
134+
</button>
133135
</div>
134136
</td>
135137
</tr>
@@ -182,7 +184,9 @@
182184
<td>
183185
<div class="flex gap-2">
184186
<router-link :to="'/stats/' + url.shortCode" class="action-link">详情</router-link>
185-
<button @click="copyUrl(url.shortCode)" class="action-link">复制</button>
187+
<button @click="copyUrl(url.shortCode)" class="action-link">
188+
{{ copyingCode === url.shortCode ? '已复制' : '复制' }}
189+
</button>
186190
<button @click="deleteUrl(url.shortCode)" class="action-link text-red-500">删除</button>
187191
</div>
188192
</td>
@@ -282,13 +286,22 @@ function getSharePercent(url) {
282286
return totalClicks.value > 0 ? (Number(url.totalVisits || 0) / totalClicks.value * 100) : 0
283287
}
284288
289+
// 复制状态
290+
const copyingCode = ref(null)
291+
285292
async function copyUrl(shortCode) {
286293
const url = `${SHORT_BASE}/${shortCode}`
287294
try {
295+
copyingCode.value = shortCode
288296
await copyToClipboard(url)
289-
// 可以添加提示,但需要状态管理
297+
// 显示复制成功提示
298+
setTimeout(() => {
299+
copyingCode.value = null
300+
}, 2000)
290301
} catch (e) {
291302
console.error('复制失败:', e)
303+
alert('复制失败,请手动复制')
304+
copyingCode.value = null
292305
}
293306
}
294307

0 commit comments

Comments
 (0)