Skip to content

Commit ead7cfc

Browse files
committed
修复前端硬编码localhost:8080,改用SHORT_BASE
1 parent 2b13cc9 commit ead7cfc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

web/App.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ import { SHORT_BASE } from '/src/composables/shortBase'
226226
227227
const API_BASE = (typeof window !== 'undefined' && window.location && window.location.origin)
228228
? window.location.origin
229-
: 'http://localhost:8080' // 用于顶部历史记录跳转链接
229+
SHORT_BASE // 用于顶部"历史记录"跳转链接
230230
// 使用全局 axios 实例(已在 useAuth 中配置拦截器)
231231
const api = axios
232232
@@ -390,7 +390,7 @@ export default {
390390
}
391391
392392
const code = this.extractCode({ shortUrl: shortRaw })
393-
// 统一展示域名为 http://localhost:8080(外部短链形式)
393+
// 统一展示域名为生产环境地址(外部短链形式)
394394
this.shortUrl = this.buildDisplayShortUrl(code)
395395
this.longUrl = url
396396
// 本地插入至历史顶部,无需整页刷新
@@ -523,17 +523,17 @@ export default {
523523
buildShortUrl(code) {
524524
if (!code) return ''
525525
try {
526-
return new URL('/api/redirect/' + encodeURIComponent(String(code)), 'http://localhost:8080').href
526+
return new URL('/api/redirect/' + encodeURIComponent(String(code)), SHORT_BASE).href
527527
} catch {
528-
return 'http://localhost:8080/api/redirect/' + encodeURIComponent(String(code))
528+
return SHORT_BASE + '/api/redirect/' + encodeURIComponent(String(code))
529529
}
530530
},
531531
buildDisplayShortUrl(code) {
532532
if (!code) return ''
533533
try {
534-
return new URL('/' + encodeURIComponent(String(code)), 'http://localhost:8080').href
534+
return new URL('/' + encodeURIComponent(String(code)), SHORT_BASE).href
535535
} catch {
536-
return 'http://localhost:8080/' + encodeURIComponent(String(code))
536+
return SHORT_BASE + '/' + encodeURIComponent(String(code))
537537
}
538538
},
539539
displayShortUrl(item) {

0 commit comments

Comments
 (0)