feat: 登录状态校验功能修改

This commit is contained in:
alger
2025-09-14 00:34:35 +08:00
parent 8f9c989815
commit 8f0728d9db
5 changed files with 61 additions and 11 deletions
@@ -117,6 +117,7 @@ import { createPlaylist, updatePlaylistTracks } from '@/api/music';
import { getUserPlaylist } from '@/api/user';
import { useUserStore } from '@/store';
import { getImgUrl } from '@/utils';
import { hasPermission, getLoginErrorMessage } from '@/utils/auth';
const store = useUserStore();
const { t } = useI18n();
@@ -160,6 +161,13 @@ const fetchUserPlaylists = async () => {
return;
}
// 检查是否有真实登录权限
if (!hasPermission(true)) {
message.error(getLoginErrorMessage(true));
emit('update:modelValue', false);
return;
}
const res = await getUserPlaylist(user.userId, 999);
if (res.data?.playlist) {
playlists.value = res.data.playlist.filter((item: any) => item.userId === user.userId);
@@ -173,6 +181,13 @@ const fetchUserPlaylists = async () => {
// 添加到歌单
const handleAddToPlaylist = async (playlist: any) => {
if (!props.songId) return;
// 检查是否有真实登录权限
if (!hasPermission(true)) {
message.error(getLoginErrorMessage(true));
return;
}
try {
const res = await updatePlaylistTracks({
op: 'add',
@@ -200,6 +215,12 @@ const handleCreatePlaylist = async () => {
return;
}
// 检查是否有真实登录权限
if (!hasPermission(true)) {
message.error(getLoginErrorMessage(true));
return;
}
try {
creating.value = true;