mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-03 14:20:50 +08:00
🔧 chore: 移除统计,更新支持的音乐源列表
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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<void> {
|
||||
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('应用退出');
|
||||
});
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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'];
|
||||
|
||||
/**
|
||||
* 音乐解析函数
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<void> {
|
||||
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<void> {
|
||||
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<any> {
|
||||
if (!isElectron) return null;
|
||||
try {
|
||||
return await window.api.invoke('get-stats-summary');
|
||||
} catch (error) {
|
||||
console.error('获取统计摘要失败:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<Platform, string> = {
|
||||
'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',
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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<typeof useSettingsStore> | 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);
|
||||
});
|
||||
|
||||
|
||||
@@ -248,7 +248,6 @@ export interface IArtists {
|
||||
export type MusicSourceType =
|
||||
| 'tencent'
|
||||
| 'kugou'
|
||||
| 'kuwo'
|
||||
| 'migu'
|
||||
| 'netease'
|
||||
| 'joox'
|
||||
|
||||
@@ -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'];
|
||||
export const DEFAULT_PLATFORMS: Platform[] = ['migu', 'kugou', 'pyncmd', 'bilibili'];
|
||||
@@ -171,7 +171,6 @@
|
||||
<a class="text-green-400 hover:text-green-500" href="https://music.163.com/store/vip" target="_blank">网易云音乐会员</a>
|
||||
<a class="text-green-400 hover:text-green-500" href="https://y.qq.com/portal/vipportal/" target="_blank">QQ音乐会员</a>
|
||||
<a class="text-green-400 hover:text-green-500" href="https://vip.kugou.com/" target="_blank">酷狗音乐会员</a>
|
||||
<a class="text-green-400 hover:text-green-500" href="https://vip1.kuwo.cn/" target="_blank">酷我音乐会员</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user