Skip to content

Commit 569e81f

Browse files
committed
fix:短链复制问题
1 parent 6df4f0e commit 569e81f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

web/src/composables/useCopy.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
export function copyToClipboard(text) {
66
return new Promise((resolve, reject) => {
77
// 方法1: 现代浏览器的 Clipboard API (需要 HTTPS)
8-
if (navigator.clipboard && navigator.clipboard.writeText) {
8+
// 使用可选链操作符避免访问未定义的 navigator.clipboard
9+
if (navigator?.clipboard?.writeText) {
910
navigator.clipboard.writeText(text)
1011
.then(() => resolve())
1112
.catch(() => {

web/src/router/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ const routes = [
1414
{ path: '/stats/:shortCode', component: StatsPage },
1515
{ path: '/about', component: AboutPage, meta: { public: true } },
1616
// 短链跳转路由(匹配 4-8 位字母数字组合)
17-
{
18-
path: '/:shortCode(\\w{4,8})',
19-
component: RedirectPage,
20-
meta: { public: true, hideNav: true }
21-
},
17+
// 注意:短链跳转应直接访问后端API,而不是前端路由
18+
// 此路由仅作为备用,正常情况下应该由 Nginx 直接转发到后端
19+
// {
20+
// path: '/:shortCode(\\w{4,8})',
21+
// component: RedirectPage,
22+
// meta: { public: true, hideNav: true }
23+
// },
2224
]
2325

2426
const router = createRouter({

0 commit comments

Comments
 (0)