feat: 优化UI

This commit is contained in:
Blizzard
2026-03-05 17:04:40 +08:00
parent 0a61c4ddec
commit 7f51b2a0a8
28 changed files with 1773 additions and 964 deletions
+58 -6
View File
@@ -110,7 +110,7 @@ function unsubscribe(channelId) {
/** 添加收听历史 */
function addHistory(params) {
return post('/radio/history/add', {
return post('/history/add', {
programId: params.programId,
progress: params.progress || 0,
duration: params.duration || 0
@@ -119,27 +119,42 @@ function addHistory(params) {
/** 获取收听历史列表 */
function getHistoryList(params) {
return post('/radio/history/list', {
return post('/history/list', {
current: (params && params.current) || 1,
pageSize: (params && params.pageSize) || 20
})
}
/** 删除单条收听历史 */
function deleteHistory(programId) {
return post('/history/delete', { programId })
}
/** 清空全部收听历史 */
function deleteAllHistory() {
return get('/history/deleteAll')
}
// ======================== 收藏 ========================
/** 添加收藏 */
function addFavorite(programId) {
return post('/radio/favorite/add', { programId })
return post('/favorite/add', { programId })
}
/** 取消收藏 */
function removeFavorite(programId) {
return post('/radio/favorite/remove', { programId })
return post('/favorite/remove', { programId })
}
/** 清空全部收藏 */
function removeAllFavorites() {
return get('/favorite/removeAll')
}
/** 获取收藏列表 */
function getFavoriteList(params) {
return post('/radio/favorite/list', {
return post('/favorite/list', {
current: (params && params.current) || 1,
pageSize: (params && params.pageSize) || 20
})
@@ -149,10 +164,39 @@ function getFavoriteList(params) {
/** 切换点赞 */
function toggleLike(programId) {
return post('/radio/like/toggle', { programId })
return post('/like/toggle', { programId })
}
/** 添加评论 */
function addComment(programId, content) {
return post('/comment/add', { programId, content })
}
/** 删除评论 */
function deleteComment(id) {
return post('/comment/delete', { id })
}
/** 获取评论列表 */
function getCommentList(programId, params) {
return post('/comment/list', {
programId,
current: (params && params.current) || 1,
pageSize: (params && params.pageSize) || 20
})
}
/** 获取当前登录用户 */
/** 获取 VIP 配置(价格等) */
function getVipConfig() {
return post('/vip/config/detail', {})
}
/** 发起 VIP 开通预支付 */
function initiateVipPayment() {
return post('/vip/vip',{})
}
function getUserInfo() {
return get('/user/info')
}
@@ -205,10 +249,18 @@ module.exports = {
unsubscribe,
addHistory,
getHistoryList,
deleteHistory,
deleteAllHistory,
addFavorite,
removeFavorite,
removeAllFavorites,
getFavoriteList,
toggleLike,
addComment,
deleteComment,
getCommentList,
getVipConfig,
initiateVipPayment,
getUserInfo,
subscribeChannel,
unlockChannel,
+8 -11
View File
@@ -10,6 +10,7 @@ const api = require('./api')
let bgAudioManager = null
let appInstance = null
let _switching = false // 切换音频时的锁,防止 onStop 事件干扰
let _ended = false // 标记音频是否已自然播放完毕
/**
* 初始化音频管理器
@@ -42,6 +43,7 @@ function init(app) {
})
bgAudioManager.onEnded(() => {
_ended = true
reportHistory()
updatePlayState(false)
appInstance.globalData.currentTime = appInstance.globalData.duration
@@ -140,6 +142,7 @@ function playContent(content) {
// 标记正在切换,防止旧音频的 onStop 干扰
_switching = true
_ended = false // 重置结束标记
appInstance.globalData.activeContent = content
appInstance.globalData.currentTime = 0
@@ -167,18 +170,12 @@ function togglePlay() {
if (appInstance.globalData.isPlaying) {
bgAudioManager.pause()
} else {
// 检查 bgAudioManager 是否还有有效的 src
// 音频结束/被系统回收后,src 会变为空,此时 play() 无效
// 需要重新设置 src 来恢复播放
var currentSrc = ''
try {
currentSrc = bgAudioManager.src
} catch (e) {
currentSrc = ''
}
// 音频已自然播放完毕,或 src 被系统回收 → 从头重新播放
var srcEmpty = false
try { srcEmpty = !bgAudioManager.src } catch (e) { srcEmpty = true }
if (!currentSrc) {
// src 已被清空(音频结束、系统回收等),重新播放
if (_ended || srcEmpty) {
_ended = false
playContent(appInstance.globalData.activeContent)
} else {
bgAudioManager.play()
+2 -2
View File
@@ -4,8 +4,8 @@
*/
// 接口基础地址(预留占位符,对接后端时替换)
const API_BASE_URL = 'https://radio.sundynix.cn/api'
//const API_BASE_URL = 'http://192.168.0.184:8888'
//const API_BASE_URL = 'https://radio.sundynix.cn/api'
const API_BASE_URL = 'http://192.168.0.184:8888'
/**