mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 04:52:50 +08:00
fix: safe router.back() — fallback to home if no history (prevents navigating to external site)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
eb0088d110
commit
7d329a0db1
2 files changed
+17
-2
No files matched your search
@@ -89,7 +89,12 @@ const currentSong = computed(() => store.currentSong);
|
||||
|
||||
function toggleLyrics() {
|
||||
if (route.path === '/lyrics') {
|
||||
router.back();
|
||||
// Go back if there's history, otherwise go home
|
||||
if (window.history.length > 1) {
|
||||
router.back();
|
||||
} else {
|
||||
router.push('/');
|
||||
}
|
||||
} else {
|
||||
router.push('/lyrics');
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="lyrics-page" :style="bgStyle">
|
||||
<div class="lyrics-overlay" />
|
||||
<button class="back-btn" @click="$router.back()">
|
||||
<button class="back-btn" @click="goBack">
|
||||
<Icon icon="mdi:arrow-left" />
|
||||
返回
|
||||
</button>
|
||||
@@ -46,14 +46,24 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { Icon } from '@iconify/vue';
|
||||
import axios from 'axios';
|
||||
import { usePlayerStore } from '../stores/player.js';
|
||||
import CoverArt from '../components/CoverArt.vue';
|
||||
|
||||
const router = useRouter();
|
||||
const store = usePlayerStore();
|
||||
const currentSong = computed(() => store.currentSong);
|
||||
|
||||
function goBack() {
|
||||
if (window.history.length > 1) {
|
||||
router.back();
|
||||
} else {
|
||||
router.push('/');
|
||||
}
|
||||
}
|
||||
|
||||
interface LyricLine {
|
||||
time: number;
|
||||
text: string;
|
||||
|
||||
Reference in new issue
Block a user