2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
2022-11-02 19:25:22 +00:00
|
|
|
<dialog ref="dialog" class="text-primary bg-primary" @cancel.prevent>
|
2022-12-02 16:17:37 +00:00
|
|
|
<Component :is="modalNameToComponentMap[activeModalName]" v-if="activeModalName" @close="close" />
|
2022-10-27 21:19:26 +00:00
|
|
|
</dialog>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-12-02 16:17:37 +00:00
|
|
|
import { defineAsyncComponent, ref, watch } from 'vue'
|
2022-07-20 08:00:02 +00:00
|
|
|
import { arrayify, eventBus, provideReadonly } from '@/utils'
|
2022-11-27 15:29:29 +00:00
|
|
|
import { ModalContextKey } from '@/symbols'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
const modalNameToComponentMap = {
|
2022-10-27 21:19:26 +00:00
|
|
|
'create-playlist-form': defineAsyncComponent(() => import('@/components/playlist/CreatePlaylistForm.vue')),
|
|
|
|
'edit-playlist-form': defineAsyncComponent(() => import('@/components/playlist/EditPlaylistForm.vue')),
|
|
|
|
'create-smart-playlist-form': defineAsyncComponent(() => import('@/components/playlist/smart-playlist/CreateSmartPlaylistForm.vue')),
|
|
|
|
'edit-smart-playlist-form': defineAsyncComponent(() => import('@/components/playlist/smart-playlist/EditSmartPlaylistForm.vue')),
|
|
|
|
'add-user-form': defineAsyncComponent(() => import('@/components/user/AddUserForm.vue')),
|
|
|
|
'edit-user-form': defineAsyncComponent(() => import('@/components/user/EditUserForm.vue')),
|
2023-08-20 22:35:58 +00:00
|
|
|
'invite-user-form': defineAsyncComponent(() => import('@/components/user/InviteUserForm.vue')),
|
2022-10-27 21:19:26 +00:00
|
|
|
'edit-song-form': defineAsyncComponent(() => import('@/components/song/EditSongForm.vue')),
|
|
|
|
'create-playlist-folder-form': defineAsyncComponent(() => import('@/components/playlist/CreatePlaylistFolderForm.vue')),
|
|
|
|
'edit-playlist-folder-form': defineAsyncComponent(() => import('@/components/playlist/EditPlaylistFolderForm.vue')),
|
2024-01-26 14:24:46 +00:00
|
|
|
'playlist-collaboration': defineAsyncComponent(() => import('@/components/playlist/PlaylistCollaborationModal.vue')),
|
2022-11-02 19:25:22 +00:00
|
|
|
'about-koel': defineAsyncComponent(() => import('@/components/meta/AboutKoelModal.vue')),
|
2024-01-13 17:57:24 +00:00
|
|
|
'koel-plus': defineAsyncComponent(() => import('@/components/koel-plus/KoelPlusModal.vue')),
|
2022-11-02 19:25:22 +00:00
|
|
|
'equalizer': defineAsyncComponent(() => import('@/components/ui/Equalizer.vue'))
|
2022-10-27 21:19:26 +00:00
|
|
|
}
|
2022-07-10 15:17:48 +00:00
|
|
|
|
2022-10-27 21:19:26 +00:00
|
|
|
type ModalName = keyof typeof modalNameToComponentMap
|
|
|
|
|
|
|
|
const dialog = ref<HTMLDialogElement>()
|
|
|
|
const activeModalName = ref<ModalName | null>(null)
|
2022-11-27 15:29:29 +00:00
|
|
|
const context = ref<Record<string, any>>({})
|
2022-07-10 15:17:48 +00:00
|
|
|
|
2022-11-27 15:29:29 +00:00
|
|
|
provideReadonly(ModalContextKey, context)
|
2022-09-08 05:06:49 +00:00
|
|
|
|
2022-10-27 21:19:26 +00:00
|
|
|
watch(activeModalName, name => name ? dialog.value?.showModal() : dialog.value?.close())
|
|
|
|
|
2022-11-27 15:29:29 +00:00
|
|
|
const close = () => {
|
|
|
|
activeModalName.value = null
|
|
|
|
context.value = {}
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-11-15 15:52:38 +00:00
|
|
|
eventBus.on('MODAL_SHOW_ABOUT_KOEL', () => (activeModalName.value = 'about-koel'))
|
2024-01-13 17:57:24 +00:00
|
|
|
.on('MODAL_SHOW_KOEL_PLUS', () => (activeModalName.value = 'koel-plus'))
|
2022-11-15 15:52:38 +00:00
|
|
|
.on('MODAL_SHOW_ADD_USER_FORM', () => (activeModalName.value = 'add-user-form'))
|
2023-08-20 22:35:58 +00:00
|
|
|
.on('MODAL_SHOW_INVITE_USER_FORM', () => (activeModalName.value = 'invite-user-form'))
|
2022-12-06 10:28:48 +00:00
|
|
|
.on('MODAL_SHOW_CREATE_PLAYLIST_FORM', (folder, songs) => {
|
|
|
|
context.value = {
|
|
|
|
folder,
|
|
|
|
songs: songs ? arrayify(songs) : []
|
|
|
|
}
|
|
|
|
|
2022-11-27 15:29:29 +00:00
|
|
|
activeModalName.value = 'create-playlist-form'
|
|
|
|
})
|
|
|
|
.on('MODAL_SHOW_CREATE_SMART_PLAYLIST_FORM', folder => {
|
|
|
|
context.value = { folder }
|
|
|
|
activeModalName.value = 'create-smart-playlist-form'
|
|
|
|
})
|
2022-11-15 15:52:38 +00:00
|
|
|
.on('MODAL_SHOW_CREATE_PLAYLIST_FOLDER_FORM', () => (activeModalName.value = 'create-playlist-folder-form'))
|
|
|
|
.on('MODAL_SHOW_EDIT_PLAYLIST_FORM', playlist => {
|
2022-11-27 15:29:29 +00:00
|
|
|
context.value = { playlist }
|
2022-10-27 21:19:26 +00:00
|
|
|
activeModalName.value = playlist.is_smart ? 'edit-smart-playlist-form' : 'edit-playlist-form'
|
2022-11-15 15:52:38 +00:00
|
|
|
})
|
|
|
|
.on('MODAL_SHOW_EDIT_USER_FORM', user => {
|
2022-11-27 15:29:29 +00:00
|
|
|
context.value = { user }
|
2022-10-27 21:19:26 +00:00
|
|
|
activeModalName.value = 'edit-user-form'
|
2022-11-15 15:52:38 +00:00
|
|
|
})
|
|
|
|
.on('MODAL_SHOW_EDIT_SONG_FORM', (songs, initialTab: EditSongFormTabName = 'details') => {
|
2022-11-27 15:29:29 +00:00
|
|
|
context.value = {
|
|
|
|
initialTab,
|
|
|
|
songs: arrayify(songs)
|
|
|
|
}
|
|
|
|
|
2022-10-27 21:19:26 +00:00
|
|
|
activeModalName.value = 'edit-song-form'
|
2022-11-15 15:52:38 +00:00
|
|
|
})
|
|
|
|
.on('MODAL_SHOW_EDIT_PLAYLIST_FOLDER_FORM', folder => {
|
2022-11-27 15:29:29 +00:00
|
|
|
context.value = { folder }
|
2022-10-27 21:19:26 +00:00
|
|
|
activeModalName.value = 'edit-playlist-folder-form'
|
2022-11-15 15:52:38 +00:00
|
|
|
})
|
2024-01-24 22:39:47 +00:00
|
|
|
.on('MODAL_SHOW_PLAYLIST_COLLABORATION', playlist => {
|
|
|
|
context.value = { playlist }
|
|
|
|
activeModalName.value = 'playlist-collaboration'
|
|
|
|
})
|
2022-11-15 15:52:38 +00:00
|
|
|
.on('MODAL_SHOW_EQUALIZER', () => (activeModalName.value = 'equalizer'))
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
2022-07-22 16:15:30 +00:00
|
|
|
|
2024-04-04 20:13:35 +00:00
|
|
|
<style lang="postcss" scoped>
|
2022-10-27 21:19:26 +00:00
|
|
|
dialog {
|
|
|
|
border: 0;
|
|
|
|
padding: 0;
|
|
|
|
border-radius: 4px;
|
|
|
|
min-width: 460px;
|
|
|
|
max-width: calc(100vw - 24px);
|
2024-01-13 17:57:24 +00:00
|
|
|
overflow: visible;
|
2022-07-22 16:15:30 +00:00
|
|
|
|
2022-10-27 21:19:26 +00:00
|
|
|
@media screen and (max-width: 768px) {
|
|
|
|
min-width: calc(100vw - 24px);
|
|
|
|
}
|
|
|
|
|
|
|
|
&::backdrop {
|
|
|
|
background: rgba(0, 0, 0, 0.7);
|
|
|
|
}
|
|
|
|
|
2024-01-24 22:39:47 +00:00
|
|
|
:deep(form), :deep(>div) {
|
2022-10-27 21:19:26 +00:00
|
|
|
position: relative;
|
2022-07-29 12:12:55 +00:00
|
|
|
|
2022-07-22 16:15:30 +00:00
|
|
|
> header, > main, > footer {
|
|
|
|
padding: 1.2rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
> footer {
|
|
|
|
margin-top: 0;
|
2024-01-24 22:39:47 +00:00
|
|
|
background: rgba(0, 0, 0, 0.1);
|
|
|
|
border-top: 1px solid rgba(255, 255, 255, .05);
|
2022-07-22 16:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[type=text], [type=number], [type=email], [type=password], [type=url], [type=date], textarea, select {
|
|
|
|
width: 100%;
|
|
|
|
max-width: 100%;
|
|
|
|
height: 32px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.warning {
|
|
|
|
color: var(--color-red);
|
|
|
|
}
|
|
|
|
|
|
|
|
textarea {
|
|
|
|
min-height: 192px;
|
|
|
|
}
|
|
|
|
|
2022-10-27 21:19:26 +00:00
|
|
|
> footer {
|
|
|
|
button + button {
|
|
|
|
margin-left: .5rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-22 16:15:30 +00:00
|
|
|
> header {
|
|
|
|
display: flex;
|
|
|
|
background: var(--color-bg-secondary);
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
font-size: 1.8rem;
|
|
|
|
line-height: 2.2rem;
|
|
|
|
margin-bottom: .3rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|