添加vue eslint规则,修复问题

This commit is contained in:
lyswhut
2021-12-03 23:45:03 +08:00
parent ccd951b5d3
commit 1ab5db8507
35 changed files with 198 additions and 175 deletions
+3 -3
View File
@@ -2,7 +2,7 @@
<div :class="$style.aside">
<ControlBtns v-if="setting.controlBtnPosition == 'left'" />
<div :class="$style.logo" v-else>L X</div>
<Nav />
<NavBar />
</div>
</template>
@@ -10,10 +10,10 @@
import { mapGetters } from 'vuex'
import ControlBtns from './ControlBtns'
import Nav from './Nav'
import NavBar from './NavBar'
export default {
components: { ControlBtns, Nav },
components: { ControlBtns, NavBar },
computed: {
...mapGetters(['setting']),
},
@@ -28,7 +28,7 @@ transition(enter-active-class="animated lightSpeedIn" leave-active-class="animat
p(v-if="musicInfo.album") {{$t('player__music_album')}}{{musicInfo.album}}
transition(enter-active-class="animated fadeIn" leave-active-class="animated fadeOut")
Lyric(v-if="visibleLrc")
LyricPlayer(v-if="visibleLrc")
core-music-comment(:class="$style.comment" :musicInfo="musicInfoItem" :show="isShowPlayComment" @close="hideComment")
play-bar
</template>
@@ -46,12 +46,12 @@ import {
musicInfoItem,
musicInfo,
} from '@renderer/core/share/player'
import Lyric from './Lyric'
import LyricPlayer from './LyricPlayer'
import PlayBar from './PlayBar'
export default {
components: {
Lyric,
LyricPlayer,
PlayBar,
},
setup() {
+3 -16
View File
@@ -97,22 +97,9 @@ const usePlayInfoInit = () => {
return downloadList => {
return getPlayInfo().then(info => {
window.restorePlayInfo = null
if (!info) return
if (info.index < 0) return
if (info.listId) {
if (info.listId == 'download') {
const list = downloadList
// console.log(list)
if (!list || !list[info.index]) return
info.list = list
} else {
const list = getList(info.listId)
// console.log(list)
if (!list[info.index]) return
info.list = list
}
}
if (!info.list || !info.list[info.index]) return
if (!info?.listId || info.index < 0) return
const list = getList(info.listId)
if (!list || !list[info.index]) return
window.restorePlayInfo = info
setPlayList({
listId: info.listId,
@@ -182,7 +182,7 @@ export default ({ setting }) => {
},
})
setImg(playMusicInfo)
setImg({ musicInfo: musicInfoItem.value, listId: playMusicInfo.listId })
setLrc(musicInfoItem.value)
if (setting.value.player.togglePlayMethod == 'random') setPlayedList({ ...playMusicInfo })
}
+1 -1
View File
@@ -39,7 +39,7 @@ export default {
return this.confirmButtonText || this.$t('confirm_button_text')
},
},
beforeDestroy() {
beforeUnmount() {
const el = this.$el
el.parentNode.removeChild(el)
},
-24
View File
@@ -1,24 +0,0 @@
import { onBeforeUnmount, ref, computed, useI18n, watch, useCommit } from '@renderer/utils/vueTools'
import { formatPlayTime2 } from '@renderer/utils'
import { setLoopPlay } from '../player'
export default ({ setting }) => {
const { t } = useI18n()
const toggleDesktopLyricBtnTitle = computed(() => {
return `${
setting.value.desktopLyric.enable
? t('desktop_lyric__off')
: t('desktop_lyric__on')
}(${
setting.value.desktopLyric.isLock
? t('desktop_lyric__unlock')
: t('desktop_lyric__lock')
})`
})
return {
toggleDesktopLyricBtnTitle,
}
}
-48
View File
@@ -1,48 +0,0 @@
import { useRefGetter, reactive, computed, watch, useCommit } from '@renderer/utils/vueTools'
import Lyric from '@renderer/utils/lyric-font-player'
import { getCurrentTime } from '@renderer/plugins/player'
import { setDesktopLyricInfo } from '@renderer/utils/tools'
// let lrc = window.lrc
export default ({ setting, musicInfo, isPlay, listId, setStatusText }) => {
const lyric = reactive({
lines: [],
text: '',
line: 0,
})
const lrc = window.lrc = new Lyric({
lineClassName: 'lrc-content',
fontClassName: 'font',
shadowContent: false,
activeLineClassName: 'active',
onPlay: (line, text) => {
lyric.text = text
lyric.line = line
setStatusText(text)
// console.log(line, text)
},
onSetLyric: lines => { // listening lyrics seting event
// console.log(lines) // lines is array of all lyric text
lyric.lines = lines
lyric.line = 0
},
// offset: 80,
})
const setLyric = () => {
lrc.setLyric(
setting.value.player.isPlayLxlrc && musicInfo.value.lxlrc ? musicInfo.vlaue.lxlrc : musicInfo.vlaue.lrc,
setting.value.player.isShowLyricTranslation && musicInfo.value.tlrc ? musicInfo.value.tlrc : '',
)
if (isPlay.value && (musicInfo.value.url || listId.value == 'download')) {
const time = getCurrentTime() * 1000
setDesktopLyricInfo('play', time)
lrc.play(time)
}
}
watch(setting.value.player.isShowLyricTranslation, setLyric)
watch(setting.value.player.isPlayLxlrc, setLyric)
}
+3 -3
View File
@@ -391,8 +391,8 @@ const mutations = {
window.eventHub.emit(eventListNames.listChange, [id])
},
clearCache() {
const [listIds, lists] = Object.entries(allList)
for (const { list } of lists) {
const lists = Object.values(allList)
for (const list of lists) {
for (const item of list) {
if (item.otherSource) item.otherSource = null
if (item.typeUrl['128k']) delete item.typeUrl['128k']
@@ -408,7 +408,7 @@ const mutations = {
}
clearMusicUrl()
clearLyric()
window.eventHub.emit(eventListNames.listChange, listIds)
window.eventHub.emit(eventListNames.listChange, Object.keys(allList))
},
setOtherSource(state, { musicInfo, otherSource }) {
musicInfo.otherSource = otherSource
+1 -1
View File
@@ -192,7 +192,7 @@ export default {
created() {
this.listenEvent()
},
beforeDestroy() {
beforeUnmount() {
this.unlistenEvent()
},
methods: {
+1 -1
View File
@@ -120,7 +120,7 @@ export default {
created() {
this.listenEvent()
},
beforeDestroy() {
beforeUnmount() {
this.unlistenEvent()
},
mounted() {
+3 -3
View File
@@ -1,6 +1,6 @@
<template>
<div id="my-list" :class="$style.container" @click="handleContainerClick" v-if="isInitedList">
<Lists :list-id="listId" @show-menu="$refs.musicList.hideMenu()" ref="lists" />
<MyLists :list-id="listId" @show-menu="$refs.musicList.hideMenu()" ref="lists" />
<MusicList :list-id="listId" @show-menu="$refs.lists.hideListsMenu()" ref="musicList" />
</div>
@@ -11,13 +11,13 @@ import { getListPrevSelectId } from '@renderer/utils/data'
import { isInitedList } from '@renderer/core/share/list'
import { getList } from '@renderer/core/share/utils'
import Lists from './components/Lists'
import MyLists from './components/MyLists'
import MusicList from './components/MusicList'
export default {
name: 'List',
components: {
Lists,
MyLists,
MusicList,
},
setup() {
@@ -48,7 +48,7 @@ import { computed } from '@renderer/utils/vueTools'
import { getList } from '@renderer/core/share/utils'
export default {
name: 'ListLists',
name: 'MyLists',
props: {
listId: {
type: [String, Number],
+42 -43
View File
@@ -1,5 +1,4 @@
<template>
<div :class="$style.main">
<!-- <div class="scroll" :class="$style.toc">
<ul :class="$style.tocList">
@@ -19,20 +18,20 @@
</div> -->
<div class="scroll" :class="$style.setting" ref="dom_setting">
<dl ref="dom_setting_list">
<Basic />
<Play />
<DesktopLyric />
<Search />
<List />
<Download />
<Sync />
<HotKey />
<Network />
<Odc />
<Backup />
<Other />
<Update />
<About />
<SettingBasic />
<SettingPlay />
<SettingDesktopLyric />
<SettingSearch />
<SettingList />
<SettingDownload />
<SettingSync />
<SettingHotKey />
<SettingNetwork />
<SettingOdc />
<SettingBackup />
<SettingOther />
<SettingUpdate />
<SettingAbout />
</dl>
</div>
</div>
@@ -42,38 +41,38 @@
import { useRefGetter, watch, useCommit } from '@renderer/utils/vueTools'
import { currentStting } from './setting'
import Basic from './components/Basic'
import Play from './components/Play'
import DesktopLyric from './components/DesktopLyric'
import Search from './components/Search'
import List from './components/List'
import Download from './components/Download'
import Sync from './components/Sync'
import HotKey from './components/HotKey'
import Network from './components/Network'
import Odc from './components/Odc'
import Backup from './components/Backup'
import Other from './components/Other'
import Update from './components/Update'
import About from './components/About'
import SettingBasic from './components/SettingBasic'
import SettingPlay from './components/SettingPlay'
import SettingDesktopLyric from './components/SettingDesktopLyric'
import SettingSearch from './components/SettingSearch'
import SettingList from './components/SettingList'
import SettingDownload from './components/SettingDownload'
import SettingSync from './components/SettingSync'
import SettingHotKey from './components/SettingHotKey'
import SettingNetwork from './components/SettingNetwork'
import SettingOdc from './components/SettingOdc'
import SettingBackup from './components/SettingBackup'
import SettingOther from './components/SettingOther'
import SettingUpdate from './components/SettingUpdate'
import SettingAbout from './components/SettingAbout'
export default {
name: 'Setting',
components: {
Basic,
Play,
DesktopLyric,
Search,
List,
Download,
Sync,
HotKey,
Network,
Odc,
Backup,
Other,
Update,
About,
SettingBasic,
SettingPlay,
SettingDesktopLyric,
SettingSearch,
SettingList,
SettingDownload,
SettingSync,
SettingHotKey,
SettingNetwork,
SettingOdc,
SettingBackup,
SettingOther,
SettingUpdate,
SettingAbout,
},
setup() {
const setting = useRefGetter('setting')
@@ -59,7 +59,7 @@ import { openUrl, clipboardWriteText } from '@renderer/utils'
import { currentStting } from '../setting'
export default {
name: 'About',
name: 'SettingAbout',
setup() {
const handleShowPact = () => {
isShowPact.value = true
@@ -31,7 +31,7 @@ import { currentStting } from '../setting'
import { getList } from '@renderer/core/share/utils'
export default {
name: 'Update',
name: 'SettingUpdate',
setup() {
const { t } = useI18n()
const setting = useGetter('setting')
@@ -63,7 +63,7 @@ import apiSourceInfo from '@renderer/utils/music/api-source-info'
import UserApiModal from './UserApiModal'
export default {
name: 'Basic',
name: 'SettingBasic',
components: {
UserApiModal,
},
@@ -21,7 +21,7 @@ import { getSystemFonts } from '@renderer/utils/tools'
import { currentStting } from '../setting'
export default {
name: 'DesktopLyric',
name: 'SettingDesktopLyric',
setup() {
const { t } = useI18n()
const systemFontList = ref([])
@@ -44,7 +44,7 @@ import { openDirInExplorer, selectDir } from '@renderer/utils'
import { currentStting } from '../setting'
export default {
name: 'Download',
name: 'SettingDownload',
setup() {
const { t } = useI18n()
@@ -51,7 +51,7 @@ const formatHotKeyName = (name) => {
}
export default {
name: 'HotKey',
name: 'SettingHotKey',
setup() {
const { t } = useI18n()
const current_hot_key = ref({
@@ -20,7 +20,7 @@ dd(:tips="$t('setting__basic_sourcename_title')")
import { currentStting } from '../setting'
export default {
name: 'List',
name: 'SettingList',
setup() {
return {
currentStting,
@@ -22,7 +22,7 @@ import { debounce } from '@renderer/utils'
import { currentStting } from '../setting'
export default {
name: 'Network',
name: 'SettingNetwork',
setup() {
watch(() => currentStting.value.network.proxy.enable, enable => {
proxy.enable = enable
@@ -12,7 +12,7 @@ dd
import { currentStting } from '../setting'
export default {
name: 'Odc',
name: 'SettingOdc',
setup() {
return {
currentStting,
@@ -26,7 +26,7 @@ import { sizeFormate, clearCache, getCacheSize } from '@renderer/utils'
import { currentStting } from '../setting'
export default {
name: 'Other',
name: 'SettingOther',
setup() {
const { t } = useI18n()
@@ -26,7 +26,7 @@ import { setTaskBarProgress } from '@renderer/utils/tools'
import { currentStting } from '../setting'
export default {
name: 'Play',
name: 'SettingPlay',
setup() {
const mediaDevices = ref([])
const getMediaDevice = async() => {
@@ -15,7 +15,7 @@ dd
import { currentStting } from '../setting'
export default {
name: 'Search',
name: 'SettingSearch',
setup() {
return {
currentStting,
@@ -23,7 +23,7 @@ import { debounce } from '@renderer/utils'
import { currentStting } from '../setting'
export default {
name: 'Update',
name: 'SettingSync',
setup() {
const { t } = useI18n()
@@ -22,7 +22,7 @@ import { sizeFormate } from '@renderer/utils/tools'
import { currentStting } from '../setting'
export default {
name: 'Update',
name: 'SettingUpdate',
setup() {
const { t } = useI18n()
+1 -1
View File
@@ -169,7 +169,7 @@ export default {
if (!this.isVisibleListDetail) this.setTagListWidth()
this.listenEvent()
},
beforeDestroy() {
beforeUnmount() {
this.unlistenEvent()
},
methods: {
@@ -28,16 +28,17 @@ export default {
},
modelValue: {
type: Object,
required: true,
},
},
computed: {
...mapGetters(['setting']),
},
data() {
return {
show: false,
}
},
computed: {
...mapGetters(['setting']),
},
mounted() {
document.addEventListener('click', this.handleHide)
},