Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/components/Admin/SongManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,7 @@
<SongSourceReplaceModal
:show="showSourceReplaceModal"
:song="sourceReplaceSong"
allow-replace-title-artist
@close="showSourceReplaceModal = false"
@apply="applySourceReplacement"
/>
Expand Down Expand Up @@ -2445,6 +2446,9 @@ const applySourceReplacement = (payload) => {
editForm.value.musicId = payload.musicId || ''
if (payload.cover) editForm.value.cover = payload.cover
if (payload.durationSeconds != null) editForm.value.durationSeconds = payload.durationSeconds
// 勾选时同步采用新音源的歌名与歌手
if (payload.title) editForm.value.title = payload.title
if (payload.artist) editForm.value.artist = payload.artist
// 旧播放地址指向原音源,换源后必须清空避免继续使用旧链接
editForm.value.playUrl = ''
editSourceSelection.value = payload.selectionToken
Expand Down
63 changes: 49 additions & 14 deletions app/components/Admin/SongSourceReplaceModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -330,22 +330,49 @@
{{ t('sourceReplace.selectHint') }}
</p>
</div>
<div class="flex items-center justify-end gap-3 shrink-0">
<div class="flex flex-wrap items-center gap-3 shrink-0">
<button
class="px-5 py-2.5 text-xs font-bold text-text-tertiary hover:text-text-secondary"
@click="closeModal"
>
{{ t('sourceReplace.cancel') }}
</button>
<button
:disabled="!selected || applying"
class="px-6 py-2.5 bg-primary-hover hover:bg-primary text-text-primary text-xs font-black rounded-lg transition-all disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"
@click="applySelection"
v-if="allowReplaceTitleArtist"
type="button"
:aria-pressed="replaceTitleArtist"
:disabled="applying"
class="flex items-center gap-2 px-3 py-2.5 text-[11px] font-bold transition-all disabled:opacity-50 disabled:cursor-not-allowed"
:class="
replaceTitleArtist
? 'text-primary'
: 'text-text-tertiary hover:text-text-secondary'
"
@click="replaceTitleArtist = !replaceTitleArtist"
>
<Loader2 v-if="applying" :size="14" class="animate-spin" />
<ArrowLeftRight v-else :size="14" />
{{ applying ? t('sourceReplace.applying') : t('sourceReplace.apply') }}
<span
class="w-3.5 h-3.5 rounded border flex items-center justify-center shrink-0"
:class="
replaceTitleArtist
? 'bg-primary border-primary text-text-primary'
: 'border-border-tertiary'
"
>
<Check v-if="replaceTitleArtist" :size="10" />
</span>
{{ t('sourceReplace.replaceTitleArtist') }}
</button>
<div class="flex items-center gap-3 ml-auto">
<button
class="px-5 py-2.5 text-xs font-bold text-text-tertiary hover:text-text-secondary"
@click="closeModal"
>
{{ t('sourceReplace.cancel') }}
</button>
<button
:disabled="!selected || applying"
class="px-6 py-2.5 bg-primary-hover hover:bg-primary text-text-primary text-xs font-black rounded-lg transition-all disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2"
@click="applySelection"
>
<Loader2 v-if="applying" :size="14" class="animate-spin" />
<ArrowLeftRight v-else :size="14" />
{{ applying ? t('sourceReplace.applying') : t('sourceReplace.apply') }}
</button>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -392,6 +419,10 @@ const props = defineProps({
song: {
type: Object,
default: () => ({})
},
allowReplaceTitleArtist: {
type: Boolean,
default: false
}
})

Expand Down Expand Up @@ -421,6 +452,7 @@ const autoSearchPending = ref(false)
const selectedKey = ref('')
const selectedPageIndex = ref(0)
const applying = ref(false)
const replaceTitleArtist = ref(false)

const platformResults = ref({})
const platformStates = ref({})
Expand Down Expand Up @@ -804,7 +836,9 @@ const applySelection = async () => {
musicId,
cover: cover || '',
durationSeconds: durationSeconds || null,
selectionToken: isPluginPlatform(item.musicPlatform) ? item.selectionToken || '' : ''
selectionToken: isPluginPlatform(item.musicPlatform) ? item.selectionToken || '' : '',
title: props.allowReplaceTitleArtist && replaceTitleArtist.value ? item.title : null,
artist: props.allowReplaceTitleArtist && replaceTitleArtist.value ? item.artist : null
})
} finally {
applying.value = false
Expand All @@ -821,6 +855,7 @@ const resetState = () => {
selectedKey.value = ''
selectedPageIndex.value = 0
applying.value = false
replaceTitleArtist.value = false
platformResults.value = {}
platformStates.value = {}
platformErrors.value = {}
Expand Down
1 change: 1 addition & 0 deletions app/utils/locale/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2828,6 +2828,7 @@ export const admin = {
pageLabel: (page: number) => `P${page}`,
selectedHint:
'Platform, music ID and cover will be replaced; duration updates when available, play URL is cleared',
replaceTitleArtist: 'Replace title & artist',
selectHint: 'Select a search result',
apply: 'Apply',
applying: 'Fetching info...',
Expand Down
1 change: 1 addition & 0 deletions app/utils/locale/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2760,6 +2760,7 @@ export const admin = {
selectPage: '选择分P',
pageLabel: (page: number) => `P${page}`,
selectedHint: '应用后将替换平台、音乐 ID 与封面,可用时更新时长,并清空播放地址',
replaceTitleArtist: '同时替换歌名与歌手',
selectHint: '选择一条搜索结果',
apply: '应用替换',
applying: '获取信息中...',
Expand Down
Loading