修复问题

pull/733/head
lyswhut 2021-12-04 17:25:21 +08:00
parent 9afafec9d6
commit 60e606a413
13 changed files with 62 additions and 83 deletions

View File

@ -1,15 +1,12 @@
{ {
"extends": [ "extends": [
"plugin:vue/vue3-recommended", // "plugin:vue/vue3-recommended",
"standard" "standard"
], ],
"plugins": [ "plugins": [
"html" "html"
], ],
"parser": "vue-eslint-parser", "parser": "babel-eslint",
"parserOptions": {
"parser": "babel-eslint"
},
"rules": { "rules": {
"no-new": "off", "no-new": "off",
"camelcase": "off", "camelcase": "off",

View File

@ -1,9 +1,7 @@
<template> <template>
<button <button
:class="[$style.btn, {[$style.min]: min}, {[$style.outline]: outline}]" :class="[$style.btn, {[$style.min]: min}, {[$style.outline]: outline}]"
:disabled="disabled" :disabled="disabled">
@click="$emit('click', $event)"
>
<slot /> <slot />
</button> </button>
</template> </template>
@ -23,7 +21,6 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['click'],
} }
</script> </script>

View File

@ -32,7 +32,7 @@ export default {
default: 'text', default: 'text',
}, },
}, },
emits: ['update:modelValue', 'keydown', 'blur', 'submit', 'change', 'focus'], emits: ['update:modelValue', 'submit', 'change'],
methods: { methods: {
handleInput(event) { handleInput(event) {
let value = event.target.value.trim() let value = event.target.value.trim()

View File

@ -105,7 +105,7 @@ export default {
require: true, require: true,
}, },
}, },
emits: ['contextmenu', 'scroll'], emits: ['scroll'],
setup(props, { emit }) { setup(props, { emit }) {
const views = ref([]) const views = ref([])
const dom_scrollContainer = ref(null) const dom_scrollContainer = ref(null)

View File

@ -8,7 +8,6 @@ import { debounce } from '@renderer/utils'
import { import {
ref, ref,
useRoute, useRoute,
useGetter,
watch, watch,
useRefGetter, useRefGetter,
useRouter, useRouter,
@ -26,14 +25,14 @@ export default {
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
const setting = useGetter('setting') const setting = useRefGetter('setting')
const clearSearchList = useCommit('search', 'clearList') const clearSearchList = useCommit('search', 'clearList')
watch(() => route.name, (newValue, oldValue) => { watch(() => route.name, (newValue, oldValue) => {
if (newValue.name != 'search') { if (newValue.name != 'search') {
if (setting.odc.isAutoClearSearchInput && searchText.value) searchText.value = '' if (setting.value.odc.isAutoClearSearchInput && searchText.value) searchText.value = ''
if (setting.odc.isAutoClearSearchList) clearSearchList() if (setting.value.odc.isAutoClearSearchList) clearSearchList()
} }
}) })
@ -50,10 +49,10 @@ export default {
const tipSearch = debounce(() => { const tipSearch = debounce(() => {
if (searchText.value === '') { if (searchText.value === '') {
tipList.value = [] tipList.value = []
music[setting.search.tempSearchSource].tempSearch.cancelTempSearch() music[setting.value.search.tempSearchSource].tempSearch.cancelTempSearch()
return return
} }
music[setting.search.tempSearchSource].tempSearch.search(searchText.value).then(list => { music[setting.value.search.tempSearchSource].tempSearch.search(searchText.value).then(list => {
tipList.value = list tipList.value = list
}).catch(() => {}) }).catch(() => {})
}, 50) }, 50)

View File

@ -49,6 +49,7 @@ export default ({
}) })
const rSetConfig = onSetConfig((event, config) => { const rSetConfig = onSetConfig((event, config) => {
console.log(config)
setSetting(Object.assign({}, toRaw(setting.value), config)) setSetting(Object.assign({}, toRaw(setting.value), config))
window.eventHub.emit(eventBaseName.set_config, config) window.eventHub.emit(eventBaseName.set_config, config)
}) })

View File

@ -1,4 +1,4 @@
import { useCommit, useGetter, onBeforeUnmount, toRaw } from '@renderer/utils/vueTools' import { useCommit, useRefGetter, onBeforeUnmount, toRaw } from '@renderer/utils/vueTools'
import { sync as eventSyncName } from '@renderer/event/names' import { sync as eventSyncName } from '@renderer/event/names'
import { syncEnable, onSyncStatus } from '@renderer/utils/tools' import { syncEnable, onSyncStatus } from '@renderer/utils/tools'
import { sync } from '@renderer/core/share' import { sync } from '@renderer/core/share'
@ -22,7 +22,7 @@ export default () => {
const setMusicPosition = useCommit('list', 'setMusicPosition') const setMusicPosition = useCommit('list', 'setMusicPosition')
const setSyncListData = useCommit('list', 'setSyncListData') const setSyncListData = useCommit('list', 'setSyncListData')
const setting = useGetter('setting') const setting = useRefGetter('setting')
const handleSyncAction = ({ action, data }) => { const handleSyncAction = ({ action, data }) => {
if (typeof data == 'object') data.isSync = true if (typeof data == 'object') data.isSync = true
@ -115,10 +115,10 @@ export default () => {
sync.status.devices = status.devices sync.status.devices = status.devices
}) })
if (setting.sync.enable && setting.sync.port) { if (setting.value.sync.enable && setting.value.sync.port) {
syncEnable({ syncEnable({
enable: setting.sync.enable, enable: setting.value.sync.enable,
port: setting.sync.port, port: setting.value.sync.port,
}) })
} }

View File

@ -8,7 +8,7 @@
<script> <script>
import { getListPrevSelectId } from '@renderer/utils/data' import { getListPrevSelectId } from '@renderer/utils/data'
import { isInitedList } from '@renderer/core/share/list' import { isInitedList, defaultList } from '@renderer/core/share/list'
import { getList } from '@renderer/core/share/utils' import { getList } from '@renderer/core/share/utils'
import MyLists from './components/MyLists' import MyLists from './components/MyLists'
@ -31,51 +31,41 @@ export default {
focusTarget: 'listDetail', focusTarget: 'listDetail',
} }
}, },
beforeRouteEnter(to, from) {
let id = to.query.id
if (!id) {
id = getListPrevSelectId() || defaultList.id
return {
path: '/list',
query: { id },
}
}
},
beforeRouteUpdate(to, from) { beforeRouteUpdate(to, from) {
// console.log(to, from) // console.log(to, from)
if (to.query.updated) return
let id = to.query.id let id = to.query.id
if (id == null) return if (id == null) {
if (!getList(id)) { id = defaultList.id
id = this.$store.state.list.defaultList.id } else if (!getList(id)) {
this.handleListToggle(id) id = defaultList.id
} }
this.listId = id this.listId = id
const scrollIndex = to.query.scrollIndex const scrollIndex = to.query.scrollIndex
if (from.query.id == to.query.id) { const isAnimation = from.query.id == to.query.id
if (!scrollIndex) return
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.musicList.restoreScroll(scrollIndex, true) this.$refs.musicList.restoreScroll(scrollIndex, isAnimation)
this.$nextTick(() => {
this.$router.replace({
path: 'list',
query: {
id,
},
})
})
}) })
return {
path: '/list',
query: { id, updated: true },
} }
}, },
beforeRouteLeave(to, from) { beforeRouteLeave(to, from) {
this.$refs.musicList.saveListPosition() this.$refs.musicList.saveListPosition()
}, },
created() { created() {
let id = this.$route.query.id this.listId = this.$route.query.id
if (!id) {
id = getListPrevSelectId() || this.$store.state.list.defaultList.id
this.handleListToggle(id)
}
this.listId = id
},
methods: {
handleListToggle(id) {
if (id == this.listId) return
this.$router.replace({
path: 'list',
query: { id },
}).catch(_ => _)
},
}, },
} }
</script> </script>

