mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
feat(dashboard): show monthly added music count in media statistics
- read music_count_month from dashboard statistic API and snapshot - replace the music library placeholder with the monthly addition text - drop unused dashboard.musicLibrary locale keys
This commit is contained in:
@@ -1386,6 +1386,8 @@ export interface MediaStatistic {
|
||||
tv_count_month: number
|
||||
// 本月新增剧集数量
|
||||
episode_count_month: number
|
||||
// 本月新增音乐数量
|
||||
music_count_month: number
|
||||
}
|
||||
|
||||
// 后台进程
|
||||
|
||||
@@ -1161,7 +1161,6 @@ export default {
|
||||
episodes: 'Episodes',
|
||||
users: 'Users',
|
||||
activeUsers: 'Active users',
|
||||
musicLibrary: 'Music library',
|
||||
noSchedulers: 'No Background Services',
|
||||
transferQueue: 'Transfer Queue',
|
||||
transferProgress: '{completed} / {total} files',
|
||||
|
||||
@@ -1152,7 +1152,6 @@ export default {
|
||||
episodes: '剧集',
|
||||
users: '用户',
|
||||
activeUsers: '活跃用户',
|
||||
musicLibrary: '音乐媒体库',
|
||||
noSchedulers: '没有后台服务',
|
||||
transferQueue: '整理队列',
|
||||
transferProgress: '{completed} / {total} 个文件',
|
||||
|
||||
@@ -1152,7 +1152,6 @@ export default {
|
||||
episodes: '劇集',
|
||||
users: '用戶',
|
||||
activeUsers: '活躍用戶',
|
||||
musicLibrary: '音樂媒體庫',
|
||||
noSchedulers: '沒有後台服務',
|
||||
transferQueue: '整理隊列',
|
||||
transferProgress: '{completed} / {total} 個文件',
|
||||
|
||||
@@ -20,6 +20,7 @@ const musicCount = ref(Number(currentSnapshot?.value.music_count) || 0)
|
||||
const movieCountMonth = ref(Number(currentSnapshot?.value.movie_count_month) || 0)
|
||||
const tvCountMonth = ref(Number(currentSnapshot?.value.tv_count_month) || 0)
|
||||
const episodeCountMonth = ref(Number(currentSnapshot?.value.episode_count_month) || 0)
|
||||
const musicCountMonth = ref(Number(currentSnapshot?.value.music_count_month) || 0)
|
||||
let statisticLoadId = 0
|
||||
|
||||
const animatedMovieCount = useAnimatedDashboardNumber(movieCount, {
|
||||
@@ -71,7 +72,7 @@ const statistics = computed(() => [
|
||||
stats: formatDashboardCount(animatedMusicCount.value),
|
||||
icon: 'mdi-music-box-multiple',
|
||||
color: 'info',
|
||||
addition: null,
|
||||
addition: musicCountMonth.value,
|
||||
},
|
||||
])
|
||||
|
||||
@@ -90,6 +91,7 @@ async function loadMediaStatistic() {
|
||||
movie_count_month: Number(res.movie_count_month) || 0,
|
||||
tv_count_month: Number(res.tv_count_month) || 0,
|
||||
episode_count_month: Number(res.episode_count_month) || 0,
|
||||
music_count_month: Number(res.music_count_month) || 0,
|
||||
}
|
||||
|
||||
movieCount.value = statistic.movie_count
|
||||
@@ -99,6 +101,7 @@ async function loadMediaStatistic() {
|
||||
movieCountMonth.value = statistic.movie_count_month
|
||||
tvCountMonth.value = statistic.tv_count_month
|
||||
episodeCountMonth.value = statistic.episode_count_month
|
||||
musicCountMonth.value = statistic.music_count_month
|
||||
writeSnapshot(statistic)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
@@ -132,7 +135,6 @@ onActivated(() => {
|
||||
<span v-if="item.addition !== null" class="dashboard-stat-addition">
|
||||
{{ t('dashboard.monthlyAddition', { count: item.addition }) }}
|
||||
</span>
|
||||
<span v-else class="dashboard-stat-addition text-medium-emphasis">{{ t('dashboard.musicLibrary') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -39,6 +39,7 @@ describe('AnalyticsMediaStatistic', () => {
|
||||
movie_count_month: 1,
|
||||
tv_count_month: 2,
|
||||
episode_count_month: 3,
|
||||
music_count_month: 7,
|
||||
},
|
||||
}),
|
||||
)
|
||||
@@ -51,6 +52,7 @@ describe('AnalyticsMediaStatistic', () => {
|
||||
expect(screen.getByText('34')).toBeInTheDocument()
|
||||
expect(screen.getByText('56')).toBeInTheDocument()
|
||||
expect(screen.getByText('7')).toBeInTheDocument()
|
||||
expect(screen.getByText('+7 本月新增')).toBeInTheDocument()
|
||||
expect(apiGet).toHaveBeenCalledWith('dashboard/statistic')
|
||||
|
||||
request.resolve({
|
||||
@@ -61,14 +63,17 @@ describe('AnalyticsMediaStatistic', () => {
|
||||
movie_count_month: 4,
|
||||
tv_count_month: 5,
|
||||
episode_count_month: 6,
|
||||
music_count_month: 9,
|
||||
})
|
||||
|
||||
await waitFor(() => expect(screen.getByText('21')).toBeInTheDocument())
|
||||
expect(screen.getByText('+9 本月新增')).toBeInTheDocument()
|
||||
expect(JSON.parse(localStorage.getItem(snapshotKey) ?? '{}').value).toMatchObject({
|
||||
movie_count: 21,
|
||||
tv_count: 43,
|
||||
episode_count: 65,
|
||||
music_count: 8,
|
||||
music_count_month: 9,
|
||||
})
|
||||
})
|
||||
|
||||
@@ -85,6 +90,7 @@ describe('AnalyticsMediaStatistic', () => {
|
||||
movie_count_month: 1,
|
||||
tv_count_month: 2,
|
||||
episode_count_month: 3,
|
||||
music_count_month: 7,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user