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
+16
-1
No files matched your search
@@ -89,7 +89,12 @@ const currentSong = computed(() => store.currentSong);
|
|||||||
|
|
||||||
function toggleLyrics() {
|
function toggleLyrics() {
|
||||||
if (route.path === '/lyrics') {
|
if (route.path === '/lyrics') {
|
||||||
|
// Go back if there's history, otherwise go home
|
||||||
|
if (window.history.length > 1) {
|
||||||
router.back();
|
router.back();
|
||||||
|
} else {
|
||||||
|
router.push('/');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
router.push('/lyrics');
|
router.push('/lyrics');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="lyrics-page" :style="bgStyle">
|
<div class="lyrics-page" :style="bgStyle">
|
||||||
<div class="lyrics-overlay" />
|
<div class="lyrics-overlay" />
|
||||||
<button class="back-btn" @click="$router.back()">
|
<button class="back-btn" @click="goBack">
|
||||||
<Icon icon="mdi:arrow-left" />
|
<Icon icon="mdi:arrow-left" />
|
||||||
返回
|
返回
|
||||||
</button>
|
</button>
|
||||||
@@ -46,14 +46,24 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
|
import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
import { Icon } from '@iconify/vue';
|
import { Icon } from '@iconify/vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { usePlayerStore } from '../stores/player.js';
|
import { usePlayerStore } from '../stores/player.js';
|
||||||
import CoverArt from '../components/CoverArt.vue';
|
import CoverArt from '../components/CoverArt.vue';
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
const store = usePlayerStore();
|
const store = usePlayerStore();
|
||||||
const currentSong = computed(() => store.currentSong);
|
const currentSong = computed(() => store.currentSong);
|
||||||
|
|
||||||
|
function goBack() {
|
||||||
|
if (window.history.length > 1) {
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
router.push('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface LyricLine {
|
interface LyricLine {
|
||||||
time: number;
|
time: number;
|
||||||
text: string;
|
text: string;
|
||||||
|
|||||||
Reference in new issue
Block a user