Skip to content

Commit

Permalink
修复问题
Browse files Browse the repository at this point in the history
  • Loading branch information
lyswhut committed Dec 4, 2021
1 parent 9afafec commit 60e606a
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 83 deletions.
7 changes: 2 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"extends": [
"plugin:vue/vue3-recommended",
// "plugin:vue/vue3-recommended",
"standard"
],
"plugins": [
"html"
],
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "babel-eslint"
},
"parser": "babel-eslint",
"rules": {
"no-new": "off",
"camelcase": "off",
Expand Down
5 changes: 1 addition & 4 deletions src/renderer/components/base/Btn.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<template>
<button
:class="[$style.btn, {[$style.min]: min}, {[$style.outline]: outline}]"
:disabled="disabled"
@click="$emit('click', $event)"
>
:disabled="disabled">
<slot />
</button>
</template>
Expand All @@ -23,7 +21,6 @@ export default {
default: false,
},
},
emits: ['click'],
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/base/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
default: 'text',
},
},
emits: ['update:modelValue', 'keydown', 'blur', 'submit', 'change', 'focus'],
emits: ['update:modelValue', 'submit', 'change'],
methods: {
handleInput(event) {
let value = event.target.value.trim()
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/base/VirtualizedList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default {
require: true,
},
},
emits: ['contextmenu', 'scroll'],
emits: ['scroll'],
setup(props, { emit }) {
const views = ref([])
const dom_scrollContainer = ref(null)
Expand Down
11 changes: 5 additions & 6 deletions src/renderer/components/core/Toolbar/SearchInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { debounce } from '@renderer/utils'
import {
ref,
useRoute,
useGetter,
watch,
useRefGetter,
useRouter,
Expand All @@ -26,14 +25,14 @@ export default {
const route = useRoute()
const router = useRouter()
const setting = useGetter('setting')
const setting = useRefGetter('setting')
const clearSearchList = useCommit('search', 'clearList')
watch(() => route.name, (newValue, oldValue) => {
if (newValue.name != 'search') {
if (setting.odc.isAutoClearSearchInput && searchText.value) searchText.value = ''
if (setting.odc.isAutoClearSearchList) clearSearchList()
if (setting.value.odc.isAutoClearSearchInput && searchText.value) searchText.value = ''
if (setting.value.odc.isAutoClearSearchList) clearSearchList()
}
})
Expand All @@ -50,10 +49,10 @@ export default {
const tipSearch = debounce(() => {
if (searchText.value === '') {
tipList.value = []
music[setting.search.tempSearchSource].tempSearch.cancelTempSearch()
music[setting.value.search.tempSearchSource].tempSearch.cancelTempSearch()
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
}).catch(() => {})
}, 50)
Expand Down
1 change: 1 addition & 0 deletions src/renderer/core/useApp/useEventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default ({
})

const rSetConfig = onSetConfig((event, config) => {
console.log(config)
setSetting(Object.assign({}, toRaw(setting.value), config))
window.eventHub.emit(eventBaseName.set_config, config)
})
Expand Down
10 changes: 5 additions & 5 deletions src/renderer/core/useApp/useSync.js
Original file line number Diff line number Diff line change
@@ -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 { syncEnable, onSyncStatus } from '@renderer/utils/tools'
import { sync } from '@renderer/core/share'
Expand All @@ -22,7 +22,7 @@ export default () => {
const setMusicPosition = useCommit('list', 'setMusicPosition')
const setSyncListData = useCommit('list', 'setSyncListData')

const setting = useGetter('setting')
const setting = useRefGetter('setting')

const handleSyncAction = ({ action, data }) => {
if (typeof data == 'object') data.isSync = true
Expand Down Expand Up @@ -115,10 +115,10 @@ export default () => {
sync.status.devices = status.devices
})

if (setting.sync.enable && setting.sync.port) {
if (setting.value.sync.enable && setting.value.sync.port) {
syncEnable({
enable: setting.sync.enable,
port: setting.sync.port,
enable: setting.value.sync.enable,
port: setting.value.sync.port,
})
}

Expand Down
58 changes: 24 additions & 34 deletions src/renderer/views/list/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<script>
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 MyLists from './components/MyLists'
Expand All @@ -31,51 +31,41 @@ export default {
focusTarget: 'listDetail',
}
},
beforeRouteEnter(to, from) {
let id = to.query.id
if (!id) {
id = getListPrevSelectId() || defaultList.id
return {
path: '/list',
query: { id },
}
}
},
beforeRouteUpdate(to, from) {
// console.log(to, from)
if (to.query.updated) return
let id = to.query.id
if (id == null) return
if (!getList(id)) {
id = this.$store.state.list.defaultList.id
this.handleListToggle(id)
if (id == null) {
id = defaultList.id
} else if (!getList(id)) {
id = defaultList.id
}
this.listId = id
const scrollIndex = to.query.scrollIndex
if (from.query.id == to.query.id) {
if (!scrollIndex) return
this.$nextTick(() => {
this.$refs.musicList.restoreScroll(scrollIndex, true)
this.$nextTick(() => {
this.$router.replace({
path: 'list',
query: {
id,
},
})
})
})
const isAnimation = from.query.id == to.query.id
this.$nextTick(() => {
this.$refs.musicList.restoreScroll(scrollIndex, isAnimation)
})
return {
path: '/list',
query: { id, updated: true },
}
},
beforeRouteLeave(to, from) {
this.$refs.musicList.saveListPosition()
},
created() {
let id = 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(_ => _)
},
this.listId = this.$route.query.id
},
}
</script>
Expand Down
18 changes: 2 additions & 16 deletions src/renderer/views/list/components/MusicList/useListScroll.js
Original file line number Diff line number Diff line change
@@ -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'

export default ({ props, listRef, list, setting }) => {
Expand Down Expand Up @@ -27,28 +27,14 @@ export default ({ props, listRef, list, setting }) => {
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(() => {
restoreScroll(route.query.scrollIndex, false)
if (route.query.scrollIndex != null) {
router.replace({
path: 'list',
query: {
id: props.listId,
updated: true,
},
})
}
Expand Down
12 changes: 10 additions & 2 deletions src/renderer/views/list/components/MyLists.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ export default {
created() {
this.setPrevSelectListId(this.listId)
},
mounted() {
this.setListsScroll()
},
methods: {
...mapMutations('list', [
'setUserListName',
Expand All @@ -174,6 +177,13 @@ export default {
...mapActions('leaderboard', {
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) {
let dom_target = this.$refs.dom_lists_list.querySelector('.' + this.$style.editing)
if (dom_target) dom_target.classList.remove(this.$style.editing)
Expand Down Expand Up @@ -351,8 +361,6 @@ export default {
})
},
handleImportList(index) {
const list = this.getTargetListInfo(index)
selectDir({
title: this.$t('lists__import_part_desc'),
properties: ['openFile'],
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/views/setting/Setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</template>

<script>
import { useRefGetter, watch, useCommit } from '@renderer/utils/vueTools'
import { useRefGetter, watch, useCommit, toRaw } from '@renderer/utils/vueTools'
import { currentStting } from './setting'
import SettingBasic from './components/SettingBasic'
Expand Down Expand Up @@ -78,10 +78,11 @@ export default {
const setting = useRefGetter('setting')
const setSetting = useCommit('setSetting')
currentStting.value = JSON.parse(JSON.stringify(setting.value))
currentStting.value = JSON.parse(JSON.stringify(toRaw(setting.value)))
watch(currentStting, newSetting => {
const newSettingStr = JSON.stringify(newSetting)
if (newSettingStr === JSON.stringify(setting.value)) return
console.log(newSetting)
setSetting(JSON.parse(newSettingStr))
}, {
deep: true,
Expand Down
13 changes: 6 additions & 7 deletions src/renderer/views/setting/components/SettingBackup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dd
</template>

<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 { base as eventBaseName } from '@renderer/event/names'
import { defaultList, loveList, userLists } from '@renderer/core/share/list'
Expand All @@ -34,19 +34,18 @@ export default {
name: 'SettingUpdate',
setup() {
const { t } = useI18n()
const setting = useGetter('setting')
const settingVersion = useGetter('settingVersion')
const setSetting = useCommit('setSetting')
const setting = useRefGetter('setting')
const settingVersion = useRefGetter('settingVersion')
const setSettingVersion = useCommit('setSettingVersion')
const setList = useCommit('list', 'setList')
const handleUpdateSetting = (config) => {
currentStting.value = JSON.parse(JSON.stringify(config))
}
const refreshSetting = async(newSetting, newVersion) => {
await saveSetting(newSetting)
await saveSetting(toRaw(newSetting))
const { setting, version } = await getSetting()
setSetting(setting)
currentStting.value = setting
setSettingVersion(version)
}
Expand Down Expand Up @@ -112,13 +111,13 @@ export default {
})
}
const exportSetting = (path) => {
console.log(path)
const data = {
type: 'setting',
data: Object.assign({ version: settingVersion.value }, toRaw(setting.value)),
}
console.log(data)
saveLxConfigFile(path, data)
}
const handleExportSetting = () => {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/views/setting/components/SettingHotKey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default {
}
const handleHotKeyFocus = async(event, info, type) => {
console.log('object')
await hotKeySetEnable(false)
window.isEditingHotKey = true
isEditHotKey = true
Expand Down

0 comments on commit 60e606a

Please sign in to comment.