Ver código fonte

文物列表scroll行为优化

(cherry picked from commit caf4875bb40a6c84036a4976a26a9111cc8cf6b6)
任一存 2 anos atrás
pai
commit
8b354642cf
3 arquivos alterados com 8 adições e 1 exclusões
  1. 3 0
      src/store/index.js
  2. 1 0
      src/views/RelicList.vue
  3. 4 1
      src/views/UnitList.vue

+ 3 - 0
src/store/index.js

@@ -13,6 +13,9 @@ export default createStore({
     },
     recordRelicListScrollValue(state, value) {
       state.relicListScrollValue = value
+    },
+    resetRelicListScrollValue(state) {
+      state.relicListScrollValue = 0
     }
   },
   actions: {

+ 1 - 0
src/views/RelicList.vue

@@ -102,6 +102,7 @@ onMounted(() => {
 })
 
 function onClickTabItem(idx) {
+  relicListEl.value.scrollLeft = 0
   router.push({
     name: route.name,
     query: {

+ 4 - 1
src/views/UnitList.vue

@@ -45,7 +45,7 @@
 </template>
 
 <script setup>
-import { computed } from "vue"
+import { computed, onMounted } from "vue"
 import { useStore } from "vuex"
 import { numberToWords } from "pixiu-number-toolkit"
 const {
@@ -63,6 +63,9 @@ function int2zh(idx) {
   return numberToWords(idx, "zh")
 }
 
+onMounted(() => {
+  store.commit('resetRelicListScrollValue')
+})
 </script>
 
 <style lang="less" scoped>