新增“不喜欢歌曲”功能&新增“收藏歌曲”、“取消收藏”、“不喜欢该歌曲”快捷键设置

This commit is contained in:
lyswhut
2023-09-04 14:13:47 +08:00
parent 3ca8f09971
commit baf69e397a
40 changed files with 861 additions and 26 deletions
@@ -201,6 +201,7 @@ export default {
handleSearch,
handleOpenMusicDetail,
handleCopyName,
handleDislikeMusic,
handleRemoveMusic,
} = useMusicActions({ props, list, removeAllSelect, selectedList })
@@ -223,6 +224,7 @@ export default {
handleShowSortModal,
handleOpenMusicDetail,
handleCopyName,
handleDislikeMusic,
handleRemoveMusic,
})
@@ -1,6 +1,7 @@
import { computed, ref, shallowReactive, reactive, nextTick } from '@common/utils/vueTools'
import musicSdk from '@renderer/utils/musicSdk'
import { useI18n } from '@renderer/plugins/i18n'
import { hasDislike } from '@renderer/core/dislikeList'
export default ({
assertApiSupport,
@@ -15,6 +16,7 @@ export default ({
handleShowSortModal,
handleOpenMusicDetail,
handleCopyName,
handleDislikeMusic,
handleRemoveMusic,
}) => {
const itemMenuControl = reactive({
@@ -26,6 +28,7 @@ export default ({
sort: true,
download: true,
search: true,
dislike: true,
remove: true,
sourceDetail: true,
})
@@ -80,6 +83,11 @@ export default ({
action: 'search',
disabled: !itemMenuControl.search,
},
{
name: t('list__dislike'),
action: 'dislike',
disabled: !itemMenuControl.dislike,
},
{
name: t('list__remove'),
action: 'remove',
@@ -94,6 +102,8 @@ export default ({
// itemMenuControl.playLater =
itemMenuControl.download = assertApiSupport(musicInfo.source) && musicInfo.source != 'local'
itemMenuControl.dislike = !hasDislike(musicInfo)
menuLocation.x = event.pageX
menuLocation.y = event.pageY
@@ -138,6 +148,9 @@ export default ({
case 'search':
handleSearch(index)
break
case 'dislike':
handleDislikeMusic(index)
break
case 'remove':
handleRemoveMusic(index)
break
@@ -6,6 +6,9 @@ import { useI18n } from '@renderer/plugins/i18n'
import { removeListMusics } from '@renderer/store/list/action'
import { appSetting } from '@renderer/store/setting'
import { toOldMusicInfo } from '@renderer/utils/index'
import { addDislikeInfo, hasDislike } from '@renderer/core/dislikeList'
import { playNext } from '@renderer/core/player'
import { playMusicInfo } from '@renderer/store/player/state'
export default ({ props, list, selectedList, removeAllSelect }) => {
@@ -34,6 +37,14 @@ export default ({ props, list, selectedList, removeAllSelect }) => {
clipboardWriteText(appSetting['download.fileName'].replace('歌名', minfo.name).replace('歌手', minfo.singer))
}
const handleDislikeMusic = async(index) => {
const minfo = list.value[index]
await addDislikeInfo([{ name: minfo.name, singer: minfo.singer }])
if (!playMusicInfo.isTempPlay && hasDislike(playMusicInfo.musicInfo)) {
playNext(true)
}
}
const handleRemoveMusic = async(index, single) => {
if (selectedList.value.length && !single) {
const confirm = await (selectedList.value.length > 1
@@ -55,6 +66,7 @@ export default ({ props, list, selectedList, removeAllSelect }) => {
handleSearch,
handleOpenMusicDetail,
handleCopyName,
handleDislikeMusic,
handleRemoveMusic,
}
}
@@ -0,0 +1,112 @@
<template lang="pug">
material-modal(:show="modelValue" teleport="#view" height="80%" width="80%" @close="$emit('update:modelValue', false)")
main(:class="$style.main")
h2 {{ $t('setting__dislike_list_title') }}
div(:class="$style.content")
textarea(v-model="rules" :class="$style.textarea")
div(:class="$style.footer")
div(:class="$style.tips") {{ $t('setting__dislike_list_tips') }}
base-btn(:class="$style.btn" @click="handleSave") {{ $t('setting__dislike_list_save_btn') }}
</template>
<script>
import { watch, ref } from '@common/utils/vueTools'
import { overwirteDislikeInfo } from '@renderer/core/dislikeList'
import { dislikeInfo } from '@renderer/store/dislikeList'
export default {
props: {
modelValue: {
type: Boolean,
default: false,
},
},
emits: ['update:modelValue', 'onRuleUpdate'],
setup(props, { emit }) {
const rules = ref('')
const handleSave = async() => {
await overwirteDislikeInfo(rules.value)
emit('onRuleUpdate')
emit('update:modelValue', false)
}
watch(() => props.modelValue, (visible) => {
if (!visible) return
rules.value = dislikeInfo.rules
})
return {
rules,
handleSave,
}
},
}
</script>
<style lang="less" module>
@import '@renderer/assets/styles/layout.less';
.main {
// padding: 15px;
// max-width: 400px;
// min-width: 460px;
// min-height: 200px;
// width: ;
flex: auto;
display: flex;
flex-flow: column nowrap;
justify-content: center;
// min-height: 0;
// max-height: 100%;
// overflow: hidden;
h2 {
margin: 20px;
font-size: 16px;
color: var(--color-font);
line-height: 1.3;
text-align: center;
}
}
.content {
flex: auto;
// min-height: 100px;
max-height: 100%;
display: flex;
padding: 0 15px;
}
.textarea {
width: 100%;
height: 100%;
border: none;
outline: none;
border-radius: 4px;
background-color: var(--color-primary-light-200-alpha-900);
box-sizing: border-box;
font-family: inherit;
resize: none;
}
.footer {
box-sizing: border-box;
flex: none;
// width: @width;
padding: 15px 15px;
// padding: 2px 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.tips {
// padding: 10px 15px;
font-size: 12px;
line-height: 1.25;
color: var(--color-550);
white-space: pre-wrap;
}
.btn {
min-width: 80px;
}
</style>
@@ -34,6 +34,16 @@ dd
base-btn.btn(min :disabled="isDisabledMusicUrlCacheClear" @click="handleClearMusicUrlCache") {{ $t('setting__other_music_url_clear_btn') }}
base-btn.btn(min :disabled="isDisabledLyricRawCacheClear" @click="handleClearLyricRawCache") {{ $t('setting__other_lyric_raw_clear_btn') }}
dd
h3#other_lyric_edited {{ $t('setting__other_dislike_list') }}
div
.p
| {{ $t('setting__other_dislike_list_label') }}
span.auto-hidden {{ dislikeRuleCount }}
.p
base-btn.btn(min @click="isShowDislikeList = true") {{ $t('setting__other_dislike_list_show_btn') }}
DislikeListModal(v-model="isShowDislikeList" @on-rule-update="handleCountRules")
dd
h3#other_lyric_edited {{ $t('setting__other_lyric_edited_cache') }}
div
@@ -65,9 +75,14 @@ import { dialog } from '@renderer/plugins/Dialog'
import { useI18n } from '@renderer/plugins/i18n'
import { appSetting, updateSetting } from '@renderer/store/setting'
import { overwriteListFull } from '@renderer/store/list/listManage'
import { dislikeInfo } from '@renderer/store/dislikeList'
import DislikeListModal from './DislikeListModal.vue'
export default {
name: 'SettingOther',
components: {
DislikeListModal,
},
setup() {
const t = useI18n()
@@ -135,6 +150,11 @@ export default {
}
refreshMusicUrlCount()
const dislikeRuleCount = ref(dislikeInfo.musicNames.size + dislikeInfo.singerNames.size + dislikeInfo.names.size)
const isShowDislikeList = ref(false)
const handleCountRules = () => {
dislikeRuleCount.value = dislikeInfo.musicNames.size + dislikeInfo.singerNames.size + dislikeInfo.names.size
}
const lyricRawCount = ref(0)
const isDisabledLyricRawCacheClear = ref(false)
@@ -204,6 +224,10 @@ export default {
isDisabledMusicUrlCacheClear,
handleClearMusicUrlCache,
dislikeRuleCount,
isShowDislikeList,
handleCountRules,
lyricRawCount,
isDisabledLyricRawCacheClear,
handleClearLyricRawCache,