完成同步功能
This commit is contained in:
+12
-11
@@ -355,7 +355,7 @@ export default {
|
||||
'removeUserList',
|
||||
'setListScroll',
|
||||
'setList',
|
||||
'sortList',
|
||||
'setMusicPosition',
|
||||
]),
|
||||
...mapActions('songList', ['getListDetailAll']),
|
||||
...mapActions('leaderboard', {
|
||||
@@ -576,7 +576,7 @@ export default {
|
||||
this.setPlayList({ list: this.listData, index })
|
||||
},
|
||||
handleRemove(index) {
|
||||
this.listRemove({ id: this.listId, index })
|
||||
this.listRemove({ listId: this.listId, id: this.list[index].songmid })
|
||||
},
|
||||
handleListBtnClick(info) {
|
||||
switch (info.action) {
|
||||
@@ -677,8 +677,9 @@ export default {
|
||||
let dom_target = this.$refs.dom_lists_list.querySelector('.' + this.$style.editing)
|
||||
if (dom_target) dom_target.classList.remove(this.$style.editing)
|
||||
let name = event.target.value.trim()
|
||||
if (name.length) return this.setUserListName({ index, name })
|
||||
event.target.value = this.userList[index].name
|
||||
const targetList = this.userList[index]
|
||||
if (name.length) return this.setUserListName({ id: targetList.id, name })
|
||||
event.target.value = targetList.name
|
||||
},
|
||||
handleListsCreate(event) {
|
||||
if (event.target.readonly) return
|
||||
@@ -774,13 +775,13 @@ export default {
|
||||
this.handleSyncSourceList(index)
|
||||
break
|
||||
case 'moveup':
|
||||
this.moveupUserList(index)
|
||||
this.moveupUserList({ id: this.userList[index].id })
|
||||
break
|
||||
case 'movedown':
|
||||
this.movedownUserList(index)
|
||||
this.movedownUserList({ id: this.userList[index].id })
|
||||
break
|
||||
case 'remove':
|
||||
this.removeUserList(index)
|
||||
this.removeUserList({ id: this.userList[index].id })
|
||||
break
|
||||
}
|
||||
},
|
||||
@@ -870,7 +871,7 @@ export default {
|
||||
break
|
||||
case 'remove':
|
||||
if (this.selectdListDetailData.length) {
|
||||
this.listRemoveMultiple({ id: this.listId, list: this.selectdListDetailData })
|
||||
this.listRemoveMultiple({ listId: this.listId, ids: this.selectdListDetailData.map(m => m.songmid) })
|
||||
this.removeAllSelectListDetail()
|
||||
} else {
|
||||
this.handleRemove(index)
|
||||
@@ -929,10 +930,10 @@ export default {
|
||||
},
|
||||
handleSortMusicInfo(num) {
|
||||
num = Math.min(num, this.list.length)
|
||||
this.sortList({
|
||||
this.setMusicPosition({
|
||||
id: this.listId,
|
||||
sortNum: num,
|
||||
musicInfos: this.selectdListDetailData.length ? [...this.selectdListDetailData] : [this.musicInfo],
|
||||
position: num,
|
||||
list: this.selectdListDetailData.length ? [...this.selectdListDetailData] : [this.musicInfo],
|
||||
})
|
||||
this.removeAllSelectListDetail()
|
||||
this.isShowListSortModal = false
|
||||
|
||||
@@ -150,6 +150,21 @@ div(:class="$style.main")
|
||||
div
|
||||
material-checkbox(id="setting_download_isDownloadLrc" v-model="current_setting.download.isDownloadLrc" :label="$t('view.setting.is_enable')")
|
||||
|
||||
dt#sync {{$t('view.setting.sync')}}
|
||||
dd
|
||||
material-checkbox(id="setting_sync_enable" v-model="current_setting.sync.enable" @change="handleSyncChange('enable')" :label="syncEnableTitle")
|
||||
div
|
||||
p.small {{$t('view.setting.sync_auth_code', { code: sync.status.code || '' })}}
|
||||
p.small {{$t('view.setting.sync_address', { address: sync.status.address.join(', ') || '' })}}
|
||||
p.small {{$t('view.setting.sync_device', { devices: syncDevices })}}
|
||||
p
|
||||
material-btn(:class="$style.btn" min :disabled="!current_setting.sync.enable" @click="handleRefreshSyncCode") {{$t('view.setting.sync_refresh_code')}}
|
||||
dd
|
||||
h3#sync_port {{$t('view.setting.sync_port')}}
|
||||
div
|
||||
p
|
||||
material-input(:class="$style.gapLeft" v-model.trim="current_setting.sync.port" @change="handleSyncChange('port')" :placeholder="$t('view.setting.sync_port_tip')")
|
||||
|
||||
dt#hot_key {{$t('view.setting.hot_key')}}
|
||||
dd
|
||||
h3#hot_key_local_title {{$t('view.setting.hot_key_local_title')}}
|
||||
@@ -295,7 +310,7 @@ import {
|
||||
getSetting,
|
||||
saveSetting,
|
||||
} from '../utils'
|
||||
import { rendererSend, rendererInvoke, NAMES } from '@common/ipc'
|
||||
import { rendererSend, rendererInvoke, rendererOn, NAMES, rendererOff } from '@common/ipc'
|
||||
import { mergeSetting, isMac } from '../../common/utils'
|
||||
import apiSourceInfo from '../utils/music/api-source-info'
|
||||
import fs from 'fs'
|
||||
@@ -410,6 +425,21 @@ export default {
|
||||
},
|
||||
]
|
||||
},
|
||||
syncEnableTitle() {
|
||||
let title = this.$t('view.setting.sync_enable')
|
||||
if (this.sync.status.message) {
|
||||
title += ` [${this.sync.status.message}]`
|
||||
}
|
||||
// else if (this.sync.status.address.length) {
|
||||
// // title += ` [${this.sync.status.address.join(', ')}]`
|
||||
// }
|
||||
return title
|
||||
},
|
||||
syncDevices() {
|
||||
return this.sync.status.devices.length
|
||||
? this.sync.status.devices.map(d => `${d.deviceName} (${d.clientId.substring(0, 5)})`).join(', ')
|
||||
: ''
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -474,6 +504,10 @@ export default {
|
||||
isToTray: false,
|
||||
themeId: 0,
|
||||
},
|
||||
sync: {
|
||||
enable: false,
|
||||
port: '23332',
|
||||
},
|
||||
windowSizeId: 1,
|
||||
langId: 'cns',
|
||||
themeId: 0,
|
||||
@@ -608,6 +642,15 @@ export default {
|
||||
},
|
||||
isDisabledResourceCacheClear: false,
|
||||
isDisabledListCacheClear: false,
|
||||
sync: {
|
||||
status: {
|
||||
status: false,
|
||||
message: '',
|
||||
address: [],
|
||||
code: '',
|
||||
devices: [],
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -665,6 +708,7 @@ export default {
|
||||
window.eventHub.$off(eventBaseName.set_config, this.handleUpdateSetting)
|
||||
window.eventHub.$off(eventBaseName.key_down, this.handleKeyDown)
|
||||
window.eventHub.$off(eventBaseName.set_hot_key_config, this.handleUpdateHotKeyConfig)
|
||||
this.syncUnInit()
|
||||
|
||||
if (this.current_setting.network.proxy.enable && !this.current_setting.network.proxy.host) window.globalObj.proxy.enable = false
|
||||
},
|
||||
@@ -684,6 +728,7 @@ export default {
|
||||
this.current_hot_key = window.appHotKeyConfig
|
||||
this.initHotKeyConfig()
|
||||
this.getHotKeyStatus()
|
||||
this.syncInit()
|
||||
},
|
||||
// initTOC() {
|
||||
// const list = this.$refs.dom_setting_list.children
|
||||
@@ -1151,6 +1196,42 @@ export default {
|
||||
|
||||
return status
|
||||
},
|
||||
setStatus(e, status) {
|
||||
this.sync.status.status = status.status
|
||||
this.sync.status.message = status.message
|
||||
this.sync.status.address = status.address
|
||||
this.sync.status.code = status.code
|
||||
this.sync.status.devices = status.devices
|
||||
},
|
||||
syncInit() {
|
||||
rendererInvoke(NAMES.mainWindow.sync_get_status).then(status => {
|
||||
this.sync.status.status = status.status
|
||||
this.sync.status.message = status.message
|
||||
this.sync.status.address = status.address
|
||||
this.sync.status.code = status.code
|
||||
this.sync.status.devices = status.devices
|
||||
})
|
||||
rendererOn(NAMES.mainWindow.sync_status, this.setStatus)
|
||||
},
|
||||
syncUnInit() {
|
||||
rendererOff(NAMES.mainWindow.sync_status, this.setStatus)
|
||||
},
|
||||
handleSyncChange(action) {
|
||||
switch (action) {
|
||||
case 'port':
|
||||
if (!this.current_setting.sync.enable) return
|
||||
case 'enable':
|
||||
rendererInvoke(NAMES.mainWindow.sync_enable, {
|
||||
enable: this.current_setting.sync.enable,
|
||||
port: this.current_setting.sync.port,
|
||||
})
|
||||
window.globalObj.sync.enable = this.current_setting.sync.enable
|
||||
break
|
||||
}
|
||||
},
|
||||
handleRefreshSyncCode() {
|
||||
rendererInvoke(NAMES.mainWindow.sync_generate_code)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user