Skip to content

Commit 82dc35e

Browse files
committed
fix:跳转异常
1 parent 569e81f commit 82dc35e

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

web/src/pages/DashboardPage.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@
118118
<tbody>
119119
<tr v-for="(url, idx) in topUrls" :key="url.shortCode">
120120
<td><span class="rank-badge">{{ idx + 1 }}</span></td>
121-
<td><code class="code-badge">{{ url.shortCode }}</code></td>
121+
<td>
122+
<a :href="`${SHORT_BASE}/${url.shortCode}`" target="_blank" class="code-badge hover:underline" style="color: #3b82f6; text-decoration: none;">
123+
{{ url.shortCode }}
124+
</a>
125+
</td>
122126
<td class="truncate max-w-[300px]">{{ url.longUrl }}</td>
123127
<td class="font-semibold text-blue-600">{{ url.totalClicks }}</td>
124128
<td>{{ url.todayClicks }}</td>
@@ -160,7 +164,11 @@
160164
</thead>
161165
<tbody>
162166
<tr v-for="url in filteredList" :key="url.shortCode">
163-
<td><code class="code-badge">{{ url.shortCode }}</code></td>
167+
<td>
168+
<a :href="`${SHORT_BASE}/${url.shortCode}`" target="_blank" class="code-badge hover:underline" style="color: #3b82f6; text-decoration: none;">
169+
{{ url.shortCode }}
170+
</a>
171+
</td>
164172
<td class="truncate max-w-[300px]">{{ url.longUrl }}</td>
165173
<td class="font-semibold text-blue-600">{{ url.totalVisits ?? '-' }}</td>
166174
<td>{{ url.todayVisits === 0 ? '-' : url.todayVisits }}</td>

web/src/pages/HomePage.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
<div class="flex flex-col md:flex-row items-start md:items-center gap-6">
4747
<div class="min-w-0 flex-1 text-left">
4848
<div class="text-sm mb-2" style="color:var(--tf-text-muted)">{{ $t('result.created') }}</div>
49-
<button @click="redirectViaApi({ shortUrl })" class="underline break-all text-[16px] font-medium" style="color:var(--tf-brand-primary);background:none;border:none;padding:0;cursor:pointer">
49+
<a :href="shortUrl" target="_blank" class="underline break-all text-[16px] font-medium hover:opacity-80" style="color:var(--tf-brand-primary);text-decoration:underline;cursor:pointer;display:inline-block">
5050
{{ decodeUrlText(shortUrl) }}
51-
</button>
51+
</a>
5252
<div class="mt-4 flex gap-3">
5353
<button @click="copyShortUrl" class="fs-btn-secondary px-4 py-2">
5454
{{ $t('result.copy') }}
@@ -94,7 +94,7 @@
9494
<Favicon :long-url="normalizeUrl(resolveLongUrl(item)) || (location.origin + (item.shortUrl || ''))" />
9595
<div class="min-w-0">
9696
<div class="flex items-center gap-2 min-w-0">
97-
<button @click="redirectViaApi(item)" class="truncate text-[14px] font-medium hover:underline" style="color:var(--tf-brand-primary);max-width:52vw;background:none;border:none;padding:0;cursor:pointer">{{ displayShortUrlText(item) }}</button>
97+
<a :href="displayShortUrl(item)" target="_blank" class="truncate text-[14px] font-medium hover:underline hover:opacity-80" style="color:var(--tf-brand-primary);max-width:52vw;text-decoration:none">{{ displayShortUrlText(item) }}</a>
9898
<span class="px-2 py-0.5 text-[12px] rounded" style="background:var(--tf-brand-lighter);color:var(--tf-brand-primary)">{{ extractCode(item) }}</span>
9999
</div>
100100
<div class="mt-1 truncate text-[13px]" style="color:var(--tf-text-muted);max-width:60vw">{{ item.longUrl }}</div>
@@ -164,6 +164,7 @@ import LoadingSpinner from '../components/LoadingSpinner.vue'
164164
import QrcodeVue from 'qrcode.vue'
165165
import Favicon from '../components/Favicon.vue'
166166
import { SHORT_BASE } from '/src/composables/shortBase'
167+
import { copyToClipboard } from '../composables/useCopy'
167168
168169
const api = axios
169170
@@ -292,12 +293,13 @@ export default {
292293
async copyShortUrl() {
293294
if (!this.shortUrl) return
294295
try {
295-
await navigator.clipboard.writeText(this.shortUrl)
296+
await copyToClipboard(this.shortUrl)
296297
this.copyLabel = '已复制'
297298
clearTimeout(this.copyTimer)
298299
this.copyTimer = setTimeout(() => { this.copyLabel = '复制链接' }, 2000)
299300
} catch (e) {
300301
console.error('复制失败:', e)
302+
alert('复制失败,请手动复制')
301303
}
302304
},
303305
confirmClearAll() {
@@ -374,12 +376,13 @@ export default {
374376
},
375377
async copyLink(url, id) {
376378
try {
377-
await navigator.clipboard.writeText(url)
379+
await copyToClipboard(url)
378380
this.copiedId = id
379381
clearTimeout(this.copyItemTimer)
380382
this.copyItemTimer = setTimeout(() => { this.copiedId = null }, 2000)
381383
} catch (e) {
382384
console.error('复制失败:', e)
385+
alert('复制失败,请手动复制')
383386
}
384387
},
385388
async refreshHistory() {

0 commit comments

Comments
 (0)