View File

@ -1,4 +1,4 @@
import { useRoute, useRouter, onMounted, onBeforeUnmount, nextTick, watch } from '@renderer/utils/vueTools' import { useRoute, useRouter, onMounted, onBeforeUnmount } from '@renderer/utils/vueTools'
import { setListPosition, getListPosition } from '@renderer/utils/data' import { setListPosition, getListPosition } from '@renderer/utils/data'
export default ({ props, listRef, list, setting }) => { export default ({ props, listRef, list, setting }) => {
@ -27,21 +27,6 @@ export default ({ props, listRef, list, setting }) => {
handleScrollList(index, isAnimation) handleScrollList(index, isAnimation)
} }
watch(() => route.query.id, (id, oId) => {
if (!oId || route.path != '/list') return
const scrollIndex = route.query.scrollIndex
nextTick(() => {
restoreScroll(scrollIndex, false)
if (scrollIndex != null) {
router.replace({
path: 'list',
query: {
id: props.listId,
},
})
}
})
})
onMounted(() => { onMounted(() => {
restoreScroll(route.query.scrollIndex, false) restoreScroll(route.query.scrollIndex, false)
if (route.query.scrollIndex != null) { if (route.query.scrollIndex != null) {
@ -49,6 +34,7 @@ export default ({ props, listRef, list, setting }) => {
path: 'list', path: 'list',
query: { query: {
id: props.listId, id: props.listId,
updated: true,
}, },
}) })
} }

View File

@ -160,6 +160,9 @@ export default {
created() { created() {
this.setPrevSelectListId(this.listId) this.setPrevSelectListId(this.listId)
}, },
mounted() {
this.setListsScroll()
},
methods: { methods: {
...mapMutations('list', [ ...mapMutations('list', [
'setUserListName', 'setUserListName',
@ -174,6 +177,13 @@ export default {
...mapActions('leaderboard', { ...mapActions('leaderboard', {
getBoardListAll: 'getListAll', getBoardListAll: 'getListAll',
}), }),
setListsScroll() {
let target = this.$refs.dom_lists_list.querySelector('.' + this.$style.active)
if (!target) return
let offsetTop = target.offsetTop
let location = offsetTop - 150
if (location > 0) this.$refs.dom_lists_list.scrollTop = location
},
handleListsSave(index, event) { handleListsSave(index, event) {
let dom_target = this.$refs.dom_lists_list.querySelector('.' + this.$style.editing) let dom_target = this.$refs.dom_lists_list.querySelector('.' + this.$style.editing)
if (dom_target) dom_target.classList.remove(this.$style.editing) if (dom_target) dom_target.classList.remove(this.$style.editing)
@ -351,8 +361,6 @@ export default {
}) })
}, },
handleImportList(index) { handleImportList(index) {
const list = this.getTargetListInfo(index)
selectDir({ selectDir({
title: this.$t('lists__import_part_desc'), title: this.$t('lists__import_part_desc'),
properties: ['openFile'], properties: ['openFile'],

View File

@ -38,7 +38,7 @@
</template> </template>
<script> <script>
import { useRefGetter, watch, useCommit } from '@renderer/utils/vueTools' import { useRefGetter, watch, useCommit, toRaw } from '@renderer/utils/vueTools'
import { currentStting } from './setting' import { currentStting } from './setting'
import SettingBasic from './components/SettingBasic' import SettingBasic from './components/SettingBasic'
@ -78,10 +78,11 @@ export default {
const setting = useRefGetter('setting') const setting = useRefGetter('setting')
const setSetting = useCommit('setSetting') const setSetting = useCommit('setSetting')
currentStting.value = JSON.parse(JSON.stringify(setting.value)) currentStting.value = JSON.parse(JSON.stringify(toRaw(setting.value)))
watch(currentStting, newSetting => { watch(currentStting, newSetting => {
const newSettingStr = JSON.stringify(newSetting) const newSettingStr = JSON.stringify(newSetting)
if (newSettingStr === JSON.stringify(setting.value)) return if (newSettingStr === JSON.stringify(setting.value)) return
console.log(newSetting)
setSetting(JSON.parse(newSettingStr)) setSetting(JSON.parse(newSettingStr))
}, { }, {
deep: true, deep: true,

View File

@ -15,7 +15,7 @@ dd
</template> </template>
<script> <script>
import { useCommit, useI18n, onBeforeUnmount, useGetter, toRaw } from '@renderer/utils/vueTools' import { useCommit, useI18n, onBeforeUnmount, toRaw, useRefGetter } from '@renderer/utils/vueTools'
import { mergeSetting } from '@common/utils' import { mergeSetting } from '@common/utils'
import { base as eventBaseName } from '@renderer/event/names' import { base as eventBaseName } from '@renderer/event/names'
import { defaultList, loveList, userLists } from '@renderer/core/share/list' import { defaultList, loveList, userLists } from '@renderer/core/share/list'
@ -34,9 +34,8 @@ export default {
name: 'SettingUpdate', name: 'SettingUpdate',
setup() { setup() {
const { t } = useI18n() const { t } = useI18n()
const setting = useGetter('setting') const setting = useRefGetter('setting')
const settingVersion = useGetter('settingVersion') const settingVersion = useRefGetter('settingVersion')
const setSetting = useCommit('setSetting')
const setSettingVersion = useCommit('setSettingVersion') const setSettingVersion = useCommit('setSettingVersion')
const setList = useCommit('list', 'setList') const setList = useCommit('list', 'setList')
@ -44,9 +43,9 @@ export default {
currentStting.value = JSON.parse(JSON.stringify(config)) currentStting.value = JSON.parse(JSON.stringify(config))
} }
const refreshSetting = async(newSetting, newVersion) => { const refreshSetting = async(newSetting, newVersion) => {
await saveSetting(newSetting) await saveSetting(toRaw(newSetting))
const { setting, version } = await getSetting() const { setting, version } = await getSetting()
setSetting(setting) currentStting.value = setting
setSettingVersion(version) setSettingVersion(version)
} }
@ -112,13 +111,13 @@ export default {
}) })
} }
const exportSetting = (path) => { const exportSetting = (path) => {
console.log(path) console.log(path)
const data = { const data = {
type: 'setting', type: 'setting',
data: Object.assign({ version: settingVersion.value }, toRaw(setting.value)), data: Object.assign({ version: settingVersion.value }, toRaw(setting.value)),
} }
console.log(data)
saveLxConfigFile(path, data) saveLxConfigFile(path, data)
} }
const handleExportSetting = () => { const handleExportSetting = () => {

View File

@ -91,6 +91,7 @@ export default {
} }
const handleHotKeyFocus = async(event, info, type) => { const handleHotKeyFocus = async(event, info, type) => {
console.log('object')
await hotKeySetEnable(false) await hotKeySetEnable(false)
window.isEditingHotKey = true window.isEditingHotKey = true
isEditHotKey = true isEditHotKey = true