From 4d831777f19118104f696557d7d7697e53e26036 Mon Sep 17 00:00:00 2001 From: algerkong Date: Fri, 27 Jun 2025 18:49:37 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20chore:=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=EF=BC=8C=E6=9B=B4=E6=96=B0=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=9A=84=E9=9F=B3=E4=B9=90=E6=BA=90=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/index.ts | 7 - src/main/modules/statsService.ts | 122 ------------------ src/main/set.json | 2 +- src/main/unblockMusic.ts | 4 +- src/preload/index.ts | 6 +- src/renderer/api/gdmusic.ts | 5 +- src/renderer/api/stats.ts | 75 ----------- src/renderer/components/home/TopBanner.vue | 18 +-- .../components/player/ReparsePopover.vue | 2 - .../settings/MusicSourceSettings.vue | 5 +- src/renderer/hooks/MusicHistoryHook.ts | 20 --- src/renderer/router/index.ts | 10 +- src/renderer/type/music.ts | 1 - src/renderer/types/music.ts | 4 +- src/renderer/views/set/index.vue | 3 +- 15 files changed, 20 insertions(+), 264 deletions(-) delete mode 100644 src/main/modules/statsService.ts delete mode 100644 src/renderer/api/stats.ts diff --git a/src/main/index.ts b/src/main/index.ts index bab4bae..d5788e5 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -10,7 +10,6 @@ import { initializeFileManager } from './modules/fileManager'; import { initializeFonts } from './modules/fonts'; import { initializeRemoteControl } from './modules/remoteControl'; import { initializeShortcuts, registerShortcuts } from './modules/shortcuts'; -import { initializeStats, setupStatsHandlers } from './modules/statsService'; import { initializeTray, updateCurrentSong, updatePlayState, updateTrayMenu } from './modules/tray'; import { setupUpdateHandlers } from './modules/update'; import { createMainWindow, initializeWindowManager } from './modules/window'; @@ -51,12 +50,6 @@ function initialize() { // 初始化托盘 initializeTray(iconPath, mainWindow); - // 初始化统计服务 - initializeStats(); - - // 设置统计相关的IPC处理程序 - setupStatsHandlers(ipcMain); - // 启动音乐API startMusicApi(); diff --git a/src/main/modules/statsService.ts b/src/main/modules/statsService.ts deleted file mode 100644 index bce6d30..0000000 --- a/src/main/modules/statsService.ts +++ /dev/null @@ -1,122 +0,0 @@ -import axios from 'axios'; -import { app } from 'electron'; -import Store from 'electron-store'; - -import { getDeviceId, getSystemInfo } from './deviceInfo'; - -const store = new Store(); - -// 统计服务配置 -const STATS_API_URL = 'http://donate.alger.fun/state/api/stats'; - -/** - * 记录应用安装/启动 - */ -export async function recordInstallation(): Promise { - try { - const deviceId = getDeviceId(); - const systemInfo = getSystemInfo(); - - // 发送请求到统计服务器 - await axios.post(`${STATS_API_URL}/installation`, { - deviceId, - osType: systemInfo.osType, - osVersion: systemInfo.osVersion, - appVersion: systemInfo.appVersion - }); - - console.log('应用启动统计已记录'); - - // 记录最后一次启动时间 - store.set('lastStartTime', new Date().toISOString()); - } catch (error) { - console.error('记录应用启动统计失败:', error); - } -} - -/** - * 设置 IPC 处理程序以接收渲染进程的统计请求 - * @param ipcMain Electron IPC主对象 - */ -export function setupStatsHandlers(ipcMain: Electron.IpcMain): void { - // 处理页面访问统计 - ipcMain.handle('record-visit', async (_, page: string, userId?: string) => { - try { - const deviceId = getDeviceId(); - - await axios.post(`${STATS_API_URL}/visit`, { - deviceId, - userId, - page - }); - - return { success: true }; - } catch (error) { - console.error('记录页面访问统计失败:', error); - return { success: false, error: (error as Error).message }; - } - }); - - // 处理播放统计 - ipcMain.handle( - 'record-play', - async ( - _, - songData: { - userId: string | null; - songId: string | number; - songName: string; - artistName: string; - duration?: number; - completedPlay?: boolean; - } - ) => { - try { - const { songId, songName, artistName, duration = 0, completedPlay = false } = songData; - const deviceId = getDeviceId(); - - await axios.post(`${STATS_API_URL}/play`, { - deviceId, - userId: songData.userId, - songId: songId.toString(), - songName, - artistName, - duration, - completedPlay - }); - - return { success: true }; - } catch (error) { - console.error('记录播放统计失败:', error); - return { success: false, error: (error as Error).message }; - } - } - ); - - // 处理获取统计摘要 - ipcMain.handle('get-stats-summary', async () => { - try { - const response = await axios.get(`${STATS_API_URL}/summary`); - return response.data; - } catch (error) { - console.error('获取统计摘要失败:', error); - throw error; - } - }); -} - -/** - * 应用启动时初始化统计服务 - */ -export function initializeStats(): void { - // 记录应用启动统计 - recordInstallation().catch((error) => { - console.error('初始化统计服务失败:', error); - }); - - // 注册应用退出时的回调 - app.on('will-quit', () => { - // 可以在这里添加应用退出时的统计逻辑 - console.log('应用退出'); - }); -} diff --git a/src/main/set.json b/src/main/set.json index fd2a2c8..8e4233f 100644 --- a/src/main/set.json +++ b/src/main/set.json @@ -23,7 +23,7 @@ "alwaysShowDownloadButton": false, "unlimitedDownload": false, "enableMusicUnblock": true, - "enabledMusicSources": ["migu", "kugou", "pyncmd", "bilibili", "kuwo"], + "enabledMusicSources": ["migu", "kugou", "pyncmd", "bilibili"], "showTopAction": false, "contentZoomFactor": 1 } diff --git a/src/main/unblockMusic.ts b/src/main/unblockMusic.ts index bc0533d..171fdb3 100644 --- a/src/main/unblockMusic.ts +++ b/src/main/unblockMusic.ts @@ -1,6 +1,6 @@ import match from '@unblockneteasemusic/server'; -type Platform = 'qq' | 'migu' | 'kugou' | 'pyncmd' | 'joox' | 'kuwo' | 'bilibili'; +type Platform = 'qq' | 'migu' | 'kugou' | 'pyncmd' | 'joox' | 'bilibili'; interface SongData { name: string; @@ -30,7 +30,7 @@ interface UnblockResult { } // 所有可用平台 -export const ALL_PLATFORMS: Platform[] = ['migu', 'kugou', 'pyncmd', 'kuwo', 'bilibili']; +export const ALL_PLATFORMS: Platform[] = ['migu', 'kugou', 'pyncmd', 'bilibili']; /** * 音乐解析函数 diff --git a/src/preload/index.ts b/src/preload/index.ts index c75c40b..3cce699 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -47,11 +47,7 @@ const api = { 'get-system-fonts', 'get-cached-lyric', 'cache-lyric', - 'clear-lyric-cache', - // 统计相关 - 'record-visit', - 'record-play', - 'get-stats-summary' + 'clear-lyric-cache' ]; if (validChannels.includes(channel)) { return ipcRenderer.invoke(channel, ...args); diff --git a/src/renderer/api/gdmusic.ts b/src/renderer/api/gdmusic.ts index b2e232b..dd82aea 100644 --- a/src/renderer/api/gdmusic.ts +++ b/src/renderer/api/gdmusic.ts @@ -73,9 +73,8 @@ export const parseFromGDMusic = async ( throw new Error('搜索查询过短'); } - // 所有可用的音乐源 netease、kuwo、joox、tidal - const allSources = [ - 'kuwo', 'joox', 'tidal', 'netease' + // 所有可用的音乐源 netease、joox、tidal + const allSources = ['joox', 'tidal', 'netease' ] as MusicSourceType[]; console.log('GD音乐台开始搜索:', searchQuery); diff --git a/src/renderer/api/stats.ts b/src/renderer/api/stats.ts deleted file mode 100644 index c7447cf..0000000 --- a/src/renderer/api/stats.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { isElectron } from '@/utils'; - -import { useUserStore } from '../store/modules/user'; - -/** - * 获取用户ID - * @returns 用户ID或null - */ -function getUserId(): string | null { - const userStore = useUserStore(); - return userStore.user?.userId?.toString() || null; -} - -/** - * 记录页面访问 - * @param page 页面名称或路径 - */ -export async function recordVisit(page: string): Promise { - if (!isElectron) return; - try { - const userId = getUserId(); - await window.api.invoke('record-visit', page, userId); - console.log(`页面访问已记录: ${page}`); - } catch (error) { - console.error('记录页面访问失败:', error); - } -} - -/** - * 记录歌曲播放 - * @param songId 歌曲ID - * @param songName 歌曲名称 - * @param artistName 艺术家名称 - * @param duration 时长(秒) - * @param completedPlay 是否完整播放 - */ -export async function recordPlay( - songId: string | number, - songName: string, - artistName: string, - duration: number = 0, - completedPlay: boolean = false -): Promise { - if (!isElectron) return; - try { - const userId = getUserId(); - - await window.api.invoke('record-play', { - userId, - songId, - songName, - artistName, - duration, - completedPlay - }); - - console.log(`歌曲播放已记录: ${songName}`); - } catch (error) { - console.error('记录歌曲播放失败:', error); - } -} - -/** - * 获取统计摘要 - * @returns 统计数据摘要 - */ -export async function getStatsSummary(): Promise { - if (!isElectron) return null; - try { - return await window.api.invoke('get-stats-summary'); - } catch (error) { - console.error('获取统计摘要失败:', error); - return null; - } -} diff --git a/src/renderer/components/home/TopBanner.vue b/src/renderer/components/home/TopBanner.vue index d67dd5d..1bb90d9 100644 --- a/src/renderer/components/home/TopBanner.vue +++ b/src/renderer/components/home/TopBanner.vue @@ -142,7 +142,7 @@ import { IDayRecommend } from '@/type/day_recommend'; import { Playlist } from '@/type/list'; import type { IListDetail } from '@/type/listDetail'; import { SongResult } from '@/type/music'; -import type { Artist, IHotSinger } from '@/type/singer'; +import type { IHotSinger } from '@/type/singer'; import { getImgUrl, isMobile, @@ -150,7 +150,6 @@ import { setAnimationDelay, setBackgroundImg } from '@/utils'; -import { getArtistDetail } from '@/api/artist'; import { navigateToMusicList } from '@/components/common/MusicListNavigator'; const userStore = useUserStore(); @@ -233,20 +232,6 @@ onMounted(async () => { loadNonUserData(); }); -const JayChouId = 6452; -const loadArtistData = async () => { - try { - const { data: artistData }: { data: { data: { artist: Artist } } } = await getArtistDetail(JayChouId); - console.log('artistData', artistData); - if (hotSingerData.value) { - // 将周杰伦数据放在第一位 - hotSingerData.value.artists = [artistData.data.artist, ...hotSingerData.value.artists]; - } - } catch (error) { - console.error('获取周杰伦数据失败:', error); - } -} - // 提取每日推荐加载逻辑到单独的函数 const loadDayRecommendData = async () => { @@ -276,7 +261,6 @@ const loadNonUserData = async () => { const { data: singerData } = await getHotSinger({ offset: 0, limit: 5 }); hotSingerData.value = singerData; - await loadArtistData(); } catch (error) { console.error('加载热门歌手数据失败:', error); } diff --git a/src/renderer/components/player/ReparsePopover.vue b/src/renderer/components/player/ReparsePopover.vue index 05e078b..588256a 100644 --- a/src/renderer/components/player/ReparsePopover.vue +++ b/src/renderer/components/player/ReparsePopover.vue @@ -87,7 +87,6 @@ const musicSourceOptions = ref([ { label: 'MiGu', value: 'migu' as Platform }, { label: 'KuGou', value: 'kugou' as Platform }, { label: 'pyncmd', value: 'pyncmd' as Platform }, - { label: 'KuWo', value: 'kuwo' as Platform }, { label: 'Bilibili', value: 'bilibili' as Platform }, { label: 'GdMuisc', value: 'gdmusic' as Platform } ]); @@ -102,7 +101,6 @@ const getSourceIcon = (source: Platform) => { const iconMap: Record = { 'migu': 'ri-music-2-fill', 'kugou': 'ri-music-fill', - 'kuwo': 'ri-album-fill', 'qq': 'ri-qq-fill', 'joox': 'ri-disc-fill', 'pyncmd': 'ri-netease-cloud-music-fill', diff --git a/src/renderer/components/settings/MusicSourceSettings.vue b/src/renderer/components/settings/MusicSourceSettings.vue index 73460f1..266a29b 100644 --- a/src/renderer/components/settings/MusicSourceSettings.vue +++ b/src/renderer/components/settings/MusicSourceSettings.vue @@ -56,7 +56,7 @@ const props = defineProps({ }, sources: { type: Array as () => Platform[], - default: () => ['migu', 'kugou', 'pyncmd', 'bilibili', 'kuwo'] + default: () => ['migu', 'kugou', 'pyncmd', 'bilibili'] } }); @@ -70,7 +70,6 @@ const musicSourceOptions = ref([ { label: 'MiGu音乐', value: 'migu' }, { label: '酷狗音乐', value: 'kugou' }, { label: 'pyncmd', value: 'pyncmd' }, - { label: '酷我音乐', value: 'kuwo' }, { label: 'Bilibili音乐', value: 'bilibili' }, { label: 'GD音乐台', value: 'gdmusic' } ]); @@ -102,7 +101,7 @@ watch( const handleConfirm = () => { // 确保至少选择一个音源 - const defaultPlatforms = ['migu', 'kugou', 'pyncmd', 'bilibili', 'kuwo']; + const defaultPlatforms = ['migu', 'kugou', 'pyncmd', 'bilibili']; const valuesToEmit = selectedSources.value.length > 0 ? [...new Set(selectedSources.value)] : defaultPlatforms; diff --git a/src/renderer/hooks/MusicHistoryHook.ts b/src/renderer/hooks/MusicHistoryHook.ts index 263a97a..51dfc3e 100644 --- a/src/renderer/hooks/MusicHistoryHook.ts +++ b/src/renderer/hooks/MusicHistoryHook.ts @@ -1,7 +1,6 @@ // musicHistoryHooks import { useLocalStorage } from '@vueuse/core'; -import { recordPlay } from '@/api/stats'; import type { SongResult } from '@/type/music'; export const useMusicHistory = () => { @@ -15,25 +14,6 @@ export const useMusicHistory = () => { } else { musicHistory.value.unshift({ ...music, count: 1 }); } - - // 记录播放统计 - if (music?.id && music?.name) { - // 获取艺术家名称 - let artistName = '未知艺术家'; - - if (music.ar) { - artistName = music.ar.map((artist) => artist.name).join('/'); - } else if (music.song?.artists && music.song.artists.length > 0) { - artistName = music.song.artists.map((artist) => artist.name).join('/'); - } else if (music.artists) { - artistName = music.artists.map((artist) => artist.name).join('/'); - } - - // 发送播放统计 - recordPlay(music.id, music.name, artistName).catch((error) => - console.error('记录播放统计失败:', error) - ); - } }; const delMusic = (music: SongResult) => { diff --git a/src/renderer/router/index.ts b/src/renderer/router/index.ts index 102a006..59a7ca3 100644 --- a/src/renderer/router/index.ts +++ b/src/renderer/router/index.ts @@ -1,12 +1,17 @@ import { createRouter, createWebHashHistory } from 'vue-router'; -import { recordVisit } from '@/api/stats'; +import { useUserStore } from '../store/modules/user'; import AppLayout from '@/layout/AppLayout.vue'; import MiniLayout from '@/layout/MiniLayout.vue'; import homeRouter from '@/router/home'; import otherRouter from '@/router/other'; import { useSettingsStore } from '@/store/modules/settings'; +function getUserId(): string | null { + const userStore = useUserStore(); + return userStore.user?.userId?.toString() || null; +} + // 由于 Vue Router 守卫在创建前不能直接使用组合式 API // 我们创建一个辅助函数来获取 store 实例 let _settingsStore: ReturnType | null = null; @@ -76,7 +81,8 @@ router.afterEach((to) => { const pageName = to.name?.toString() || to.path; // 使用setTimeout避免阻塞路由导航 setTimeout(() => { - recordVisit(pageName).catch((error) => console.error('记录页面访问失败:', error)); + const userId = getUserId(); + console.log('pageName', pageName, userId); }, 100); }); diff --git a/src/renderer/type/music.ts b/src/renderer/type/music.ts index f836fce..4ca31b3 100644 --- a/src/renderer/type/music.ts +++ b/src/renderer/type/music.ts @@ -248,7 +248,6 @@ export interface IArtists { export type MusicSourceType = | 'tencent' | 'kugou' - | 'kuwo' | 'migu' | 'netease' | 'joox' diff --git a/src/renderer/types/music.ts b/src/renderer/types/music.ts index 8166346..eb79d49 100644 --- a/src/renderer/types/music.ts +++ b/src/renderer/types/music.ts @@ -1,5 +1,5 @@ // 音乐平台类型 -export type Platform = 'qq' | 'migu' | 'kugou' | 'pyncmd' | 'joox' | 'kuwo' | 'bilibili' | 'gdmusic'; +export type Platform = 'qq' | 'migu' | 'kugou' | 'pyncmd' | 'joox' | 'bilibili' | 'gdmusic'; // 默认平台列表 -export const DEFAULT_PLATFORMS: Platform[] = ['migu', 'kugou', 'pyncmd', 'bilibili', 'kuwo']; \ No newline at end of file +export const DEFAULT_PLATFORMS: Platform[] = ['migu', 'kugou', 'pyncmd', 'bilibili']; \ No newline at end of file diff --git a/src/renderer/views/set/index.vue b/src/renderer/views/set/index.vue index 44458b1..079db71 100644 --- a/src/renderer/views/set/index.vue +++ b/src/renderer/views/set/index.vue @@ -171,7 +171,6 @@ 网易云音乐会员 QQ音乐会员 酷狗音乐会员 - 酷我音乐会员 @@ -522,7 +521,7 @@ import { type Platform } from '@/types/music'; import config from '../../../../package.json'; // 所有平台默认值 -const ALL_PLATFORMS: Platform[] = ['migu', 'kugou', 'pyncmd', 'bilibili', 'kuwo']; +const ALL_PLATFORMS: Platform[] = ['migu', 'kugou', 'pyncmd', 'bilibili']; const platform = window.electron ? window.electron.ipcRenderer.sendSync('get-platform') : 'web';